Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ComparisonsThreshold config option to Style/MultipleComparison #11873

Merged

Conversation

fatkodima
Copy link
Contributor

I want to use Style/MultipleComparison, but only when at least 3 comparisons are made. It enforces this style when there are 2. Personally, I do not see much benefit for myself from this in most of the cases. So I made this value configurable, while preserving the original value of 2.

@@ -4374,6 +4374,7 @@ Style/MultipleComparison:
VersionAdded: '0.49'
VersionChanged: '1.1'
AllowMethodComparison: true
MinComparisonsCount: 2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd name this "AllowedComparisonsCount" or "ThresholdComparisonsCount". I don't think that "Min" is the best term in the context. Perhaps the word "count" is a bit redundant.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(obviously the default value would be different depending on the exact name chosen)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to ComparisonsThreshold. Let me know what you think.

@fatkodima fatkodima force-pushed the multiple_comparison-min_comparisons_count branch from d3f89bf to 1252dad Compare May 13, 2023 09:56
@bbatsov bbatsov merged commit 37ee25f into rubocop:master May 13, 2023
29 checks passed
@bbatsov
Copy link
Collaborator

bbatsov commented May 13, 2023

Looks good to me. Thanks!

@fatkodima fatkodima deleted the multiple_comparison-min_comparisons_count branch May 13, 2023 11:17
@fatkodima fatkodima changed the title Add MinComparisonsCount config option to Style/MultipleComparison Add ComparisonsThreshold config option to Style/MultipleComparison May 13, 2023
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.

None yet

2 participants