mirror of
https://github.com/scratchfoundation/golangci-lint.git
synced 2025-08-28 22:28:43 -04:00
1. Allow govet to work in 2 modes: fast and slow. Default is slow. In fast mode golangci-lint runs `go install -i` and `go test -i` for analyzed packages. But it's fast only when: - go >= 1.10 - it's repeated run or $GOPATH/pkg or `go env GOCACHE` is cached between CI builds In slow mode we load program from source code like for another linters and do it only once for all linters. 3. Patch govet code to warn about any troubles with the type information. Default behaviour of govet was to hide such warnings. Fail analysis if there are any troubles with type loading: it will prevent false-positives and false-negatives from govet. 4. Describe almost all options in .golangci.example.yml and include it into README. Describe when to use slow or fast mode of govet. 5. Speed up govet: reuse AST parsing: it's already parsed once by golangci-lint. For "slow" runs (when we run at least one slow linter) speedup by not loading type information second time. 6. Improve logging, debug logging 7. Fix crash in logging of AST cache warnings (#118)
This commit is contained in:
parent
f239b80ce1
commit
5514c4393e
22 changed files with 720 additions and 158 deletions
|
@ -19,8 +19,11 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
var root = filepath.Join("..", "...")
|
||||
var installOnce sync.Once
|
||||
|
||||
const noIssuesOut = "Congrats! No issues were found.\n"
|
||||
|
||||
func installBinary(t assert.TestingT) {
|
||||
installOnce.Do(func() {
|
||||
cmd := exec.Command("go", "install", filepath.Join("..", "cmd", binName))
|
||||
|
@ -30,7 +33,7 @@ func installBinary(t assert.TestingT) {
|
|||
|
||||
func checkNoIssuesRun(t *testing.T, out string, exitCode int) {
|
||||
assert.Equal(t, exitcodes.Success, exitCode)
|
||||
assert.Equal(t, "Congrats! No issues were found.\n", out)
|
||||
assert.Equal(t, noIssuesOut, out)
|
||||
}
|
||||
|
||||
func TestCongratsMessageGoneIfSilent(t *testing.T) {
|
||||
|
@ -40,7 +43,7 @@ func TestCongratsMessageGoneIfSilent(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCongratsMessageIfNoIssues(t *testing.T) {
|
||||
out, exitCode := runGolangciLint(t, "../...")
|
||||
out, exitCode := runGolangciLint(t, root)
|
||||
checkNoIssuesRun(t, out, exitCode)
|
||||
}
|
||||
|
||||
|
@ -66,7 +69,7 @@ func TestRunOnAbsPath(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDeadline(t *testing.T) {
|
||||
out, exitCode := runGolangciLint(t, "--deadline=1ms", filepath.Join("..", "..."))
|
||||
out, exitCode := runGolangciLint(t, "--deadline=1ms", root)
|
||||
assert.Equal(t, exitcodes.Timeout, exitCode)
|
||||
assert.Contains(t, out, "deadline exceeded: try increase it by passing --deadline option")
|
||||
assert.NotContains(t, out, "Congrats! No issues were found.")
|
||||
|
@ -343,6 +346,15 @@ func TestEnabledLinters(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestGovetInFastMode(t *testing.T) {
|
||||
cfg := `
|
||||
linters-settings:
|
||||
use-installed-packages: true
|
||||
`
|
||||
out := runGolangciLintWithYamlConfig(t, cfg, "--fast", "-Egovet", root)
|
||||
assert.Equal(t, noIssuesOut, out)
|
||||
}
|
||||
|
||||
func TestEnabledPresetsAreNotDuplicated(t *testing.T) {
|
||||
out, ec := runGolangciLint(t, "--no-config", "-v", "-p", "style,bugs")
|
||||
assert.Equal(t, exitcodes.Success, ec)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue