Skip to content

Add 7 cross-language code quality recipes#853

Open
jkschneider wants to merge 8 commits intomainfrom
more-csa
Open

Add 7 cross-language code quality recipes#853
jkschneider wants to merge 8 commits intomainfrom
more-csa

Conversation

@jkschneider
Copy link
Copy Markdown
Member

@jkschneider jkschneider commented Apr 9, 2026

Summary

Part of a cross-language initiative implementing the same 9 RSPEC rules across Java, Go, C#, JavaScript, and Python.

Test plan

  • All 7 new recipe test classes pass (40 tests)
  • Full existing test suite passes with no regressions

New recipes implementing SonarQube RSPEC rules with auto-remediation:
- S1066 CollapsibleIfStatements: merge nested ifs with &&
- S1656 RemoveSelfAssignment: remove x = x dead assignments
- S3923 AllBranchesIdentical: collapse if/else where all branches match
- S1764 SimplifyRedundantLogicalExpression: simplify x && x to x
- S1862 RemoveDuplicateConditions: remove dead duplicate-condition branches
- S1871 MergeIdenticalBranches: merge identical branch bodies with ||
- S4143 RemoveUnconditionalValueOverwrite: remove dead map.put overwrites

These are part of a cross-language initiative covering Java, Go, C#,
JavaScript, and Python with the same rules in each language.
@greg-at-moderne
Copy link
Copy Markdown
Contributor

cross-language initiative

If these recipes are meant to work for all these 5 languages, should we add at least one case for each of the language in each test?

Resolve conflicts in recipes.csv by keeping all new recipe entries
from both branches.
Return directly when a branch has no else, removing the need for the
`hasExplicitElse` flag and its follow-up guard.
`SemanticallyEqual` already matches `(a)` with `a`, but returning
`b.getLeft()` preserved the surrounding parens. Call `unwrap()` so
`(a) && a` simplifies to `a` rather than `(a)`.
Expressions containing method invocations, assignments, increments, or
`new` may produce different results across repeated evaluations, so
simplifying `iterator.next() && iterator.next()` to `iterator.next()`
changes semantics. Only simplify when both operands are side-effect free.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Collapsible if statements should be merged. RSPEC-1066

3 participants