mirror of https://github.com/containers/podman.git
Bump golangci-lint to v2.0.2
This ended up slightly more complicated than anticipated, tin part because golangci-lint v2 dropped support for --exclude-dirs, so linter issues with GOOS=windows and GOOS=darwin which were previously ignored had to be fixed now. This is also the reason why the ./hack/golangci-lint was simplified. In addition, it now runs linters on Linux without systemd tag set. Tested locally with: for OS in linux windows darwin; do GOOS=$OS ./hack/golangci-lint.sh; done Linting for GOOS=linux + ./bin/golangci-lint run --build-tags=apparmor,seccomp,selinux 0 issues. + ./bin/golangci-lint run --build-tags=apparmor,seccomp,selinux,systemd 0 issues. + ./bin/golangci-lint run --build-tags=apparmor,seccomp,selinux,remote 0 issues. Linting for GOOS=windows + ./bin/golangci-lint run --build-tags=remote,containers_image_openpgp 0 issues. Linting for GOOS=darwin + ./bin/golangci-lint run --build-tags=remote,containers_image_openpgp 0 issues. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
8bd73b7d2c
commit
c9b108d5b3
|
@ -1,8 +1,14 @@
|
||||||
---
|
version: "2"
|
||||||
run:
|
run:
|
||||||
concurrency: 6
|
|
||||||
timeout: 5m
|
|
||||||
modules-download-mode: readonly
|
modules-download-mode: readonly
|
||||||
|
|
||||||
|
formatters:
|
||||||
|
enable:
|
||||||
|
- gofmt
|
||||||
|
- goimports
|
||||||
|
exclusions:
|
||||||
|
generated: strict
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
enable:
|
enable:
|
||||||
- asasalint
|
- asasalint
|
||||||
|
@ -13,7 +19,6 @@ linters:
|
||||||
- decorder
|
- decorder
|
||||||
- dogsled
|
- dogsled
|
||||||
- durationcheck
|
- durationcheck
|
||||||
- errcheck
|
|
||||||
- errchkjson
|
- errchkjson
|
||||||
- exptostd
|
- exptostd
|
||||||
- fatcontext
|
- fatcontext
|
||||||
|
@ -21,15 +26,10 @@ linters:
|
||||||
- gocheckcompilerdirectives
|
- gocheckcompilerdirectives
|
||||||
- gochecksumtype
|
- gochecksumtype
|
||||||
- gocritic
|
- gocritic
|
||||||
- gofmt
|
|
||||||
- goimports
|
|
||||||
- goprintffuncname
|
- goprintffuncname
|
||||||
- gosimple
|
|
||||||
- govet
|
|
||||||
- grouper
|
- grouper
|
||||||
- iface
|
- iface
|
||||||
- inamedparam
|
- inamedparam
|
||||||
- ineffassign
|
|
||||||
- interfacebloat
|
- interfacebloat
|
||||||
- makezero
|
- makezero
|
||||||
- mirror
|
- mirror
|
||||||
|
@ -49,32 +49,34 @@ linters:
|
||||||
- testableexamples
|
- testableexamples
|
||||||
- unconvert
|
- unconvert
|
||||||
- unparam
|
- unparam
|
||||||
- unused
|
|
||||||
- usestdlibvars
|
- usestdlibvars
|
||||||
- usetesting
|
- usetesting
|
||||||
- wastedassign
|
- wastedassign
|
||||||
- whitespace
|
- whitespace
|
||||||
linters-settings:
|
settings:
|
||||||
errcheck:
|
staticcheck:
|
||||||
check-blank: false
|
checks:
|
||||||
nolintlint:
|
- all
|
||||||
require-specific: true
|
- -ST1003 # https://staticcheck.dev/docs/checks/#ST1003 Poorly chosen identifier.
|
||||||
revive:
|
- -QF1008 # https://staticcheck.dev/docs/checks/#QF1008 Omit embedded fields from selector expression.
|
||||||
|
nolintlint:
|
||||||
|
require-specific: true
|
||||||
|
revive:
|
||||||
|
rules:
|
||||||
|
- name: unused-parameter
|
||||||
|
disabled: true
|
||||||
|
exclusions:
|
||||||
|
generated: strict
|
||||||
|
presets:
|
||||||
|
- comments
|
||||||
|
- common-false-positives
|
||||||
|
- legacy
|
||||||
|
- std-error-handling
|
||||||
rules:
|
rules:
|
||||||
- name: unused-parameter
|
- linters:
|
||||||
disabled: true
|
- recvcheck
|
||||||
|
path: pkg/k8s.io/
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
# Maximum issues count per one linter.
|
|
||||||
# Set to 0 to disable.
|
|
||||||
# Default: 50
|
|
||||||
max-issues-per-linter: 0
|
max-issues-per-linter: 0
|
||||||
# Maximum count of issues with the same text.
|
|
||||||
# Set to 0 to disable.
|
|
||||||
# Default: 3
|
|
||||||
max-same-issues: 0
|
max-same-issues: 0
|
||||||
exclude-rules:
|
|
||||||
# Exclude recvcheck from running on the imported k8s files, to much failures
|
|
||||||
- path: pkg/k8s.io/
|
|
||||||
linters:
|
|
||||||
- recvcheck
|
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -61,7 +61,7 @@ BUILDTAGS += ${EXTRA_BUILDTAGS}
|
||||||
# N/B: This value is managed by Renovate, manual changes are
|
# N/B: This value is managed by Renovate, manual changes are
|
||||||
# possible, as long as they don't disturb the formatting
|
# possible, as long as they don't disturb the formatting
|
||||||
# (i.e. DO NOT ADD A 'v' prefix!)
|
# (i.e. DO NOT ADD A 'v' prefix!)
|
||||||
GOLANGCI_LINT_VERSION := 1.64.4
|
GOLANGCI_LINT_VERSION := 2.0.2
|
||||||
PYTHON ?= $(shell command -v python3 python|head -n1)
|
PYTHON ?= $(shell command -v python3 python|head -n1)
|
||||||
PKG_MANAGER ?= $(shell command -v dnf yum|head -n1)
|
PKG_MANAGER ?= $(shell command -v dnf yum|head -n1)
|
||||||
# ~/.local/bin is not in PATH on all systems
|
# ~/.local/bin is not in PATH on all systems
|
||||||
|
@ -282,7 +282,7 @@ endif
|
||||||
|
|
||||||
.PHONY: golangci-lint
|
.PHONY: golangci-lint
|
||||||
golangci-lint: .install.golangci-lint
|
golangci-lint: .install.golangci-lint
|
||||||
hack/golangci-lint.sh run
|
hack/golangci-lint.sh
|
||||||
|
|
||||||
.PHONY: test/checkseccomp/checkseccomp
|
.PHONY: test/checkseccomp/checkseccomp
|
||||||
test/checkseccomp/checkseccomp: $(wildcard test/checkseccomp/*.go)
|
test/checkseccomp/checkseccomp: $(wildcard test/checkseccomp/*.go)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Need to run linter twice to cover all the build tags code paths
|
# Run golangci-lint with different sets of build tags.
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# WARNING: This script executes on multiple operating systems that
|
# WARNING: This script executes on multiple operating systems that
|
||||||
|
@ -8,38 +8,23 @@ set -e
|
||||||
# a very old version, where modern features (like `declare -A`) are
|
# a very old version, where modern features (like `declare -A`) are
|
||||||
# absent.
|
# absent.
|
||||||
|
|
||||||
# Makefile calls script with the 'run' argument, but developers may not.
|
echo "Linting for GOOS=$GOOS"
|
||||||
# Handle both cases transparently.
|
# Special case: for Darwin and Windows only "remote" linting is possible and required.
|
||||||
[[ $1 == run ]] && shift
|
if [[ "$GOOS" == "windows" || "$GOOS" == "darwin" ]]; then
|
||||||
|
(
|
||||||
BUILD_TAGS_DEFAULT="apparmor,seccomp,selinux"
|
set -x
|
||||||
BUILD_TAGS_ABI="$BUILD_TAGS_DEFAULT,systemd"
|
./bin/golangci-lint run --build-tags="remote,containers_image_openpgp" "$@"
|
||||||
BUILD_TAGS_TUNNEL="$BUILD_TAGS_DEFAULT,remote"
|
)
|
||||||
BUILD_TAGS_REMOTE="remote,containers_image_openpgp"
|
exit 0
|
||||||
|
|
||||||
SKIP_DIRS_ABI=""
|
|
||||||
SKIP_DIRS_TUNNEL=""
|
|
||||||
SKIP_DIRS_REMOTE="libpod/events,pkg/machine/qemu,pkg/machine/wsl,test"
|
|
||||||
|
|
||||||
declare -a to_lint
|
|
||||||
to_lint=(ABI TUNNEL)
|
|
||||||
|
|
||||||
# Special-case, for Darwin and Windows only "remote" linting is possible and required.
|
|
||||||
if [[ "$GOOS" == "windows" ]] || [[ "$GOOS" == "darwin" ]]; then
|
|
||||||
to_lint=(REMOTE)
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for to_lint in "${to_lint[@]}"; do
|
# Normal case (Linux): run linter for various sets of build tags.
|
||||||
tags_var="BUILD_TAGS_${to_lint}"
|
TAGS="apparmor,seccomp,selinux"
|
||||||
skip_var="SKIP_DIRS_${to_lint}"
|
for EXTRA_TAGS in "" ",systemd" ",remote"; do
|
||||||
echo ""
|
|
||||||
echo Running golangci-lint for "$to_lint"
|
|
||||||
echo Build Tags "$to_lint": ${!tags_var}
|
|
||||||
echo Skipped directories "$to_lint": ${!skip_var}
|
|
||||||
(
|
(
|
||||||
# Make it really easy for a developer to copy-paste the command-line
|
# Make it really easy for a developer to copy-paste the command-line
|
||||||
# to focus or debug a single, specific linting category.
|
# to focus or debug a single, specific linting category.
|
||||||
set -x
|
set -x
|
||||||
./bin/golangci-lint run --timeout=10m --build-tags="${!tags_var}" --exclude-dirs="${!skip_var}" "$@"
|
./bin/golangci-lint run --build-tags="${TAGS}${EXTRA_TAGS}" "$@"
|
||||||
)
|
)
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue