Commit Graph

57 Commits (main)

Author SHA1 Message Date
renovate[bot] 7f2d8ae80b [CI:DOCS] Update dependency golangci/golangci-lint to v1.56.1
Disable the `perfsprint` and `typecheck` linters as they are too noisy.
There are some good issues worthy of fixing but it's too time consuming
at the moment.  Hence, let's unblock the PR.

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2024-02-13 11:02:56 +01:00
Paul Holzinger 9e648a1f50
lint: disable testifylint
The new linter testifylint reports way to many issues, although they
look like correct findings it is only a small expected vs actual swap
which should not effect the tests other than a (maybe )confusing
error message.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-20 16:27:46 +02:00
Valentin Rothberg 84e42877ae make lint: re-enable revive
But disable the `unused-parameter` linter as there are just too many
reports that I could handle.  Also allow unused nolintlint reports.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-06-19 15:20:57 +02:00
Valentin Rothberg aa453c4f11 make lint: re-enable ginkgolinter
To make sure the e2e tests are kept in order.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-06-19 15:09:34 +02:00
Valentin Rothberg 2efa7c3fa1 make lint: enable rowserrcheck
It turns out, after iterating over rows, we need to check for errors. It
also turns out that we did not do that at all.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-06-19 14:31:40 +02:00
Valentin Rothberg f07aa1bfdc make lint: enable wastedassign
Because we shouldn't waste assigns.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-06-19 14:14:48 +02:00
Valentin Rothberg 60a5a59475 make lint: enable mirror
Helpful reports to avoid unnecessary allocations.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-06-19 14:11:12 +02:00
Valentin Rothberg a35da3ad87 bump golangci-lint to v1.53.3
Disable new linters and drop comments on them.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-06-19 14:11:10 +02:00
Paul Holzinger 93c35a7038
golangci-lint: show all errors at once
When golangci-lint it will only report 3 errors fromt he same linter by
default. This is annoying when a new linter is added and you think only
3 three errors lets fix it real quick only to notice when you rerun it
there again new 3 errors and so on.
In CI and local I want to see all issues at once so I can fix them and
know how much work it is before starting to fix them.

With `max-issues-per-linter: 0` and `max-same-issues: 0` it will show
us all errors because 0 means unlimted. By default it will only show 50
per linter and 3 from the same issue.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-02-07 14:26:23 +01:00
Paul Holzinger 77e4b19397
update golangci-lint to version 1.51.1
The new version contains the ginkgolinter, which makes sure the
assertions are more helpful.

Also replace the deprecated os.SEEK_END with io.SeekEnd.

There is also a new `musttag` linter which checks if struct that are
un/marshalled all have json tags. This results in many warnings so I
disabled the check for now. We can reenable it if we think it is worth
it but for now it way to much work to fix all report problems.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-02-07 14:16:21 +01:00
Valentin Rothberg dcbf7b4481 bump golangci-lint to v1.50.1
Also fix a number of duplicate words.  Yet disable the new `dupword`
linter as it displays too many false positives.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-12-15 13:39:56 +01:00
Ed Santiago 59118b42b1 golangci-lint: remove three deprecated linters
golangci-lint is throwing warnings on each run:

   WARN [runner] The linter 'xxxxx' is deprecated (since v1.49.0)
      due to: The owner seems to have abandoned the linter.
      Replaced by unused.

...for xxxxx in deadcode, structcheck, varcheck. Add those three
to the deprecated-linter list, and remove any exceptions from
the code base.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-12-10 13:34:46 -07:00
Valentin Rothberg 44bac51fca bump golangci-lint to v1.49.0
Motivated to have a working `make lint` on Fedora 37 (beta).
Most changes come from the new `gofmt` standards.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-10-17 09:19:41 +02:00
Paul Holzinger 21819254dd
golangci-lint: update to v1.46.2
Update to the latest golangci-lint version. v1.46 added new linters.
I disabled nonamedreturns and exhaustruct since they enforce a certain
code style and using them would require big changes to the code base.

