Skip to content

[dx] Move if-set rules into code-quality and coding-style sets, deprecate opinionated rules - #8409

Closed
TomasVotruba wants to merge 8 commits into
mainfrom
move-alternative-if-to-bracket-to-coding-style
Closed

[dx] Move if-set rules into code-quality and coding-style sets, deprecate opinionated rules#8409
TomasVotruba wants to merge 8 commits into
mainfrom
move-alternative-if-to-bracket-to-coding-style

Conversation

@TomasVotruba

@TomasVotruba TomasVotruba commented Aug 29, 2026

Copy link
Copy Markdown
Member

Consolidate rules that live in the CodeQuality and CodingStyle namespaces but were registered in the if set into their proper level sets:

  • AlternativeIfToBracketRector -> CodingStyleLevel
  • InlineIfToExplicitIfRector, TernaryFalseExpressionToIfRector, ArrayExplicitBoolCompareRector, ObjectExplicitBoolCompareRector, ShortenElseIfRector -> CodeQualityLevel

Also deprecate two opinionated rules whose result depends on context:

  • SimplifyIfElseToTernaryRector - can worsen readability; extracting a method is a better fix when needed.
  • ExplicitBoolCompareRector - array and object bool compares have dedicated rules; the rest is an opinionated approach.

The rule lives in the CodingStyle namespace; place it in CodingStyleLevel among the safe formatting rules, remove it from the if set.

Claude-Session: https://claude.ai/code/session_012HQ19gVsT8wVkekuVqVXGx
…ctor from if set to code-quality set

Both rules live in the CodeQuality namespace; place them in CodeQualityLevel next to SingularSwitchToIfRector, remove from the if set.

Claude-Session: https://claude.ai/code/session_012HQ19gVsT8wVkekuVqVXGx
…ctor, ShortenElseIfRector from if set to code-quality set

All three live in the CodeQuality namespace; place them in CodeQualityLevel among the compare rules, remove from the if set.

Claude-Session: https://claude.ai/code/session_012HQ19gVsT8wVkekuVqVXGx
The result depends on context and can worsen readability; extracting a method is a better fix when needed. Mark with DeprecatedInterface and @deprecated.

Claude-Session: https://claude.ai/code/session_012HQ19gVsT8wVkekuVqVXGx
@TomasVotruba TomasVotruba changed the title [dx] Move AlternativeIfToBracketRector from if set to coding-style set [dx] Move if-set rules into code-quality and coding-style sets, deprecate SimplifyIfElseToTernaryRector Aug 29, 2026
Array and object bool compares have dedicated rules; the remaining behavior is an opinionated approach that depends on context. Mark with DeprecatedInterface and @deprecated.

Claude-Session: https://claude.ai/code/session_012HQ19gVsT8wVkekuVqVXGx
@TomasVotruba TomasVotruba changed the title [dx] Move if-set rules into code-quality and coding-style sets, deprecate SimplifyIfElseToTernaryRector [dx] Move if-set rules into code-quality and coding-style sets, deprecate opinionated rules Aug 29, 2026
…licitBoolCompareRector

Replace the rule bodies with a deprecation message via ShouldNotHappenException, remove their tests, and unregister them from the if set so they are no longer executed. Also drop the now-obsolete issue tests that combined these rules.

Claude-Session: https://claude.ai/code/session_012HQ19gVsT8wVkekuVqVXGx
…recate CombineIfRector

Move CompleteMissingIfElseBracketRector into CodingStyleLevel next to AlternativeIfToBracketRector. Deprecate CombineIfRector: merging nested ifs can create much less readable code and depends on context - gut the body to throw, remove its tests, unregister it. The if set is now empty.

Claude-Session: https://claude.ai/code/session_012HQ19gVsT8wVkekuVqVXGx
The if set is now empty; its rules were moved to code-quality and coding-style sets or deprecated.

Claude-Session: https://claude.ai/code/session_012HQ19gVsT8wVkekuVqVXGx
@TomasVotruba

Copy link
Copy Markdown
Member Author

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant