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
Redefine what counts as a branch on ABC Size #8564
Comments
It is indeed tricky. As you realize, it's impossible to know if, in your example, The That said, we could discuss a setting to discount repeated
The first |
Yeah, that actually makes more sense than not counting them at all |
@marcandre I have no objections to your idea about counting multiple instances of the same method call with no arguments as 1 within a method. Technically these method calls could be "branching out of scope" like any other. Nevertheless, it makes sense to view them differently as we continue to shoehorn this metric into the world of Ruby. 🙂 |
PR #9053 is up |
…eated "attributes"
I was thinking if it would be possible to not count getter methods as a branch. I know this has been asked before (can't find the issue now, but I de remember reading something about it) and I'm just wondering if it may be possible with a plugin instead of a configuration setting.
The reason for it is pretty simple, take this method for example
It's ABC would be
<3, 15, 0> = 15.3
Now, if instead of calling model and current_user every time, you assign their values to a variable you get:
It's ABC would be
<5, 10, 0> = 11.18
So the reason this bothers me is that the last method is considered the least complex one, but in reality it takes more time for someone to read through it.
Branches are defined as "an explicit forward program branch out of scope", I would say getter methods in ruby are not really "explicit" as they pretty much look like just any variable. But I'm aware that's highly a matter of personal opinion.
So wrapping up, is there a way to not count any getter method (defined for this purpose as any method that receives no arguments) as branch while calculating ABC? I had a look at
AbcSizeCalculator
class but I can't figure out where thenode.type
comes from in thebranch?(node)
methodThe text was updated successfully, but these errors were encountered: