Skip to content

Add lint --non-fixable-only flag#1214

Open
ValentinWalter wants to merge 1 commit into
swiftlang:mainfrom
ValentinWalter:lint-only-unformattable-findings
Open

Add lint --non-fixable-only flag#1214
ValentinWalter wants to merge 1 commit into
swiftlang:mainfrom
ValentinWalter:lint-only-unformattable-findings

Conversation

@ValentinWalter

@ValentinWalter ValentinWalter commented Jun 4, 2026

Copy link
Copy Markdown

Adds a lint --non-fixable-only option.

This filters lint output to findings that cannot be fixed by swift-format format, so callers can avoid surfacing warnings for issues the formatter can already handle. Useful for only displaying non fixable issues in an IDE, while leaving fixable ones for automations. Especially warnings about whitespace can get very noisy in IDEs.

  • Adds per-finding fixability via Finding.isFixable.
  • Preserves the existing public Rule.diagnose API and adds an overload for explicit fixability.
  • Handles rules where some findings are fixable and others are not.
  • Findings from linter-only rules are non-fixable.
  • Findings from format rules are fixable by default.
  • Format rules can override fixability per finding when they diagnose a case the formatter intentionally leaves unchanged.

Current mixed cases are:

  • NoAssignmentInExpressions: Only return x = y is auto-rewritten. Other assignment expressions, like while x = y, are diagnosed but not safely movable.
  • OneVariableDeclarationPerLine: Multi-binding declarations are fixable only when splitting preserves valid Swift. Invalid forms like var a, b = 1 are diagnosed but preserved.
  • OrderedImports: Duplicate imports are removable unless both copies have trailing trivia/comments. In that case the duplicate is diagnosed but not merged.
  • ReturnVoidInsteadOfEmptyTuple: () -> () is rewritten to () -> Void, unless the empty tuple contains interior trivia/comments like (/* comment */).

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.

1 participant