The nosprintfhostport is new and I fixed one problem in the tests. While
the test itself is fine because it uses ipv4 only the linter still looks
good because the sprintf use will fail for ipv6 addresses.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-06-15 19:58:30 +02:00
Paul Holzinger 41528739ce
golangci-lint: enable nolintlint
The nolintlint linter does not deny the use of `//nolint`
Instead it allows us to enforce a common nolint style:
- force that a linter name must be specified
- do not add a space between `//` and `nolint`
- make sure nolint is only used when there is actually a problem

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-06-14 16:29:42 +02:00
Valentin Rothberg b22143267b linter: enable unconvert linter
Detects unneccessary type conversions and helps in keeping the code base
cleaner.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-05-19 13:59:15 +02:00
Paul Holzinger 69c479b16e
enable errcheck linter
The errcheck linter makes sure that errors are always check and not
ignored by accident. It spotted a lot of unchecked errors, mostly in the
tests but also some real problem in the code.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-29 14:06:38 +02:00
Paul Holzinger 51fbf3da9e
enable gocritic linter
The linter ensures a common code style.
- use switch/case instead of else if
- use if instead of switch/case for single case statement
- add space between comment and text
- detect the use of defer with os.Exit()
- use short form var += "..." instead of var = var + "..."
- detect problems with append()
```
newSlice := append(orgSlice, val)
```
  This could lead to nasty bugs because the orgSlice will be changed in
  place if it has enough capacity too hold the new elements. Thus we
  newSlice might not be a copy.

Of course most of the changes are just cosmetic and do not cause any
logic errors but I think it is a good idea to enforce a common style.
This should help maintainability.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-26 18:12:22 +02:00
OpenShift Merge Robot 09ef4f2e22
Merge pull request #13978 from Luap99/unparam
enable unparam linter
2022-04-25 13:43:57 -04:00
Paul Holzinger c7b16645af
enable unparam linter
The unparam linter is useful to detect unused function parameters and
return values.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-25 13:23:20 +02:00
Paul Holzinger 5b4af0584d
replace golint with revive linter
golint, scopelint and interfacer are deprecated. golint is replaced by
revive. This linter is better because it will also check for our error
style: `error strings should not be capitalized or end with punctuation or a newline`

scopelint is replaced by exportloopref (already endabled)
interfacer has no replacement but I do not think this linter is
important.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-22 15:12:33 +02:00
Paul Holzinger 2a8e435671
enable staticcheck linter
Fix many problems reported by the staticcheck linter, including many
real bugs!

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-22 12:51:29 +02:00
Valentin Rothberg 68b94338ba linter: enable makezero
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:04:35 +01:00
Valentin Rothberg 0f12b6fe55 linter: enable nilerr
A number of cases looked suspicious, so I marked them with `FIXME`s to
leave some breadcrumbs.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:04:35 +01:00
Valentin Rothberg 081e091437 linter: document nolintlint
We need to keep disabling the `nolintlint` linter to continue using
`nolint` directives in the code.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:04:35 +01:00
Valentin Rothberg 7c047bfbe9 linter: document tagliatelle
Disabling tagliatelle would mean disabling it for hundreds of fields
that cannot be changed due to K8s or Docker or backwards compat.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:04:35 +01:00
Valentin Rothberg fb792f7ed4 linter: enable ineffassign
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:04:35 +01:00
Valentin Rothberg f72a678f2a linter: enable errchkjson
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:04:35 +01:00
Valentin Rothberg bb6b69b4ab linter: enable wastedassign
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:04:34 +01:00
Valentin Rothberg 070e401499 linter: enable interfacer
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:04:34 +01:00
Valentin Rothberg 026bd9b205 bump golangci-lint to v1.45.0
* supports Go 1.18
* disable a number of new linters
* fix minor stylecheck issues

[NO NEW TESTS NEEDED]

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-21 10:42:53 +01:00
Ed Santiago b63d696405 e2e tests: enable golint
...and fix problems found therewith.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-11-29 08:30:00 -07:00
Paul Holzinger 78b419909b Enable more golangci-lint linters
Cleanup the golangci.yml file and enable more linters.

`pkg/spec` and `iopodman.io` is history. The vendor directory
is excluded by default. The dependencies dir was listed twice.

Fix the reported problems in `pkg/specgen` because that was also
excluded by `pkg/spec`.

Enable the structcheck, typecheck, varcheck, deadcode and depguard
linters.

[NO TESTS NEEDED]

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-02-12 18:20:28 +01:00
Paul Holzinger 78c8a87362 Enable whitespace linter
Use the whitespace linter and fix the reported problems.

