Skip to content

Add //lint:ignore <category> directive to Cadence linter#2330

Open
holyfuchs wants to merge 1 commit intomasterfrom
holyfuchs/cadence-lint-ignore-directive
Open

Add //lint:ignore <category> directive to Cadence linter#2330
holyfuchs wants to merge 1 commit intomasterfrom
holyfuchs/cadence-lint-ignore-directive

Conversation

@holyfuchs
Copy link
Copy Markdown
Member

Description

Adds inline suppression directives to the Cadence linter. Place //lint:ignore <category> on the same line or the line immediately before a diagnostic to suppress it. A new --show-ignored flag reveals what is being suppressed.

How it works

// Suppress on the line before:
//lint:ignore semantic-error
someUndeclaredVar

// Suppress inline on the same line:
someUndeclaredVar //lint:ignore semantic-error

The category must match the diagnostic category exactly (e.g. semantic-error, removal-hint, replacement-hint, security).

Ignored diagnostics are counted in the summary but never affect the exit code:

$ flow cadence lint contract.cdc
1 problem (0 errors, 0 warnings, 1 ignored)

$ flow cadence lint --show-ignored contract.cdc
contract.cdc:3:2: removal-hint: unnecessary force operator (ignored)
1 problem (0 errors, 0 warnings, 1 ignored)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 17, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@holyfuchs holyfuchs force-pushed the holyfuchs/cadence-lint-ignore-directive branch from 366804f to 6dd366a Compare April 17, 2026 10:58
@holyfuchs holyfuchs force-pushed the holyfuchs/cadence-lint-ignore-directive branch from 6dd366a to 9f7388f Compare April 17, 2026 10:59
@holyfuchs holyfuchs marked this pull request as ready for review April 17, 2026 11:01
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 34.95146% with 67 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/cadence/lint.go 34.95% 64 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@jribbink
Copy link
Copy Markdown
Contributor

Great idea @holyfuchs ! Couple questions:

Would it be possible to make this a PR to the https://github.com/onflow/cadence-tools repo instead? Ideally we would preserve this abstraction layer, and not require the CLI to independently parse the source code. I.e. the linter is used internally by the Cadence Language Server & Flow MCP Server as well, so ideally this sort of feature lands in all the places it would apply to.

Second, I'm not really sure, but curious what you think - unlike other general purpose languages, the source code of a smart contract language is intended to be readable by users. Are there any concerns that an inline flag could encourage users to pollute their production contracts/transactions with development artifacts? I'm assuming that a config file/CLI flags would not solve your use case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants