bazel-contrib / bazel-contrib/rules_go

Add `skip_nolint` and `skip_nolint_exclude` attributes to nogo rule

Open
#4,476 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1.5k
Forks
760
Avg merge
1d 11h
Merged PRs (30d)
12

Description

Feature Request: Add skip_nolint and skip_nolint_exclude attributes to nogo rule

In a large codebase (monorepo) with established technical debt, //nolint directives can accumulate and hide legitimate issues from static analysis. While nogo supports per-analyzer exclude_files configuration, there's no way to globally enforce analyzer checks while making targeted exceptions (e.g., for test files, mocks, or generated code).

This proposal adds two new attributes to the nogo rule:
- skip_nolint (bool): When true, ignores all //nolint directives, forcing analyzers to report all findings
- skip_nolint_exclude (string_list): Glob patterns for files where nolint directives should still be respected

This enables peeps to progressively reduce technical debt by:
1. Setting skip_nolint = True to prevent new violations from being suppressed
2. Using skip_nolint_exclude = ["*_test.go", "*/testdata/*", "*/mocks/*"] to maintain pragmatic exceptions
3. Gradually fixing production code violations without disrupting test code

Similar to how golangci-lint supports --enable-all with targeted exclusions, this provides a path for codebases to enforce stricter linting standards without requiring a big-bang migration.

Contributor guide

Open the contributing guide

Research direction

Locate the nogo rule's attribute parsing and the code that handles //nolint directives, then trace how per-analyzer exclusions are applied. Confirm the new boolean and glob-list attributes are accepted and that nolint directives are ignored globally or respected only for matching files, with coverage in the relevant existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.