Skip to content

Commit

Permalink
code review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
pkwarren committed Mar 21, 2024
1 parent 6baff77 commit 79b1422
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion make/go/go.mk
Expand Up @@ -93,7 +93,7 @@ format:: gofmtmodtidy
.PHONY: checknonolint
checknonolint: $(YQ)
@if bash $(MAKEGO)/scripts/checknolintlint.bash; then \
echo 'golangci-lint nolintlint configured'; \
echo 'golangci-lint nolintlint configured' >&2; \
elif grep -r --include "*.go" '//nolint'; then \
echo '//nolint directives found, surface ignores in .golangci.yml instead' >&2; \
exit 1; \
Expand Down
16 changes: 10 additions & 6 deletions make/go/scripts/checknolintlint.bash
Expand Up @@ -2,13 +2,17 @@

# Managed by makego. DO NOT EDIT.

## checknolintlint exits with an exit code of 0 if nolintlint is enabled and configured properly.
## It exits with an exit code of 2 if nolintlint is not enabled in .golangci.yml.
## It exits with an exit code of 1 if nolintlint is not configured according to standards.
## checknolintlint exits with exit code 0 if nolintlint is enabled and configured according to standards.
## Otherwise, it exits with exit code 1.

set -euo pipefail

# Check if nonolint linter is enabled in config
if [[ ! -f .golangci.yml ]]; then
echo "nolintlint not enabled in .golangci.yml" >&2
exit 1
fiq

# Check if nolintlint linter is enabled in config
NOLINTLINT_ENABLED=0
if [[ `yq '.linters.enable // [] | any_c(. == "nolintlint")' .golangci.yml` == "true" ]]; then
# Enabled individually
Expand All @@ -24,7 +28,8 @@ if [ "${NOLINTLINT_ENABLED}" -eq 1 ]; then
fi
fi
if [ "${NOLINTLINT_ENABLED}" -eq 0 ]; then
exit 2
echo "nolintlint not enabled in .golangci.yml" >&2
exit 1
fi

# Check if nolintlint is configured according to standards.
Expand Down Expand Up @@ -60,4 +65,3 @@ if [[ -n "${allow_no_explanation_0}" ]]; then
echo ".golangci.yml: nolintlint allow-no-explanation must be empty" >&2
exit 1
fi
exit 0

0 comments on commit 79b1422

Please sign in to comment.