Skip to content

Add autocorrection support to indentation_width rule#6613

Open
nadeemnali wants to merge 4 commits into
realm:mainfrom
nadeemnali:feature/6497-indentation-autocorrect
Open

Add autocorrection support to indentation_width rule#6613
nadeemnali wants to merge 4 commits into
realm: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.
19 Messages
📖 Building this branch resulted in a binary size of 27640.13 KiB vs 27639.02 KiB when built on main (0% larger).
📖 Linting Aerial with this PR took 0.33 s vs 0.32 s on main (3% slower).
📖 Linting Alamofire with this PR took 0.43 s vs 0.4 s on main (7% slower).
📖 Linting Brave with this PR took 2.77 s vs 2.75 s on main (0% slower).
📖 Linting DuckDuckGo with this PR took 10.58 s vs 10.57 s on main (0% slower).
📖 Linting Firefox with this PR took 4.56 s vs 4.53 s on main (0% slower).
📖 Linting Kickstarter with this PR took 3.24 s vs 3.24 s on main (0% slower).
📖 Linting Moya with this PR took 0.22 s vs 0.21 s on main (4% slower).
📖 Linting NetNewsWire with this PR took 1.06 s vs 1.03 s on main (2% slower).
📖 Linting Nimble with this PR took 0.33 s vs 0.31 s on main (6% slower).
📖 Linting PocketCasts with this PR took 2.79 s vs 2.77 s on main (0% slower).
📖 Linting Quick with this PR took 0.24 s vs 0.21 s on main (14% slower).
📖 Linting Realm with this PR took 0.97 s vs 0.94 s on main (3% slower).
📖 Linting Sourcery with this PR took 0.68 s vs 0.67 s on main (1% slower).
📖 Linting Swift with this PR took 1.6 s vs 1.58 s on main (1% slower).
📖 Linting SwiftLintPerformanceTests with this PR took 3.89 s vs 3.85 s on main (1% slower).
📖 Linting VLC with this PR took 0.52 s vs 0.52 s on main (0% slower).
📖 Linting Wire with this PR took 6.84 s vs 6.81 s on main (0% slower).
📖 Linting WordPress with this PR took 4.53 s vs 4.53 s on main (0% slower).

Generated by 🚫 Danger

@nadeemnali nadeemnali force-pushed the feature/6497-indentation-autocorrect branch 4 times, most recently from 9d7c944 to 84eaea7 Compare May 17, 2026 14:12
@nadeemnali nadeemnali marked this pull request as draft May 17, 2026 14:13
@nadeemnali nadeemnali force-pushed the feature/6497-indentation-autocorrect branch 3 times, most recently from 85ac3ba to df32252 Compare May 17, 2026 14:30
@nadeemnali nadeemnali force-pushed the feature/6497-indentation-autocorrect branch from a9b790c to f56f9bc Compare May 17, 2026 14:40
@nadeemnali nadeemnali marked this pull request as ready for review May 17, 2026 14:40
@nadeemnali nadeemnali force-pushed the feature/6497-indentation-autocorrect branch from 844ab9d to fd5eac9 Compare May 17, 2026 15:30
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