55 Commits

Author SHA1 Message Date
Trevor Pounds
2e8d83266f Update dependencies. (#684)
* Update deps.

* Update to Node.js v10.16.3 LTS.

* Fix mock logutils generation.
2019-09-12 16:02:43 +03:00
Isaev Denis
bf67a3eef3
update gosec (#681) 2019-09-11 17:46:26 +03:00
Isaev Denis
94eaa8f196
update go-critic (#679)
Go-critic got a new checker `regexpPattern`.
2019-09-11 16:56:33 +03:00
Matouš Dzivjak
58845813da linters: add Godox linter support (#621)
Godox is linter for TODOs and FIXMEs left in the code.

Signed-off-by: Matous Dzivjak <matous.dzivjak@kiwi.com>
2019-09-11 16:53:40 +03:00
NiseVoid
c7dee2c0b2 Add whitespace linter (#673) 2019-09-10 13:25:01 +03:00
Denis Isaev
e691e606b1
dev: fix updated golangci/tools revision 2019-09-10 10:59:34 +03:00
Isaev Denis
6163a8a790
Support go1.13 (#670)
Setup Travis CI to run on go 1.12 and 1.13.
Update info about go versions in README.
Rebuild go.mod,go.sum on go1.13.
2019-09-09 21:54:56 +03:00
Pierre Durand
cdeefb5f79 fix invalid dependencies (#605)
Some dependencies have invalid date.

Fixes #581 #595
2019-09-09 17:22:40 +03:00
NiseVoid
bb82273160 Add funlen linter (#603) 2019-09-09 16:56:30 +03:00
Isaev Denis
136b27171a
update bodyclose: use upstream version (#666) 2019-09-09 16:35:16 +03:00
Luke Shumaker
e87a1cfb83 Fix a false-positive from 'unused' (#585)
This false-positive is not present in the upstream stand-alone 'unused'
2019.1.1 program that golangci-lint uses.

pkg/lint.ContextLoader.filterPackages() did two things:
 1. It removed synthetic "testmain" packages (packages with .Name=="main"
    and .PkgPath ending with ".test")
 2. It removed pruned subsumed copies of packages; if a package with files
    "a.go" and "a_test.go", it results in packages.Load giving us two
    packages:
      - ID=".../a" GoFiles=[a.go]
      - ID=".../a [.../a.test]" GoFiles=[a.go a_test.go]
    The first package is subsumed in the second, and leaving it around
    results in duplicated work, and confuses the 'deadcode' linter.

However, the 'unused' linter relies on both the ".../a" and
".../a [.../a.test]" packages being present.  Pruning them causes it to
panic in some situations, which lead to this workaround:
af6baa5dc1

While that workaround got it to not panic, it causes incorrect results.

So, split filterPackages() in to two functions: filterTestMainPackages()
and filterDuplicatePackages().  The linter.Context.Packages list only
gets filterTestMainPackages() called on it, while linter.Context.Program
and linter.Context.SSAProgram get both filters applied.

With the source of the panic fixed, roll back a few now-unnecessary
commits in go-tools.
2019-09-09 16:10:49 +03:00
Denis Isaev
e39e8fb5d5 update x/tools
Significantly improve CPU and memory usage when not using SSA-powered linters.
Improve readability of go/packages errors.
Improve debugging capabilities and write doc about debugging.
2019-09-09 15:04:32 +03:00
Denis Isaev
d2b1eea2c6
bodyclose: fix race condition 2019-07-14 17:53:55 +03:00
Fernandez Ludovic
7e170af626 fix: body close panic. 2019-07-14 17:15:54 +03:00
Hernan Bandura
f8a5a8cb01 Update depguard version to 1.0.0 (Performance improvements) 2019-06-29 23:53:05 +03:00
Trevor Pounds
22d1ef65c8 Update pkg/errors to v0.8.1. 2019-06-18 22:24:38 +03:00
Denis Isaev
7274db714c fix #479: update go-critic to fix deps
This update should fix go get issues because of deps.

go-critic:
$ git cherry -v c3db6069acc5
+ fe28ac328f474c02e2383ca2bf44a606929a7048 checkers: add integration
tests with cgo for dupImports (#846)
+ 48a15b03b630252319474ba5ddc8455d2aebf34f checkers: fix fold-ranges
for floats in boolExprSimplify (#849)
+ 7bf73388643eb226addf2d5ed8a2c104be244b2e checkers: fix "Output:"
false positive in commentedOutCode (#852)
+ f6f702b31734df26415c2bd135f272d1a34d2973 checkers: extend
yodaStyleExpr supported ops list (#856)
+ 07bf84df361735ad1d90f84e79eb60c8386325c7 fix dependencies (#857)
+ 1df30086654074503eab008bdde4f3ce1921128d checkers: fix collection
URL (#860)

x/tools:
$ git cherry -v 685fecacd0a0 521d6ed310dd | fgrep -v internal/lsp
+ fe54fb35175bb1c0c175e2335e23d7fa90ca987a apidiff: represent a Report as a list of Changes
+ 15bbd99efc6f20619676dec93f914d12e5139e83 all: run go mod tidy
+ bb3b3ca95aec36bfc4a5cb10b58022e64aca735b go/packages: add some documentation for extractPackage
+ 4bf14f7f0668366a4275c6ef5e99bd8e807da1d3 internal/span: fix off-by-one in ToUTF16Column
+ cb2dda6eabdf9160e66ca7293897f984154a7f8b go/packages: deduplicate file parsing
+ 9e44c1c403071e0c2831952513e7b948587d94af go/internal/gccgoimporter: update package to match std lib version
+ 36563e24a2627da92566d43aa1c7a2dd895fc60d cmd/vet: verify potentially-recursive Stringers are actually Stringers
+ 31fd60d6bfdcfb2861856aa5b333bb135f6bbfd8 x/tools/go/packages/packagestest: fix GOPROXY file URLs for Windows
+ 2d660fb8a000e1c288dc2f2150401b364922ebe9 go/packages/packagestest: fix GOPROXY file URLs for Windows
+ 7af746645d5165109de0b5cb499980c22812dfc2 internal/span: fix another off-by-one in ToUTF16Column
+ 9d4d845e86f14303813298ede731a971dd65b593 cmd/goimports: add -format-only flag
+ 83df196e5764ed2415c28c1f39ba6cb3db747da0 internal/span: add a filename only print for spans
+ 5cec639030af3a6ada2732d9bfa1d3731ed55106 go/analysis: proposed fact enumeration API
+ 9cb3dcf692a103de0fd68c26f4f04183e0933f7c internal/span: update the offset if the end offset should be valid but is not
+ 2d16b83fe98cd1bed9e2ce9fdc86bd438d14aab7 go/vcs: ignore "mod" VCS type
+ 95299016986435f846545c27f956768ad3c3cb2f lostcancel: do not analyze cancel variable which defined outside current function scope
+ 8a42e17289ea392d63892321ce1f40bd07efcc9f compilebench: clean up different benchmark types
+ eeb76a0c47a3b97e99f330dc14174ef14777d2ba compilebench: factor running build tool commands
+ 60140f09094406e46618ef436a26dd8394983503 compilebench: add a linker benchmark
+ e31d36578abb3d202c4007c3747bf8ebb7c51011 compilebench: handle missing MemStats more gracefully
+ d996b19ee77cd9c8df974510f23b0696cedf1ca1 go/analysis/analysistest: fix word usage
+ 73554e0f78058c37e5421bc48273a72400172221 go/analysis/passes: fix bugs discovered in std
+ 35884eef200b5fc81c9044f644a8d9d911262488 cmd/vet: print help to stdout only
+ 45e43b2cb4facd370abb846ebf35575161849f3b go/packages/packagestest: fix MustCopyFileTree so that file fragments are always slash form
+ d81a07b7e58487eed036bf115fa834653590d6cd go/analysis/passes/bools: eliminate quadratic runtime, output
+ 2a413a02cc735933997fa1b467a7b27bc1b82567 godoc/static: let client use vet check returned by /compile endpoint
+ 4789ca9922f080dd3a8fc3c74df1c1306db2bb0b go/analysis/internal/analysisflags: call gob.Register on deleted analyzers
+ d1a3278ee74994e9aa609e9e711c616bba677d5d godoc/util: serve SVG files raw
+ 1da8801a9502f29f3f03edfc3149b947e6e1913c godoc: declare small victory over the punched card tyranny
+ 757ca719ca9689950c69081c10c5300fbb8e35db imports: rename to internal/imports
+ 0133cac3176f225883c5d817146de8633ed07ebc cmd/goimports: reuse cached state
+ 26647e34d3c04fd3eaef6fb824493b00af7b1b26 imports: allow nil Options in Process
2019-06-10 11:33:31 +03:00
Denis Isaev
b0281e853e update ineffassign 2019-06-10 09:23:57 +03:00
Isaev Denis
66d4a16c6a
Merge branch 'master' into lukeshu/reproduce 2019-06-09 13:18:41 +03:00
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
Luke Shumaker
d7a38bbdf2 go.mod: Roll back to golang/mock 1.0.0 2019-06-05 00:58:57 -04:00
Luke Shumaker
9ce337296b Makefile: Set GO111MODULE=on for consistency, adjust tests accordingly 2019-06-05 00:52:23 -04:00
Denis Isaev
692dacb773 Update go-critic
New checkers were added:
  - badCall
  - dupImports
  - evalOrder
  - newDeref

The following checkers were fixed/improved:
  - assignOp
  - caseOrder
  - commentedOutCode
  - deprecatedComment
  - dupArg
  - rangeValCopy
  - typeSwitchVar
  - wrapperFunc

Relates: #429
2019-04-25 16:59:23 +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
Linus Arver
127f89f072 update golang.org/x/tools
This brings in the upstream fix
1aadbdfdbb. (Upstream
issue is https://github.com/golang/go/issues/31163).

To create this commit, I did:

  vgo get golang.org/x/tools
  make update_deps
  cd cmd/golangci-lint
  go install -ldflags "-X 'main.version=$(git describe --tags)' -X 'main.commit=$(git rev-parse --short HEAD)' -X 'main.date=$(date)'"

Fixes #500
2019-04-20 13:20:13 +03:00
Aofei Sheng
cc84f896b6 Correct import path of module sourcegraph/go-diff 2019-04-20 13:12:28 +03:00
Denis Isaev
2c69ef2eb0 Update megacheck (staticcheck) to 2019.1.1
Relates to #418
2019-03-31 19:41:37 +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
Vitaly Isaev
0fdd91dc3d Update golang.org/x/tools package to fix false IllTyped error 2019-03-17 15:29:58 +03:00
Denis Isaev
b607ea387e #392: run GO111MODULE=on go mod vendor after go-diff update 2019-02-17 18:27:59 +03:00
Chris Drew
08574bf08b Update sourcegraph go-diff
Fixes #307.
2019-02-17 18:23:26 +03:00
Denis Isaev
183765e6d4
update gosec
$ git cherry --abbrev -v 8afd9cbb6cfb 66fb7fc33547
+ 63b25c1 Fix typo in README (#235)
+ 419c929 G107 - SSRF (#236)
+ 145f1a0 Removed wrapping feature (#238)
+ ec32ce6 Support Go 1.11 (#239)
+ 762ff3a Allow quoted strings to be used to format SQL queries (#240)
+ 7f6509a Update README.md (#246)
+ 5f98926 Refactor Dockerfile (#245)
+ d3f1980 Fix false positives for SQL string concatenation with constants from another file (#247)
+ 64d58c2 Refactor the test code sample to support multiple files per sample
+ 1ecd47e bump Dockerfile golang from 1.10 to 1.11
+ 027dc2b This fixes the html template when using '-fmt=html'  - resolves HTML escaping issues within the template  - resolves reference issues to reportInfo struct i.e. issues -> Issues, metrics -> Stats
+ 8c09a83 Add install.sh script
+ 97bc137 Add CI Installation steps and correct markdown lint errors
+ 3116b07 Fix typos in comments and rulelist (#256)
+ 443f84f Fix golint link (#263)
+ 4180994 Make G201 ignore CallExpr with no args (#262)
+ 9b966a4 add test case for strings.Builder G104 whitelist inclusion
+ adb4222 whitelist strings.Builder method in rule G104
+ ae82798 Fix the WriteSring test by handling the error
+ 2695567 Build the code sample for string builder only fron Go 1.10 onwards
+ f14f17f Add a helper function which extracts the string parameters values of a call expression
+ 9b32fca Fix the bind rule to handle the case when the arguments of the net.Listen are returned by a function call
+ 24e3094 Extend the bind rule to handle the case when the net.Listen address in provided from a const
+ 72e95e8 Geneate and upload the test coverage report to codecove.io
+ 12400f9 Update README with the code coverage batch
+ 14ed63d Do not flag the unhandled errors which are explicitly ignored
+ f87af5f Detect the unhandled errors even though they are explicitly ignored if the 'audit: enabled' setting is defined in the global configuration (#274)
+ 5d33e6e Update the README with some details about the configuration file
+ b662615 Fix typo
+ a966ff7 Fix -conf example in README.md
+ 04ce7ba add a no-fail flag
+ e2752bc revert to default GOPATH if necessary (#279)
- c04360f make API
+ 66fb7fc Replace import paths
2019-02-11 09:43:23 +03:00
Denis Isaev
b31cfd6c78
update go-critic
$ git cherry --abbrev -v 0af0999fabfb ee9bf5809ead
+ abd8436 all: enable Go modules on CI (#753)
+ 3c9d0fb checkers: recognize //line and //nolint in commentFormatting (#756)
+ 0b517d7 checkers: extend deprecatedComment patterns (#757)
+ 09100f6 checkers: use astcast package instead of coerce.go (#758)
+ 2e9e97f checker: simplify boolExprSimplify (#759)
+ 575701e make: add go-consistent to CI checks list (#761)
+ b55f431 checkers: fix unlambda handling of builtins (#763)
+ 5a7dee3 checker: handle lambdas properly in boolExprSimplify (#765)
+ 5ce3939 checkers: teach boolExprSimplify a few new tricks (#766)
+ 04d160f checkers: add new patterns to boolExprSimplify (#768)
+ 09582e2 make: collect coverprofile separately from goveralls (#769)
+ d8d0ee4 checkers: recognize NOTE pattern in deprecatedComment (#770)
+ 12f0f85 Update copyright notice to 2019 (#771)
+ f54bdb6 checkers: add stringXbytes checker
+ 170d65c checkers: followup for #773 (#774)
+ 84e9e83 checkers: make stringXbytes more linear (#775)
+ a800815 checkers: add Depreacted typo pattern (#776)
+ 6751be9 checkers: add hexLiterals (#772)
+ ac61906 checkers: add typeAssertChain checker (#782)
+ d19dbf1 checkers: add codegenComment checker (#783)
+ d82b576 checkers: proper pkg/obj check for flagName (#786)
+ dfcf754 ci: enable integration tests (#787)
+ 5dafc45 checkers: fix equalFold false positive (#788)
+ ed5e8e7 checkers: refactor and fix hexLiteral checker (#789)
+ e704e07 checkers: add argOrder checker (#790)
+ 34c1dc8 checkers: add Split handling to argOrder checker (#791)
+ cbe095d checkers: add math.Max and math.Min to dupArg (#792)
+ c986ee5 checkers: add checkers info fields test (#794)
+ 66e5832 cmd/makedocs: use lintpack, fix build (#793)
+ 6bce9d0 cmd/makedocs: add enabled/disabled by default info (#795)
+ 4adbf9a checkers: simplify flagName (#799)
+ 07de34a checkers: add octalLiteral checker (#798)
+ 765907a cmd/makedocs: add checker param docs (#796)
+ ee9bf58 cmd/makedocs: fix headers formatting (#803)
2019-02-11 09:35:41 +03:00
Denis Isaev
81cf48771e
Fix #387: update goimports
$ git cherry --abbrev -v d66bd3c5d5a6 379209517ffe | fgrep imports:
+ a06a922a imports: update zstdlib to Go 1.12
+ cb89afad imports: drop anything after a non identifier rune in package
names
2019-02-11 09:11:51 +03:00
Denis Isaev
9916a2fb79
Relates #367: update unparam
$ git cherry -v cc9d2fb52971 fbb59629db34
+ 7362051ae01a0e35956c077c3be5505c70edd200 testdata: add more regression
tests
+ a88ca0234e2c3732a53cd49514fb3877a5d9f1f5 properly record which methods
implement interfaces
+ b762b0b27fa23ebbdfc31df1af4097cfd89a17f6 work properly with method
wrapper functions
+ f59bb08c5c7429b88e0c6e2399b12e71e8d950db testdata: consistently use
tabs
+ 46a5101c55d03117b263b4c5161e5d01353311c1 replace more callgraph code
with plain SSA
+ 1679b9996abdc6431c2147a133e5223ebb86ea60 rewrite foo(bar()) code to
work without callgraph
+ 71b5df77c291f8c5ead5f9ff0a69e0eebf3ae5b2 rewrite "called in return"
code without callgraph
+ fc5b1c74f563d4f2f9ee7d91eda648fc7baebf67 check: replace last use of
callgraph
+ 229ad68a599e2622cf9d3bb87a385b158efe736f fix a minor false negative in
callExtract
+ fbb59629db34a0f69275bc336cc8c3a4dd9fbe5d fix up another false negative
in testdata
2019-02-11 09:02:56 +03:00
Jonathan Chappelow
01fb8231f9 unparam: update unparam, and go mod vendor
This updates the unparam linter to the current version that has fewer
false positives. The go.{mod,sum} files and the vendor folder are
updated as follows:

export GO111MODULE=on
go get -u mvdan.cc/unparam
go mod tidy
go mod vendor

The unparam callgraph algorithm is no longer selectable. Ref:
https://github.com/mvdan/unparam/commit/e6a6d1c5
This is the reason for removing the c.CallgraphAlgorithm(us.Algo) line
from pkg/golinters/unparam.go.
2019-02-11 13:48:53 +08:00
Denis Isaev
af080e7503
don't crash when staticcheck panics 2019-01-24 12:19:05 +03:00
Denis Isaev
59a533cf52
Fix #344: fix go-misc checksum on go1.11.4
See golang/go#29664 and golang/go#29278
2019-01-21 08:58:39 +03:00
Denis Isaev
87aae77943 Update gocritic
Fix #324, relates #314

1. Update gocritic to the latest version
2. Use proper gocritic checkers repo, old repo was archived
3. Get enabled by default gocritic checks in sync with go-critic: don't
enable performance, experimental and opinionated checks by default
4. Support of `enabled-tags` options for gocritic
5. Enable almost all gocritic checks for the project
6. Make rich debugging for gocritic
7. Meticulously validate gocritic checks config
2019-01-09 09:51:48 +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
Denis Isaev
609de3254c Fix #331: fix errcheck "ignore" config directive.
Make tests for "ignore" and "exclude" directives.
Mark all hidden command-line options as deprecated.
2018-12-23 12:33:41 +03:00
Denis Isaev
a4a7100011 Fix #263: update goimports
The new version of goimports works 100x faster
with go modules. Also it has some new features:

$ git cherry -v 6c7e314b6563 92cdcd90bf52 | fgrep imports
+ 5bbcdc15656ef390fab5dd6e8daf95354f7171e3 imports: redesign fixImports
+ ee45598d2ff288037f53f9e13ae0b1a6e2165ad5 imports: create named imports for name/path mismatches (again)
+ 4c53570e0460bc32468f75bf9dd71c018d03bfa9 imports: ignore globals in different packages
+ 1d424dbce8dd500e9e449fd3ff9d0668c09e2ae1 imports: clean up customization seam
+ 6a3e9aa2ab7749d72d1006ee484271b4a11f96c2 imports: fix renamed sibling imports
+ 5f4a60f04f23ac48e0665f257413ae3eacf339be imports: fix renamed sibling imports more
+ bbccd8cae4a9a47e0f978e03ff4b5df88a9fde1e imports: use go/packages, support modules
+ d4971274fe382404aee0e8c163af974f2bf738e6 imports: don't remove imports that conflict with globals
2018-12-22 15:50:16 +03:00
Denis Isaev
c9c0646265 dev: fix go.sum and don't skip test TestGoimportsLocal 2018-12-22 15:34:16 +03:00
David López
37e6995b45 lintpack/gocritic: update lintpack & gocritic versions
update lintpack & gocritic versions to support all the new gocritic checks
2018-12-22 15:34:16 +03:00
Tim Heckman
cb5d1da986 Add support for home directory expansion for -c/--config flag
This change introduces the ability to use the tilde (`~`) character in your
`-c/--config` flag value to expand your home directory. If invoking this via the
command line with `--config ~/.golangci-lint.yaml`, the user's shell expands the
`~` to the home directory. However, if something is invoking the program for
you (like an editor) it may not do the expansion.

Fixes #289

Signed-off-by: Tim Heckman <t@heckman.io>
2018-11-14 14:30:26 +03:00
Denis Isaev
ac77eaac68 Fix #282, fix #209: revert goimports commit
ed64e33c8c8bc9a919e2b85a1a08225b5ae59d70. Also add tests
for local mode of goimports and do refactoring of tests.
2018-11-10 11:46:37 +03:00
Denis Isaev
0935ce1b8d fix #132: support go-critic linter 2018-11-07 09:11:08 +03:00
Denis Isaev
c02a6daa5c Fix #263: fix goimports performance with modules
Apply https://go-review.googlesource.com/c/tools/+/132598/ as a
temporary fix before a proper fix is in golang.org/x/tools
2018-11-05 12:37:54 +03:00
Denis Isaev
17508ab904
update golang.org/x/tools 2018-10-28 18:03:14 +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