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 new CountAsOne
option for code length related Metric
cops
#8159
Conversation
Great start! I have been thinking about a similar setting myself, but the point I kept getting stuck at is the fact that arrays and hashes can have arbitrary amounts of code in them. In the test cases for this configuration option, all the arrays and hashes are assumed to be shallow collections of primitive values, which is the case where this makes sense. But I must assume this introduces some false negatives? 🤔 |
No, the code works for arbitrary complex arrays/hashes. For example, the multiline array in the original issue would be folded into 1 line.
Am I answered also this question or should you provide an example then, if not? |
Yeah, it'd be nice if there are some examples in the cop's description about using this new config. |
c0c5c19
to
e815b97
Compare
Updated with suggestions. |
Thanks! |
@fatkodima - I know this is 8 months old now, but I found it today, updated rubocop to the latest version, and am very, very happy. Thank you for this |
Closes #7724
This new setting allows to specify which ruby construction (
array
,hash
andheredoc
are currently implemented) we want to treat as one line.The algorithm from the high level: