Skip to content

Add autocorrection support to indentation_width rule#6613

Open
nadeemnali wants to merge 3 commits intorealm:mainfrom
nadeemnali:feature/6497-indentation-autocorrect
Open

Add autocorrection support to indentation_width rule#6613
nadeemnali wants to merge 3 commits intorealm:mainfrom
nadeemnali:feature/6497-indentation-autocorrect

Conversation

@nadeemnali
Copy link
Copy Markdown
Contributor

Summary

This PR implements autocorrection for the indentation_width rule, allowing violations to be automatically fixed using the --fix option. The rule now conforms to CorrectableRule and will adjust indentation to match the configured width,
preserving the original style (tabs or spaces).

Details

  • Implements correct(file:) for IndentationWidthRule
  • Handles first-line indentation, whitespace-only lines, and mixed tabs/spaces
  • Respects configuration flags for comments, compiler directives, and multiline strings
  • Extracts helpers for clarity and maintainability

Testing

  • All tests pass with zero regressions
  • Manual verification confirms correct autocorrection

Closes #6497

@nadeemnali nadeemnali force-pushed the feature/6497-indentation-autocorrect branch from 783ba1d to df32252 Compare April 20, 2026 19:55
@SwiftLintBot
Copy link
Copy Markdown

SwiftLintBot commented Apr 20, 2026

1 Warning
⚠️ This PR may need tests.
2 Messages
📖 Building this branch resulted in the same binary size as when built on main.
📖 Skipping OSS check because SwiftLint hasn't changed compared to main.

Generated by 🚫 Danger

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.

Feature Request: Add autocorrection support for indentation_width rule

2 participants