369 Commits

Author SHA1 Message Date
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
Maciej "Iwan" Iwanowski
d7772f542b
Using ExcludeRulesProcessor
Signed-off-by: Maciej "Iwan" Iwanowski <maciej.iwanowski@critical.today>
2020-04-23 09:27:48 +02:00
Maciej "Iwan" Iwanowski
05138497f2
Adding case sensitive exclude rules support
Signed-off-by: Maciej "Iwan" Iwanowski <maciej.iwanowski@critical.today>
2020-04-23 09:23:37 +02:00
Aleksandr Razumov
d00692c355
Merge branch 'nestif' of https://github.com/nakabonne/golangci-lint into nakabonne-nestif 2020-04-23 00:31:25 +03:00
Aleksandr Razumov
48361b9978
Merge pull request #852 from maratori/add-testpackage
Add linter testpackage
2020-04-23 00:17:33 +03:00
Aleksandr Razumov
aed4806aae
Merge pull request #1029 from kaka19ace/master
feat: [gocritic] support disabled-tags
2020-04-23 00:15:06 +03:00
tdakkota
92aa97e55e feat: add asciicheck linter support 2020-04-22 19:55:05 +03:00
Maciej "Iwan" Iwanowski
a68b411e4a
Adding case-sensitive exclude processor
Signed-off-by: Maciej "Iwan" Iwanowski <maciej.iwanowski@critical.today>
2020-04-22 18:40:10 +02:00
Marat Reymers
9914737fc3 Add linter testpackage 2020-04-22 18:57:30 +03:00
kaka_ace
00cc2336c7 feat: [gocritic] support disabled-tags 2020-04-22 12:11:56 +08:00
Ryan Currah
990b43f19a
Merge remote-tracking branch 'golangci/master' into add-gomodguard-linter 2020-04-21 20:17:09 -04:00
nakabonne
9442a4132c Use sort.SliceStable instead of sort.Slice 2020-04-22 08:53:50 +09:00
nakabonne
0108387c24 Add nestif linter 2020-04-22 08:51:43 +09:00
Aleksandr Razumov
3fd6db779e
Merge pull request #1017 from viktorasm/add-github-output-format
Adding github actions output format
2020-04-22 02:04:11 +03:00
Ryan Currah
6bb04d5ac0
use correct url, update gomodguard 2020-04-10 18:39:44 -04:00
Viktoras Makauskas
b7dada2249 slight cleanup 2020-04-11 00:41:24 +03:00
Viktoras
69a4e811d7
Update pkg/printers/github.go
Co-Authored-By: Bot from GolangCI <42910462+golangcibot@users.noreply.github.com>
2020-04-11 00:12:29 +03:00
Viktoras Makauskas
276e0d1e3b Fixing linter issues 2020-04-11 00:11:37 +03:00
Viktoras
da4a14d827
Update pkg/printers/github.go
Co-Authored-By: Bot from GolangCI <42910462+golangcibot@users.noreply.github.com>
2020-04-11 00:02:35 +03:00
Viktoras Makauskas
ee2c62132c Fixing linter issues 2020-04-10 23:59:07 +03:00
Viktoras Makauskas
d7222c7d38 Adding github actions output format 2020-04-10 23:46:19 +03:00