Add golangci-lint workflow (#1759)
* Add golangci-lint workflow
* Add a bit more lenient linter timeout
1 Minute isn't always enough, so bump to 3.
* Document golangci, add make target
Document how to get golangci-lint in the README file. While here,
provide a QOL target in the makefile
for the linter, and make it part of validation.
* Introduce .golangci.yml
This is the default golangci-lint configuration file location. Use it.
Move configuration into the yaml file, and enable the default set of
linters; we know we pass most of those.
* Add gofmt and revive to golangci-lint
Read the golangci-lint source code to figure out the configuration format.
Copy the configuration from `revive.toml` into the linter configuration.
* Do not set simplify on gofmt
The project currently runs without simplify. So for consistency, don't
make that a requirement for the linter.
* Add new-from-rev
Older issues should not be considered a failure for new PRs and issues.
Use new-from-from to make the current develop as the point-in-time for
when we consider errors.
Once in the tree, we can go and fix the older errors in separate
patches, taking a little bit at a time.
* Move to golangci-lint
Rewrite the way we run targets in the makefile, so it is split between
frontend and backend.
Use the frontend build steps in build.yml
Update README to reflect the new world order.
* Remove check-gofmt.sh
The tool now runs as part of golangci-lint, in particular through the
'validate' target in the Makefile.
* Remove targets for golangci-lint
Fold these targets into the `lint` target. While here, update README.
2021-09-27 00:41:59 +00:00
|
|
|
# options for analysis running
|
|
|
|
run:
|
|
|
|
timeout: 3m
|
|
|
|
modules-download-mode: vendor
|
|
|
|
|
2021-09-27 23:29:45 +00:00
|
|
|
linters:
|
|
|
|
disable-all: true
|
|
|
|
enable:
|
|
|
|
# Default set of linters from golangci-lint
|
|
|
|
- deadcode
|
|
|
|
- errcheck
|
|
|
|
- gosimple
|
|
|
|
- govet
|
|
|
|
- ineffassign
|
|
|
|
- staticcheck
|
|
|
|
- structcheck
|
|
|
|
- typecheck
|
|
|
|
- unused
|
|
|
|
- varcheck
|
|
|
|
# Linters added by the stash project
|
2021-10-03 00:48:03 +00:00
|
|
|
# - bodyclose
|
|
|
|
- dogsled
|
Errorlint sweep + minor linter tweaks (#1796)
* Replace error assertions with Go 1.13 style
Use `errors.As(..)` over type assertions. This enables better use of
wrapped errors in the future, and lets us pass some errorlint checks
in the process.
The rewrite is entirely mechanical, and uses a standard idiom for
doing so.
* Use Go 1.13's errors.Is(..)
Rather than directly checking for error equality, use errors.Is(..).
This protects against error wrapping issues in the future.
Even though something like sql.ErrNoRows doesn't need the wrapping, do
so anyway, for the sake of consistency throughout the code base.
The change almost lets us pass the `errorlint` Go checker except for
a missing case in `js.go` which is to be handled separately; it isn't
mechanical, like these changes are.
* Remove goconst
goconst isn't a useful linter in many cases, because it's false positive
rate is high. It's 100% for the current code base.
* Avoid direct comparison of errors in recover()
Assert that we are catching an error from recover(). If we are,
check that the error caught matches errStop.
* Enable the "errorlint" checker
Configure the checker to avoid checking for errorf wraps. These are
often false positives since the suggestion is to blanket wrap errors
with %w, and that exposes the underlying API which you might not want
to do.
The other warnings are good however, and with the current patch stack,
the code base passes all these checks as well.
* Configure rowserrcheck
The project uses sqlx. Configure rowserrcheck to include said package.
* Mechanically rewrite a large set of errors
Mechanically search for errors that look like
fmt.Errorf("...%s", err.Error())
and rewrite those into
fmt.Errorf("...%v", err)
The `fmt` package is error-aware and knows how to call err.Error()
itself.
The rationale is that this is more idiomatic Go; it paves the
way for using error wrapping later with %w in some sites.
This patch only addresses the entirely mechanical rewriting caught by
a project-side search/replace. There are more individual sites not
addressed by this patch.
2021-10-12 03:03:08 +00:00
|
|
|
- errorlint
|
2021-10-03 00:48:03 +00:00
|
|
|
# - exhaustive
|
|
|
|
- exportloopref
|
|
|
|
# - gocritic
|
|
|
|
# - goerr113
|
2021-09-27 23:29:45 +00:00
|
|
|
- gofmt
|
Errorlint sweep + minor linter tweaks (#1796)
* Replace error assertions with Go 1.13 style
Use `errors.As(..)` over type assertions. This enables better use of
wrapped errors in the future, and lets us pass some errorlint checks
in the process.
The rewrite is entirely mechanical, and uses a standard idiom for
doing so.
* Use Go 1.13's errors.Is(..)
Rather than directly checking for error equality, use errors.Is(..).
This protects against error wrapping issues in the future.
Even though something like sql.ErrNoRows doesn't need the wrapping, do
so anyway, for the sake of consistency throughout the code base.
The change almost lets us pass the `errorlint` Go checker except for
a missing case in `js.go` which is to be handled separately; it isn't
mechanical, like these changes are.
* Remove goconst
goconst isn't a useful linter in many cases, because it's false positive
rate is high. It's 100% for the current code base.
* Avoid direct comparison of errors in recover()
Assert that we are catching an error from recover(). If we are,
check that the error caught matches errStop.
* Enable the "errorlint" checker
Configure the checker to avoid checking for errorf wraps. These are
often false positives since the suggestion is to blanket wrap errors
with %w, and that exposes the underlying API which you might not want
to do.
The other warnings are good however, and with the current patch stack,
the code base passes all these checks as well.
* Configure rowserrcheck
The project uses sqlx. Configure rowserrcheck to include said package.
* Mechanically rewrite a large set of errors
Mechanically search for errors that look like
fmt.Errorf("...%s", err.Error())
and rewrite those into
fmt.Errorf("...%v", err)
The `fmt` package is error-aware and knows how to call err.Error()
itself.
The rationale is that this is more idiomatic Go; it paves the
way for using error wrapping later with %w in some sites.
This patch only addresses the entirely mechanical rewriting caught by
a project-side search/replace. There are more individual sites not
addressed by this patch.
2021-10-12 03:03:08 +00:00
|
|
|
# - gomnd
|
2021-10-03 00:48:03 +00:00
|
|
|
# - gosec
|
|
|
|
# - ifshort
|
|
|
|
- misspell
|
|
|
|
# - nakedret
|
|
|
|
# - noctx
|
|
|
|
# - paralleltest
|
2021-09-27 23:29:45 +00:00
|
|
|
- revive
|
2021-10-03 00:48:03 +00:00
|
|
|
- rowserrcheck
|
|
|
|
- sqlclosecheck
|
Add golangci-lint workflow (#1759)
* Add golangci-lint workflow
* Add a bit more lenient linter timeout
1 Minute isn't always enough, so bump to 3.
* Document golangci, add make target
Document how to get golangci-lint in the README file. While here,
provide a QOL target in the makefile
for the linter, and make it part of validation.
* Introduce .golangci.yml
This is the default golangci-lint configuration file location. Use it.
Move configuration into the yaml file, and enable the default set of
linters; we know we pass most of those.
* Add gofmt and revive to golangci-lint
Read the golangci-lint source code to figure out the configuration format.
Copy the configuration from `revive.toml` into the linter configuration.
* Do not set simplify on gofmt
The project currently runs without simplify. So for consistency, don't
make that a requirement for the linter.
* Add new-from-rev
Older issues should not be considered a failure for new PRs and issues.
Use new-from-from to make the current develop as the point-in-time for
when we consider errors.
Once in the tree, we can go and fix the older errors in separate
patches, taking a little bit at a time.
* Move to golangci-lint
Rewrite the way we run targets in the makefile, so it is split between
frontend and backend.
Use the frontend build steps in build.yml
Update README to reflect the new world order.
* Remove check-gofmt.sh
The tool now runs as part of golangci-lint, in particular through the
'validate' target in the Makefile.
* Remove targets for golangci-lint
Fold these targets into the `lint` target. While here, update README.
2021-09-27 00:41:59 +00:00
|
|
|
|
|
|
|
linters-settings:
|
|
|
|
gofmt:
|
|
|
|
simplify: false
|
|
|
|
|
Errorlint sweep + minor linter tweaks (#1796)
* Replace error assertions with Go 1.13 style
Use `errors.As(..)` over type assertions. This enables better use of
wrapped errors in the future, and lets us pass some errorlint checks
in the process.
The rewrite is entirely mechanical, and uses a standard idiom for
doing so.
* Use Go 1.13's errors.Is(..)
Rather than directly checking for error equality, use errors.Is(..).
This protects against error wrapping issues in the future.
Even though something like sql.ErrNoRows doesn't need the wrapping, do
so anyway, for the sake of consistency throughout the code base.
The change almost lets us pass the `errorlint` Go checker except for
a missing case in `js.go` which is to be handled separately; it isn't
mechanical, like these changes are.
* Remove goconst
goconst isn't a useful linter in many cases, because it's false positive
rate is high. It's 100% for the current code base.
* Avoid direct comparison of errors in recover()
Assert that we are catching an error from recover(). If we are,
check that the error caught matches errStop.
* Enable the "errorlint" checker
Configure the checker to avoid checking for errorf wraps. These are
often false positives since the suggestion is to blanket wrap errors
with %w, and that exposes the underlying API which you might not want
to do.
The other warnings are good however, and with the current patch stack,
the code base passes all these checks as well.
* Configure rowserrcheck
The project uses sqlx. Configure rowserrcheck to include said package.
* Mechanically rewrite a large set of errors
Mechanically search for errors that look like
fmt.Errorf("...%s", err.Error())
and rewrite those into
fmt.Errorf("...%v", err)
The `fmt` package is error-aware and knows how to call err.Error()
itself.
The rationale is that this is more idiomatic Go; it paves the
way for using error wrapping later with %w in some sites.
This patch only addresses the entirely mechanical rewriting caught by
a project-side search/replace. There are more individual sites not
addressed by this patch.
2021-10-12 03:03:08 +00:00
|
|
|
errorlint:
|
|
|
|
# Disable errorf because there are false positives, where you don't want to wrap
|
|
|
|
# an error.
|
|
|
|
errorf: false
|
|
|
|
asserts: true
|
|
|
|
comparison: true
|
|
|
|
|
Add golangci-lint workflow (#1759)
* Add golangci-lint workflow
* Add a bit more lenient linter timeout
1 Minute isn't always enough, so bump to 3.
* Document golangci, add make target
Document how to get golangci-lint in the README file. While here,
provide a QOL target in the makefile
for the linter, and make it part of validation.
* Introduce .golangci.yml
This is the default golangci-lint configuration file location. Use it.
Move configuration into the yaml file, and enable the default set of
linters; we know we pass most of those.
* Add gofmt and revive to golangci-lint
Read the golangci-lint source code to figure out the configuration format.
Copy the configuration from `revive.toml` into the linter configuration.
* Do not set simplify on gofmt
The project currently runs without simplify. So for consistency, don't
make that a requirement for the linter.
* Add new-from-rev
Older issues should not be considered a failure for new PRs and issues.
Use new-from-from to make the current develop as the point-in-time for
when we consider errors.
Once in the tree, we can go and fix the older errors in separate
patches, taking a little bit at a time.
* Move to golangci-lint
Rewrite the way we run targets in the makefile, so it is split between
frontend and backend.
Use the frontend build steps in build.yml
Update README to reflect the new world order.
* Remove check-gofmt.sh
The tool now runs as part of golangci-lint, in particular through the
'validate' target in the Makefile.
* Remove targets for golangci-lint
Fold these targets into the `lint` target. While here, update README.
2021-09-27 00:41:59 +00:00
|
|
|
revive:
|
|
|
|
ignore-generated-header: true
|
|
|
|
severity: error
|
|
|
|
confidence: 0.8
|
|
|
|
error-code: 1
|
|
|
|
warning-code: 1
|
|
|
|
rules:
|
|
|
|
- name: blank-imports
|
|
|
|
disabled: true
|
|
|
|
- name: context-as-argument
|
|
|
|
- name: context-keys-type
|
|
|
|
- name: dot-imports
|
|
|
|
- name: error-return
|
|
|
|
- name: error-strings
|
|
|
|
- name: error-naming
|
|
|
|
- name: exported
|
|
|
|
disabled: true
|
|
|
|
- name: if-return
|
|
|
|
disabled: true
|
|
|
|
- name: increment-decrement
|
|
|
|
- name: var-naming
|
|
|
|
disabled: true
|
|
|
|
- name: var-declaration
|
|
|
|
- name: package-comments
|
|
|
|
- name: range
|
|
|
|
- name: receiver-naming
|
|
|
|
- name: time-naming
|
|
|
|
- name: unexported-return
|
|
|
|
disabled: true
|
|
|
|
- name: indent-error-flow
|
|
|
|
disabled: true
|
|
|
|
- name: errorf
|
|
|
|
- name: empty-block
|
|
|
|
disabled: true
|
|
|
|
- name: superfluous-else
|
|
|
|
- name: unused-parameter
|
|
|
|
disabled: true
|
|
|
|
- name: unreachable-code
|
Errorlint sweep + minor linter tweaks (#1796)
* Replace error assertions with Go 1.13 style
Use `errors.As(..)` over type assertions. This enables better use of
wrapped errors in the future, and lets us pass some errorlint checks
in the process.
The rewrite is entirely mechanical, and uses a standard idiom for
doing so.
* Use Go 1.13's errors.Is(..)
Rather than directly checking for error equality, use errors.Is(..).
This protects against error wrapping issues in the future.
Even though something like sql.ErrNoRows doesn't need the wrapping, do
so anyway, for the sake of consistency throughout the code base.
The change almost lets us pass the `errorlint` Go checker except for
a missing case in `js.go` which is to be handled separately; it isn't
mechanical, like these changes are.
* Remove goconst
goconst isn't a useful linter in many cases, because it's false positive
rate is high. It's 100% for the current code base.
* Avoid direct comparison of errors in recover()
Assert that we are catching an error from recover(). If we are,
check that the error caught matches errStop.
* Enable the "errorlint" checker
Configure the checker to avoid checking for errorf wraps. These are
often false positives since the suggestion is to blanket wrap errors
with %w, and that exposes the underlying API which you might not want
to do.
The other warnings are good however, and with the current patch stack,
the code base passes all these checks as well.
* Configure rowserrcheck
The project uses sqlx. Configure rowserrcheck to include said package.
* Mechanically rewrite a large set of errors
Mechanically search for errors that look like
fmt.Errorf("...%s", err.Error())
and rewrite those into
fmt.Errorf("...%v", err)
The `fmt` package is error-aware and knows how to call err.Error()
itself.
The rationale is that this is more idiomatic Go; it paves the
way for using error wrapping later with %w in some sites.
This patch only addresses the entirely mechanical rewriting caught by
a project-side search/replace. There are more individual sites not
addressed by this patch.
2021-10-12 03:03:08 +00:00
|
|
|
- name: redefines-builtin-id
|
|
|
|
|
|
|
|
rowserrcheck:
|
|
|
|
packages:
|
|
|
|
- github.com/jmoiron/sqlx
|