[NO TESTS NEEDED]

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-02-11 23:01:56 +01:00
Paul Holzinger 69ab67bf90 Enable golint linter
Use the golint linter and fix the reported problems.

[NO TESTS NEEDED]

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-02-11 23:01:49 +01:00
Paul Holzinger ef2fc90f2d Enable stylecheck linter
Use the stylecheck linter and fix the reported problems.

[NO TESTS NEEDED]

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-02-11 23:01:29 +01:00
Matej Vasek 68133414f4 [NO TESTS NEEDED] Update linter
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-02-10 13:25:40 +01:00
Daniel J Walsh f62a356515
Remove varlink support from Podman
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-11-26 16:50:42 -05:00
Chris Evich 2c9084e224
Cirrus: Implement podman automation 2.0
Reimplement CI-automation to remove accumulated technical-debt and
optimize workflow.  The task-dependency graph designed goal was to
shorten it's depth and increase width (i.e. more parallelism).  A
reduction in redundant building (and 3rd party module download) was
also realized by caching `$GOPATH` and `$GOCACHE` early on.  This
cache is then reused in favor of a fresh clone of the repository
(when possible).

Note: The system tests typically execute MUCH faster than the
integration tests.  However, contrary to a fail-fast/fail-early
principal, they are executed last.  This was implemented due to
debug-ability related concerns/preferences of the primary
(golang-centric) project developers.

Signed-off-by: Chris Evich <cevich@redhat.com>
2020-10-02 11:53:04 -04:00
Daniel J Walsh 200cfa41a4
Turn on More linters
- misspell
    - prealloc
    - unparam
    - nakedret

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-15 07:05:56 -04:00
Daniel J Walsh 4bb43b898d
Fixup issues found by golint
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-10 05:49:41 -04:00
Valentin Rothberg 09dc701097 podman rmi: refactor logic
While this commit was initially meant to fix #5847, it has turned into a
bigger refactoring which I did not manage to break into smaller pieces:

 * Fix #5847 by refactoring the image-removal logic.

 * Make the api handler for image-removal use the ABI code. This way,
   both (i.e., ABI and Tunnel) end up using the same code.  Achieving
   this code share required to move some code around to prevent circular
   dependencies.

 * Everything in pkg/api (excluding pkg/api/types) must now only be
   accessed from code using `ABISupport`.

 * Avoid imports from entities on handlers to prevent circular
   dependencies.

 * Move `podman system service` logic into `cmd` to prevent circular
   dependencies - it depends on pkg/api.

 * Also remove the build header from infra/abi files.  It will otherwise
   confuse swagger and other tools; errors we cannot fix as go doesn't
   expose a build-tag env variable.

Fixes: #5847
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-04-21 08:12:25 +02:00
Jhon Honce e0847f5457 V2 podman system service
* Added support for system service
* Enabled linting on the varlinkapi source, needed to support V2
  service command
* Added support for PODMAN_SOCKET

Skip linting deprecated code

Rather than introduce bugs by correcting deprecated code, linting the
code is being skipped. Code that is being ported into V2 is being
checked.

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-04-07 19:22:10 -07:00
Brent Baude ba1d8ad2af enable linting on v2
Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-03-25 14:16:56 -05:00
Valentin Rothberg 593eb7625a golangci: enable goimports
Enable the goimports linter and fix reports.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-03-05 20:03:44 +01:00
Valentin Rothberg a102869746 .golangci.yml: move swagger.go from Makefile
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-01-14 09:54:48 +01:00
Valentin Rothberg 4533dea70e make lint: include docs/
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-01-14 09:54:48 +01:00
Valentin Rothberg 4fb24ab145 make lint: include pkg/tracing
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-01-14 09:54:48 +01:00
Valentin Rothberg 67165b7675 make lint: enable gocritic
`gocritic` is a powerful linter that helps in preventing certain kinds
of errors as well as enforcing a coding style.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-01-13 14:27:02 +01:00
Valentin Rothberg 270d892c3d linter: blacklist linters instead of whitelisting
Blacklist linters instead of whitelisting them.  This way, we will
benefit from new linters when updating and it's easier to actually
find and fix open issues.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-01-13 14:27:02 +01:00