62 Commits

Author SHA1 Message Date
Ludovic Fernandez
64492b5e59
feat: disable copyloopvar and intrange on Go < 1.22 (#4397) 2024-02-19 13:58:58 +00:00
Oleksandr Redko
0704271d8d
dev: refactor some test assertions (#4081) 2023-09-18 22:15:04 +02:00
Ludovic Fernandez
79c78d6f6f
feat: explain typecheck and remove it from the linter list (#3929) 2023-06-29 22:40:59 +02:00
Ludovic Fernandez
39f401ba3c
dev: review and clean linter tests (#3139) 2022-09-01 18:26:28 +02:00
Ludovic Fernandez
bddc63a234
dev: fix CI workflow for Windows (#3134) 2022-08-24 22:10:51 +02:00
Fernandez Ludovic
320a18eb37 dev: concat string 2022-08-21 23:03:16 +02:00
Fernandez Ludovic
3aea4ce9ce fix: flaky tests 2022-08-21 22:52:03 +02:00
Ludovic Fernandez
37d3aa437a
feat: deprecate varcheck, deadcode, and structcheck (#3125) 2022-08-21 21:37:47 +02:00
Ludovic Fernandez
2b4c9ab4fc
dev: follow standards by using 'want' instead of 'ERROR' for tests (#3104) 2022-08-20 18:53:45 +02:00
Ludovic Fernandez
5e140494b6
dev: rewrite the tests framework (#3100) 2022-08-15 21:56:32 +02:00
Sven Anderson
846fab81b9
cgo: fix linters ignoring Cgo files (#3025) 2022-07-30 22:26:33 +02:00
sivchari
1d8a15a0cc
add nosnakecase lint (#2828)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2022-06-30 16:36:33 +02:00
Ludovic Fernandez
f95b1ed39f
golint: deprecation (#1965) 2021-05-11 00:50:50 +02:00
Ludovic Fernandez
fce3949d5b
Deprecate 'scopelint' linter (#1819)
* Deprecate scopelint linter

* clean code base.
2021-03-09 10:19:22 -08:00
Sergey Vilgelm
eefb97438c
ineffassign: use upstrea instead of golangci fork (#1780) 2021-02-26 00:36:43 +01:00
Sergey Vilgelm
b77118fdac
Use errcheck from main repo instead of golangci-lint fork (#1319)
Co-authored-by: Roman Leventov <leventov@ya.ru>
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
2021-02-25 13:16:48 +01:00
Oleg Butuzov
6e7c317610
Sorting result.Issues implementation (golangci/golangci-lint#1217) (#1218) 2020-07-12 16:35:08 -05:00
Joe Wilner
60abe4ab6a
Use lowercase directories (#1229) 2020-07-10 22:09:01 -05:00
Joe Wilner
6550984878
Configure path prefix via processor abstraction (#1226) 2020-07-11 09:14:52 +10: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
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
Aleksandr Razumov
6db0292426
mod: downgrade honnef.co/go/tools to v2019.2.3
Hotfix for `failed prerequisites` errors.
Actual cause is still unknown.

Revert: #987
Ref: #994, #995, #1011
2020-04-23 01:16:55 +03:00
Daniel Helfand
a999403d3a change increase to increasing in timeout error 2020-02-18 11:42:58 -05:00
sayboras
93c0eebfa1 Fixed test deadline unit test 2019-11-07 17:22:13 -05:00
Daniel Caballero
98f60ebaa3 deadline is now deprecated, but should be taking its value from the configuration if set (#822)
* test that demostrates that deadline is not working if comes from the config

* overriding timeout with deadline when only deadline is different from its default value

* tests were not passing. default value for Deadline, that now only comes from config, is 0. Plus static check is going to fail because of deprecated cfg used

* golangci should use the latest golangci-lint version, that is the one deprecating deadline in favour of timeout

* README updated - looks the ci config in this project is used to generate usage instructions.. great!
2019-10-15 14:11:14 +03:00
Denis Titusov
0cc87df732 Rename deadline option to timeout and mark deadline as deprecated. (#793) 2019-10-08 09:37:54 +03:00
Trevor Pounds
6d786b50ae Group imports by package. 2019-10-01 18:09:47 -04:00
Denis Isaev
3aade55e05 Reduce memory usage of go/analysis 2019-09-23 09:52:54 +03:00
Trevor Pounds
a653032409 Fix flaky cgo test failures. (#716)
Fixes flaky cgo test failures caused by duplicate printf
format checks in staticcheck and go vet that use slightly
different reporting formats.
2019-09-20 19:05:01 +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
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
Luke Shumaker
9ce337296b Makefile: Set GO111MODULE=on for consistency, adjust tests accordingly 2019-06-05 00:52:23 -04: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
Denis Isaev
fd825488bf
dev: add test for govet custom formatter 2019-03-18 00:31:30 +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
d437ac8629 Implement auto-fixing for gofmt,goimports,misspell
Also, add more identifier marking patterns.
2019-02-17 20:31:31 +03:00
Denis Isaev
4f0fddf4fe
add tests for abs path args 2018-12-22 14:16:31 +03:00
Denis Isaev
7dfb9cff3d rework skip dir algorithm 2018-12-22 12:24:43 +03:00
Denis Isaev
dba3907ff3 improve typecheck errors parsing 2018-11-23 18:40:25 +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
7836034ecf dev: fix tests 2018-11-07 11:53:30 +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
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
Cezar Sa Espinola
b307cc3765 Fix formatting with updated goimports version 2018-10-20 10:40:40 +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
b900926bfc Fix #121, fix #186: remove --silent,-s flag: be silent by default 2018-08-08 23:55:01 +03:00