Completed
Pull Request — master (#1431)
by Abdeali
01:31
created

bears.tests.go.GoLintBearTest.test_run()   A

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 6
rs 9.4285
1
from bears.go.GoLintBear import GoLintBear
2
from bears.tests.LocalBearTestHelper import verify_local_bear
3
4
5
good_file = """
6
// Test that blank imports in package main are not flagged.
7
// OK
8
9
// Binary foo ...
10
package main
11
12
import _ "fmt"
13
14
import (
15
  "os"
16
  _ "path"
17
)
18
19
var _ os.File // for "os"
20
""".split("\n")
21
22
23
bad_file = """
24
// Test that blank imports in library packages are flagged.
25
26
// Package foo ...
27
package foo
28
29
// The instructions need to go before the imports below so they will not be
30
// mistaken for documentation.
31
32
/* MATCH /blank import/ */ import _ "encoding/json"
33
34
import (
35
  "fmt"
36
37
  /* MATCH /blank import/ */ _ "os"
38
39
  /* MATCH /blank import/ */ _ "net/http"
40
  _ "path"
41
)
42
43
import _ "encoding/base64" // Don't gripe about this
44
45
import (
46
  // Don't gripe about these next two lines.
47
  _ "compress/zlib"
48
  _ "syscall"
49
50
  /* MATCH /blank import/ */ _ "path/filepath"
51
)
52
53
import (
54
  "go/ast"
55
  _ "go/scanner" // Don't gripe about this or the following line.
56
  _ "go/token"
57
)
58
59
var (
60
  _ fmt.Stringer // for "fmt"
61
  _ ast.Node     // for "go/ast"
62
)
63
""".split("\n")
64
65
66
GoLintBearTest = verify_local_bear(GoLintBear,
67
                                   valid_files=(good_file,),
68
                                   invalid_files=(bad_file,))
69
70
71
GoLintBearTest = verify_local_bear(
72
    GoLintBear,
73
    valid_files=(),
74
    invalid_files=(bad_file,),
75
    settings={"golint_cli_options": "-min_confidence=0.8"})
76