Skip to content

Suppress checks

Use a source directive when a finding is intentional and changing the code would make it less clear or correct. Keep the exception next to the code and add a comment explaining why it is necessary.

Suppress the next declaration or statement

Section titled “Suppress the next declaration or statement”

Place //strider:ignore immediately before the declaration or statement that should be exempt. List the check code after the directive:

// The registry is intentionally shared by every request.
//strider:ignore no-package-var
var registry = newRegistry()

The directive applies to the next declaration or statement. To suppress more than one check there, separate the codes with commas:

// Kept as one function to mirror the protocol state machine.
//strider:ignore cognitive-complexity,cyclomatic-complexity
func advanceState() {
// ...
}

Use all to suppress every source-local check on that declaration or statement:

// Generated by the protocol compiler.
//strider:ignore all
func generatedHandler() {
// ...
}

Prefer named codes when possible so readers can see which exceptions are intentional.

Place //strider:ignore-file before the package clause to suppress one or more source-local checks throughout a file:

// Generated code; regenerate it instead of editing it.
//strider:ignore-file no-package-var,no-init
package legacy

The file-level directive also accepts all.

Use the formatter-specific directive to leave an entire file unchanged:

//strider:format-ignore
package legacy

This directive must appear in a header comment before the package clause. It applies to strider fmt and to the format check.

Inline directives apply only to checks that report against local source declarations or statements. Checks that reason across packages must instead use a per-rule path exclusion in strider.toml or a baseline.

Strider does not currently report stale or unused suppression codes, so remove directives when the corresponding exception is no longer needed.