389 Commits

Author SHA1 Message Date
Grigory Zubankov
6b60cb8a30
new nlreturn linter (#1267)
* new nlreturn linter

* fix: import order

Co-authored-by: Sergey Vilgelm <sergey.vilgelm@ibm.com>
2020-08-02 15:16:45 -05:00
Sergey Vilgelm
3aa04f5b62
Add WithAutofix flag for gofumpt linter config (#1281) 2020-08-02 15:09:50 -05:00
Xiang Dai
d38d047528
Gci: support auto fix (#1277)
Signed-off-by: Xiang Dai <long0dai@foxmail.com>
2020-07-31 08:39:08 +08:00
Xiang Dai
60613dc3eb
Introduce gci as new linter (#1266)
* Introduce gci as new linter

Signed-off-by: Xiang Dai <long0dai@foxmail.com>

* use goimports setting if not specified

Signed-off-by: Xiang Dai <long0dai@foxmail.com>
2020-07-28 13:55:02 +03:00
Sergey Vilgelm
c8bd9549a5
Support --fix for gofumpt (#1239) 2020-07-18 21:33:47 -05:00
Denis Tingaikin
21ee78cf62
Improve 'no such linter' error message (#1244) 2020-07-17 06:48:05 +00:00
Oleg Butuzov
6e7c317610
Sorting result.Issues implementation (golangci/golangci-lint#1217) (#1218) 2020-07-12 16:35:08 -05:00
dependabot-preview[bot]
65e1b30ebd
build(deps): bump github.com/kyoh86/exportloopref from 0.1.4 to 0.1.7 (#1214)
* build(deps): bump github.com/kyoh86/exportloopref from 0.1.4 to 0.1.7

Bumps [github.com/kyoh86/exportloopref](https://github.com/kyoh86/exportloopref) from 0.1.4 to 0.1.7.
- [Release notes](https://github.com/kyoh86/exportloopref/releases)
- [Changelog](https://github.com/kyoh86/exportloopref/blob/master/.goreleaser.yml)
- [Commits](https://github.com/kyoh86/exportloopref/compare/v0.1.4...v0.1.7)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Fix exportloopref linter

Change the WithLoadMode to use LoadModeTypesInfo isntead of LoadModeSyntax

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Sergey Vilgelm <sergey.vilgelm@ibm.com>
2020-07-12 21:41:06 +02:00
Melvin
ee86e0e893
gofumpt: Add extra-rules option + update linter (#1228)
Co-authored-by: Sergey Vilgelm <sergey.vilgelm@ibm.com>
2020-07-12 11:38:07 -05:00
Joe Wilner
6550984878
Configure path prefix via processor abstraction (#1226) 2020-07-11 09:14:52 +10:00
sonata
b98fda6f34
Enable linters for golangci-lint (#1221)
* Enable linters for golangci-lint

* Remove unused nolint

* Fix lint
2020-07-10 10:50:06 +09:00
Denis Tingaikin
dfa0013583
Fix: goheader linter can throw nil pointer exception in case of a source file has not issues (#1209)
* fix potential nil pointer exception

Signed-off-by: denis-tingajkin <denis.tingajkin@xored.com>

* add test to cover

Signed-off-by: denis-tingajkin <denis.tingajkin@xored.com>
2020-07-05 15:32:00 +07:00
iwankgb
306cbb0e6e
Upgrading to go-critic v0.5.0 (#1205)
Some checks failed
CI / golangci-lint (push) Failing after 3m54s
CI / tests-on-windows (push) Has been skipped
CI / tests-on-unix (1.13, ubuntu-latest) (push) Has been skipped
CI / tests-on-unix (1.14, ubuntu-latest) (push) Has been skipped
CI / check_generated (push) Has been skipped
Release a tag / release (push) Failing after 4m22s
2020-07-04 20:07:26 +00:00
Denis Tingaikin
01b566a646
Add go-header linter (#1181)
* add go-header linter
* apply review comments: add goheader example into .golangci.example.yml
* apply review comments: correctly handle multiline comments
2020-07-04 19:03:37 +00:00
Ryan Olds
b22e3f1874
Added sqlclosecheck to linters (#1203)
* Added sqlclosecheck to linters
* Addressed feedback
* Updated sqlclosecheck and tools
2020-07-04 14:30:16 +00:00
Duco van Amstel
5f0de2982b
Protect NewFilenameUnadjuster from concurrent map writes (#1192) 2020-06-25 14:57:49 +02:00
Teiva Harsanyi
38d298c2c8
Adding gofumpt (#1177) 2020-06-16 13:05:28 +03:00
sonata
f1a46f9861
Add Noctx (#1179)
Support for linter that enforces using context on each `http.Request`
https://github.com/sonatard/noctx
2020-06-08 20:21:58 +00:00
Nishanth Shanmugham
f3376cab71
add exhaustive linter (#1166)
* wip

more

add new files

run command fixes

more

* go.mod

* order

* same package

* review comment

* enable linter in .golangci.yml

* add testcase for default-signifies-exhaustive: true

* adjust runGoErrchk instead

* disable the linter

* cleanup

* more cleanup

* cleanup
2020-05-29 16:31:46 +03:00
Soichiro Kashima
71b2f04e88
handle some block comment to detect generated files (#1161) 2020-05-25 19:36:46 +03:00
Ryan Currah
fa7adcbda9
add ability to set issue severity (#1155)
* add ability to set issue severity for out formats that support it based on severity rules

* fix lint issues

* change log child name

* code climate omit severity if empty

* add tests for severity rules, add support for case sensitive rules, fix lint issues, better doc comments, share processor test

* deduplicated rule logic into a base rule that can be used by multiple rule types, moved severity config to it's own parent key named severity, reduced size of NewRunner function to make it easier to read

* put validate function under base rule struct

* better validation error wording

* add Fingerprint and Description methods to Issue struct, made codeclimate reporter easier to read, checkstyle output is now pretty printed
2020-05-25 08:21:42 -04:00
Tam Mach
dc260be693
Add exportloopref linter (#1163) 2020-05-24 10:31:32 +03:00
Andrew Shannon Brown
90a8cd41bd
Fix up nolintlint comments and urls (#1164) 2020-05-24 10:08:14 +03:00
Isaev Denis
3c46e160de
fix invalid error message "no go files to analyze" (#1154)
In case of timeouts of go/packages loading
we could return such error.

Relates: #825
2020-05-19 09:55:25 +03:00
Denis Krivak
7c2871c596
godot: add autofix mode 2020-05-18 15:49:58 +03:00
Ryan Currah
778e08fda4
bump gomodguard version (#1140)
* bump gomodguard version which adds a new feature to allow blocking modules based on version constraints

* add description why you may want to use gomodguard over depguard, updated example config and add a section the contributor doc page to remind people to update the example config
2020-05-17 22:35:13 +03:00
Isaev Denis
6b124f1a0e
fix goerr13 dependencies (#1089) 2020-05-13 21:22:52 +03:00
Denis Krivak
d7648bf202 godot: fix issue with --fix flag 2020-05-13 11:39:08 +03:00
☃ Elliot Shepherd
c88df8f473
Fix nil pointer in codeclimate.go (#1077)
Some issues don't have any source lines
2020-05-11 22:10:39 +03:00
Collin Kreklow
3c2aa58dc5
Add *println to exception EXC0001 (#1074)
Exception EXC0001 ignores errors on functions like Sprint and Sprintf,
but not Sprintln. Update the exception to include *println as well.
2020-05-09 15:18:17 +03:00
Isaev Denis
cb58d1f82e
speed up CI and golangci-lint (#1070)
Run CI on mac os only with go1.13 and on windows only on go1.14.
Speed up tests. Introduce --allow-parallel-runners.
Block on parallel run lock 5s instead of 60s.
Don't invalidate analysis cache for minor config changes.
2020-05-09 15:15:34 +03:00
ced42
7526c8d347
Add tests, failures and errors attributes on testsuites (#1072) 2020-05-07 17:05:10 +03:00
Soichiro Kashima
7f48cc88b8
Fix lint errors on files with //line directive (#1065)
If the target files contains `//line` directive and it indicates
a non-go file, the linter is going to handle it as a go file,
which results in failure.
The cause of this issue is that the linters (`Analyzer`s) are using
`pass.Fset.Position()`. This func returns the adjusted position using
`//line` directive.
The example project reported in #998 has `//line` directive that
indicates other non-go file.
According to the description of "Compiler Directives”
(https://golang.org/cmd/compile/#hdr-Compiler_Directives),
line directives is mainly used for reporting original positions to
the generators or something.
On linters of golangci-lint, `pass.Fset.Position()` is used just to
aggregate file names; we don't have to adjust positions.
This changes `Analyzer`s that use `pass.Fset.Position()` to aggregate
file names to use `pass.Fset.PositionFor()` with `adjusted == false`.

Relates: #998
2020-05-05 18:49:34 +03:00
Isaev Denis
279b6d62d3
speed up a bit (#1064)
Ensure that `unused` is always the last
in execution order. It can speed up packages loading
a bit.

Refactor enabled linters set to remove extra logging.

Relates: #944
2020-05-05 18:45:19 +03:00
Isaev Denis
38782dd097
dev: use golangci-lint action (#1066) 2020-05-05 17:51:55 +03:00
Isaev Denis
52c9b88c25
reduce mem. usage of unused and update staticcheck (#1063)
The primary improvement is in early clearing of
analyzed package's TypeInfo, facts, etc for
whole program analyzers (`unused`). Clear it when it
becomes unused and GC collects them early. Initially this
clearing was performed for all analyzers except `unused`.

Update staticcheck from v0.0.1-2019.2.3 to v0.0.1-2020.1.4

Also in this commit:
  * speed up loading packages from export data (2.5s -> 2.1s for std)
    by not using mutex for export data since it was allowed in
    x/tools#07722704da13
  * make an order of execution of linters stable
  * update renameio and robustio
  * use robustio in caching

Relates: #987, #994, #995, #1011
2020-05-03 15:20:17 +03:00
Tim Heckman
60fd647987
Update gosec linter to v2; add .test files to .gitignore (#1062)
This change updates the `gosec` linter to its v2 version. It seems like v2
maintained API compatibility for the functionality we use, so we only needed to
update the dependency and imports.

Please note, this does not use a tagged version of `gosec` and instead is the
latest `master` commit due to this issue: https://github.com/securego/gosec/issues/470.
Once this issue is resolved we should update `gosec` to a tagged release.

This also adds a line to the `.gitignore` file, to ignore the `.test` output
files that get generated by `go test`. This could accidentally get left behind,
so no use committing binary files.

Fixes #1052
2020-05-03 14:05:00 +03:00
Andrew Shannon Brown
ef44e11e17
Merge branch 'master' into asb/nolintlint-internal 2020-04-29 15:27:35 -07:00
tdakkota
0d95fafefc feat: add go-err113 linter support 2020-04-27 21:37:34 +03:00
Aleksandr Razumov
56f2b7d59d
fixer: add warning about possible line range issue 2020-04-27 20:11:42 +03:00
Aleksandr Razumov
3deb9d80ab
unused: check line range before suggesting fix
Fix #1048
2020-04-27 19:59:38 +03:00
Aleksandr Razumov
397a6a6732
Merge branch 'upgrade-gosec' of https://github.com/rung/golangci-lint into rung-upgrade-gosec 2020-04-27 13:07:03 +03:00
Andrew Shannon Brown
909f628d75 Add linter for nolint
Linter can check that nolint statements are properly formatted and also that all
nolint statements are used.
2020-04-26 20:20:17 -07:00
John Starich
36d8d881f9 Preserve API backward compatibility 2020-04-25 14:14:42 -05:00
John Starich
c55e7614d4 Re-enable default excludes by ID 2020-04-25 13:57:57 -05:00
Aleksandr Razumov
1373897abf
Merge branch 'tdakkota-feature/add-asciicheck-support' 2020-04-25 17:51:53 +03:00
Aleksandr Razumov
e2b927f029
Merge pull request #1036 from iwankgb/exclude-case-sensitive
Adding case-sensitive exclude processor
2020-04-24 12:48:42 +03:00
Maciej "Iwan" Iwanowski
078f44f8aa Getting rid of code duplication
Signed-off-by: Maciej "Iwan" Iwanowski <maciej.iwanowski@critical.today>
2020-04-23 18:37:40 +02:00
Maciej "Iwan" Iwanowski
794a464435
Improving flag help message
Signed-off-by: Maciej "Iwan" Iwanowski <maciej.iwanowski@critical.today>
2020-04-23 09:36:25 +02:00
Maciej "Iwan" Iwanowski
94f8d6aacb
Ensuring interface implementation
Signed-off-by: Maciej "Iwan" Iwanowski <maciej.iwanowski@critical.today>
2020-04-23 09:32:55 +02:00