Skip to content

feat: add fix for the inline-if-can-be-used rule - #1900

Merged
bhirsz merged 1 commit into
mainfrom
feat/add-fix-for-inline-if-can-be-used
Aug 25, 2026
Merged

feat: add fix for the inline-if-can-be-used rule#1900
bhirsz merged 1 commit into
mainfrom
feat/add-fix-for-inline-if-can-be-used

Conversation

@bhirsz

@bhirsz bhirsz commented Aug 25, 2026

Copy link
Copy Markdown
Member

Adds an automatic fix for the inline-if-can-be-used (MISC09) rule. Short single-branch IF blocks are rewritten into an inline IF via --fix.

The InlineIf formatter logic was extracted into a reusable InlineIfConverter class in formatter/utils/inline_if.py and is now shared by both the formatter and the new rule fix.

The InlineIf formatter is kept — it does more than the rule (bidirectional conversion, handles ELSE/ELSE IF and assignments, converts too-long inline IFs back to blocks). This matches the plan in #1631 (fix for MISC09 only; MISC11 stays with the formatter).

Part of #1631.

Stacked on #1899.

  • fix_availability = SOMETIMES (returns None when the inline IF would exceed the limit).
  • Preserves nested indentation.
  • Added test_fix acceptance test + expected_fixed/; InlineIf formatter tests still pass.

@bhirsz
bhirsz force-pushed the feat/add-fix-for-inline-if-can-be-used branch from fb839b6 to 4debd32 Compare August 25, 2026 06:22
Base automatically changed from feat/remove-replace-run-keyword-if-formatter to main August 25, 2026 06:37
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bhirsz
bhirsz force-pushed the feat/add-fix-for-inline-if-can-be-used branch from 4debd32 to 590c6d5 Compare August 25, 2026 06:37
@bhirsz
bhirsz merged commit e0abb92 into main Aug 25, 2026
11 checks passed
@bhirsz
bhirsz deleted the feat/add-fix-for-inline-if-can-be-used branch August 25, 2026 07:07
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