Skip to content

[CodeQuality] Extract shared services to de-duplicate explicit bool compare and repeated compare rules - #8506

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-dedupe-codequality-clones
Sep 18, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-dedupe-codequality-clones

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Removes two copy-pasted blocks flagged by the duplicated-code detector (surfaced at a lower token threshold).

ExplicitBoolCompare rules

ArrayExplicitBoolCompareRector and ObjectExplicitBoolCompareRector shared an identical refactor() preamble (short-ternary skip, BooleanNot negation detection, Bool_ cast skip, mixed/boolean native-type skip).

Extracted into ExplicitBoolConditionResolver, returning an ExplicitBoolCondition value object (condition node + negation flag). Each rule keeps its own type-specific transform.

Repeated compare to in_array rules

RepeatedAndNotEqualToNotInArrayRector and RepeatedOrEqualToInArrayRector shared the tail that validates the chain length, confirms all compared expressions are equal, and builds the in_array() args.

Extracted into InArrayFromRepeatedCompareFactory::createInArrayArgs(). Each rule keeps its own chain-walk (And/Or, strict-flag handling, and result wrapping).

No behavior change - existing fixtures pass unchanged.

@TomasVotruba
TomasVotruba merged commit bd2aa50 into main Sep 18, 2026
45 checks passed
@TomasVotruba
TomasVotruba deleted the tv-dedupe-codequality-clones branch September 18, 2026 15:11
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