67 Commits

Author SHA1 Message Date
Gianguido Sorà
72e137e344 Added "bodyclose" support
This commit adds full support for bodyclose linter
(https://github.com/timakin/bodyclose), which checks if an `http.Body`
element is correctly closed after usage.

Since it can be used via `go/analysis', I followed the `govet' example
as suggested by https://github.com/golangci/golangci-lint/wiki/How-to-add-a-custom-linter.

This commit is fully tested, and contains a (flawed) test program which
calls `http.Get()' on `https://google.com' and does not closes its
corresponding `http.Body'.
2019-06-09 13:04:30 +03:00
Denis Isaev
39f46be460 Fix staticcheck panic on packages that do not compile
The bug was introduced in golangci-lint when migrating staticcheck to go/packages.
Also, thanks to pkg.IllTyped we can analyze as max as we can by
staticcheck.

Relates: #418, #369, #429, #489
2019-04-21 11:48:33 +03:00
Denis Isaev
ed0b551070 Fix linting of preprocessed files
Preprocessed files like .qtpl.go quicktemplate Go files can have
//line directives. They map to a source .qtpl file.
This commit fixes linting of such files:
1. don't fail on AST cache loading
2. output Go filename not .qtpl or similar

Also, here we update golint to the upstream version.

Relates: #316, #466, #467, #468
2019-04-20 21:50:26 +03:00
John.Koepi
de1d1ad903 make use of LoadAllSyntax compatible with the latest x/tools version 2019-04-02 09:56:13 +03:00
Denis Isaev
f516771a92 Fix #415: sort linters list in help commands 2019-03-18 08:46:13 +03:00
Denis Isaev
8c1237b667 Use the newest go vet
The newest go vet based on go/analysis
2019-03-17 23:12:44 +03:00
Denis Isaev
3d2dfac47e Support excluding issues by source line regexp
See issues.exclude-rules[i].source.
Also introduced file data and file lines cache.
2019-03-17 15:17:29 +03:00
Trevor Pounds
7514bf8239 Fix AST cache key consistency.
Ensures the AST cache always consistently loads/stores
by using the normalized file path as the key.
2019-03-05 21:59:44 +03:00
Denis Isaev
96af958205 fix #383: eval symlinks in AST cache 2019-02-18 00:21:49 +03:00
Denis Isaev
d437ac8629 Implement auto-fixing for gofmt,goimports,misspell
Also, add more identifier marking patterns.
2019-02-17 20:31:31 +03:00
Aleksandr Razumov
a3a04552bb add support for exclude rules 2019-02-17 18:40:22 +03:00
Denis Isaev
f6ce931fcf fix #355: don't merge megacheck on linters cmd 2019-01-20 22:52:36 +03:00
Denis Isaev
7705f82591 Update megacheck to the latest version
Also do following improvements:
  - show proper sublinter name for megacheck sublinters
  - refactor and make more simple and robust megacheck
  merging/optimizing
  - improve handling of unknown linter names in //nolint directives
  - minimize diff of our megacheck version from the upstream,
  https://github.com/golang/go/issues/29612 blocks usage of the upstream
  version
  - support the new `stylecheck` linter
  - improve tests coverage for megacheck and nolint related cases
  - update and use upstream versions of unparam and interfacer instead of forked
  ones
  - don't use golangci/tools repo anymore
  - fix newly found issues after updating linters

Also should be noted that megacheck works much faster and consumes less
memory in the newest release, therefore golangci-lint works noticeably
faster and consumes less memory for large repos.

Relates: #314
2019-01-08 21:16:15 +03:00
David López
d9a1bdb831 gocritic: fix code to pass newly added gocritic checks
Fix code to pass newly added gocritic checks, mainly pointer receivers and import shadows
2019-01-08 09:59:24 +03:00
David Golub
7063a9d870 Fix errors when specifying absolute path 2018-12-22 13:44:30 +03:00
Denis Isaev
09c65fcf42 rework modules download mode option 2018-12-22 13:37:17 +03:00
Nicolae Vartolomei
b693037af0 Allow configure module download mode 2018-12-22 13:37:17 +03:00
Denis Isaev
7dfb9cff3d rework skip dir algorithm 2018-12-22 12:24:43 +03:00
Denis Isaev
255a39bcb1 fix #302: fix concurrent astcache access 2018-11-24 09:09:31 +03:00
Denis Isaev
dba3907ff3 improve typecheck errors parsing 2018-11-23 18:40:25 +03:00
Denis Isaev
898ae4d364 fix #277, fix #260: fix crash
Fix crash because of parallel access to ssa.Program
2018-11-10 16:20:49 +03:00
Denis Isaev
952cc0b22e
fix hangup of golangci-lint on large projects with compilation errors 2018-11-10 14:32:26 +03:00
Denis Isaev
7d51954355 fix #199: support gochecknoinits, gochecknoglobals
Add 2 new linters
2018-11-07 10:47:08 +03:00
Denis Isaev
a57bc83d70 On of cases for #260: fix crash in staticcheck
1. Fix crash if deps of analyzed packages weren't compiled.
2. Print deps typechecking errors
3. Fix all issues filtering because of empty go env GOCACHE for go < 1.10
2018-11-07 10:06:55 +03:00
Denis Isaev
0935ce1b8d fix #132: support go-critic linter 2018-11-07 09:11:08 +03:00
Denis Isaev
84c9c65f39 fix #243: support Scopelint linter 2018-11-06 08:11:25 +03:00
Denis Isaev
ccac35a87e Fix false positives with unused identifiers
Issue #265: don't report unused warning when an identifier is
used only in tests.
2018-11-05 14:11:14 +03:00
Denis Isaev
a4d7d7a428
logging for corrupted SSA packages 2018-11-04 13:57:50 +03:00
Pavel Berezhnoy
f5f7701650 Fix #261: build-tags fix for package loader 2018-10-29 14:33:44 +03:00
Denis Isaev
8fceb7fc47
Fix #209: support goimports.local-prefix option for goimports 2018-10-28 18:47:56 +03:00
Denis Isaev
0421bac259 Fix #237, fix #178: use go/packages
Use go/packages instead of x/tools/loader: it allows to work
with go modules and speedups loading of packages with the help
of build cache.

A lot of linters became "fast": they are enabled by --fast now and
work in 1-2 seconds. Only unparam, interfacer and megacheck
are "slow" linters now.

Average project is analyzed 20-40% faster than before if all linters are
enabled! If we enable all linters except unparam, interfacer and
megacheck analysis is 10-20x faster!
2018-10-28 17:55:15 +03:00
Peter Schuller
a84578d603 Tweak log entry for "not compiling" packages.
Motivation: Make it clear that the message is indicating packages
*which do not compile*, rather than packages which *won't be
compiled [for some unknown reason]*.
2018-10-28 16:54:37 +03:00
Cezar Sa Espinola
b307cc3765 Fix formatting with updated goimports version 2018-10-20 10:40:40 +03:00
Denis Isaev
0ef36f43d5 Prepare for #205: use forked repos without aliases 2018-09-02 14:46:54 +03:00
Denis Isaev
8a478c47ac Prepare for #164: rename GAS to gosec
1. Rename in a backward compatible way
2. Remove gosec default exclude list because gosec is already disabled
by default.
3. Warn about unmatched linter names in //nolint directives
4. Process linter names in //nolint directives in upper case
5. Disable gosec for golangci-lint in .golangci.yml
2018-09-02 09:34:35 +03:00
Denis Isaev
47440bc2cc don't print config parsing info logs twice 2018-09-02 09:34:35 +03:00
Denis Isaev
a24cc87a06 refactor lintersdb: split it into abstractions 2018-09-02 09:34:35 +03:00
Denis Isaev
e58c27e463 move source code lines extraction to processor and store source lines in output json 2018-08-18 17:27:45 +03:00
Denis Isaev
2db694a3ff exit with the code 5 if no go files to analyze 2018-08-17 21:20:54 +03:00
Denis Isaev
a2b901227c Close #196: disable GAS (gosec) by default 2018-08-12 22:27:04 +03:00
Denis Isaev
9ec959f08e
Close #187: disable typecheck for golangci.com by default 2018-08-08 23:33:45 +03:00
Denis Isaev
b1948fdbaa
remove GOLANGCI_COM_RUN: make runs in golangci.com and local runs identical 2018-07-29 23:52:10 +03:00
Denis Isaev
973c9fdfd8 Fix #126: fix working with symlinks 2018-07-29 22:45:35 +03:00
Denis Isaev
ca558ca571 Closes #154: set typecheker sizes as types.SizesFor(build.Default.Compiler, build.Default.GOARCH) 2018-07-29 22:30:55 +03:00
Denis Isaev
d02ac2466e disable go1.11 in travis and make some small fixes for go1.11 2018-07-29 13:00:41 +03:00
Denis Isaev
c5721f50d0 update Gopkg.lock for a newer dep format and update x/tools package 2018-07-28 23:47:22 +03:00
Denis Isaev
5d04557a1f #156, #157: properly detect type errors in dependencies 2018-07-28 23:47:22 +03:00
Denis Isaev
1774bf22a2 Fix #148: fix false-positive from unused if cgo is used 2018-07-01 21:52:21 +03:00
Denis Isaev
894ba0df9f Resolve #146: prealloc linter support 2018-06-30 22:07:12 +03:00
Denis Isaev
facc3a096a Fix #98: nakedret linter support 2018-06-30 15:41:47 +03:00