-
Notifications
You must be signed in to change notification settings - Fork 40
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
Count lines in private methods #48
Comments
Ok, I have found the place in the analyzer that only analyzes a method if it's not protected or private (https://github.com/makaroni4/sandi_meter/blob/master/lib/sandi_meter/analyzer.rb#L167). Is this intended? AFAIK the rules does not say that private methods can be longer than five lines. |
By the way: Thanks for a great tool! I love this! 😄 |
+1 I am pretty sure there should be no exception to this rule for private or protected methods. |
An option would be great, even though I prefer this to be default. Why should you break the rules in private methods? In the worst case, you copy a big chunk of code to a private method and just call it from the public method -> fully conforming now to sandi's rules ;-) |
@makaroni4, it definitely seems like it was intentional to ignore private methods, was there a reason for that? From the perspective of the rules as they appear here, it makes no special exception for private methods. From a practical perspective, I don't see a particularly compelling reason to skip them. The developer reading and understanding the code will not be shielded from a mess that gets hidden in a private method, in the scenario @agileapplications points out, they'd just be 'gaming the system'. So, I agree that private methods should be included in the rules, as well. As far as if it should be an option or the default behavior, I would say it should be default behavior. I actually didn't realize it was doing this until now, and I find the behavior surprising, so that's a strong indicator to me that it should be the default. I suppose an option could be included to skip private methods, but I'm not sure that provides value. |
Thanks for taking this discussion :) I agree that it should include private methods. Also, I don't see much value in a configurable option to not include private methods. |
@makaroni4, I created a new feature branch on my fork to test out the change. In making the change, it appears 3 other existing tests fail, which were explicitly testing that private and protected methods were not found by the Analyzer. This would be simple for me to address, but I want to understand why private and protected methods were expected to be ignored, before I fix the tests and issue a PR. Also, while making this change doesn't change the public API, it would change the results of running the gem on a project... so, that would be a patch level release (ex. 1.1.7 -> 1.1.8), right? I can bang this out in an hour, if everyone's in agreement on this. |
Is there any update on this? @makaroni4 @mgrecar |
I'm not sure if this is a bug or by design.
Lets say I have this class in
foo.rb
:sandi_meter -d
will produce the expected result:If I make the bar method private like this:
The
bar
method is not counted:Shouldn't the
bar
method be counted even though it's private?This example was mase with ruby 2.1.0
The text was updated successfully, but these errors were encountered: