Skip to content

Add new Performance/ShortCircuitAnd cop#506

Open
Amine-Mike wants to merge 2 commits into
rubocop:masterfrom
Amine-Mike:master
Open

Add new Performance/ShortCircuitAnd cop#506
Amine-Mike wants to merge 2 commits into
rubocop:masterfrom
Amine-Mike:master

Conversation

@Amine-Mike

@Amine-Mike Amine-Mike commented Jun 18, 2025

Copy link
Copy Markdown

Hello,

I’m a young Ruby enthusiast eager to deepen my knowledge by contributing to open source projects. This is my first contribution here, and I had a lot of fun working on it!

In this PR, I’ve added a new cop that enforces short-circuit evaluation of logical and expressions by ensuring that cheaper expressions are evaluated before more expensive ones.

Closes #505


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@Amine-Mike Amine-Mike changed the title [Fix #505]: Add Cop for short-circuiting ands Add Cop for short-circuiting ands Jun 18, 2025
@Amine-Mike Amine-Mike changed the title Add Cop for short-circuiting ands Add new Performance/ShortCircuitAnd cop Jun 25, 2025
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.

Cop idea: short-circuit logical expressions quickly by evaluating variables first

1 participant