-
Notifications
You must be signed in to change notification settings - Fork 53
Feature request (or bug?): Rule: "Standardize empty line within methods" should be able to eliminate (all) blank lines #131
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Hi Joachim, for each numeric input field, ABAP cleaner defines a range for possible input – you can try that by pressing Ctrl+Pos1 and Ctrl+End inside each of these fields (also Arrow Up/Down and Page Up/Down works). In this case, entering "Max. empty lines within methods" = 0 would mean that inside methods, ABAP cleaner would remove all empty lines in all cases. I simply didn't expect that someone would want that, because wouldn't you agree that there can be good reasons to structure a method into sections with the help of empty lines? So there could be empty lines that were intentionally put there and you wouldn't want to remove them? The styleguide says "Add a single blank line to separate things, but not more", and even in your short example, I'd personally prefer an empty line between the declarations and the executable statements. But if you're sure you want to get rid of all empty lines, it would be very easy to allow a 0 here. Kind regards, |
Hi Jörg-Michael, I agree sometimes an empty line makes sense. But: at least for method declarations, I really don't want empty lines between them. And I would love ABAP Cleaner to remove them for me. |
Oh, another thing: The link you provided lists this anti-pattern:
As far as I can tell, currently ABAP Cleaner can not fix that to:
-> It could/would with the 0-option. |
Hi Joachim, sure, that's easily done: With respect to the anti-pattern: What ABAP cleaner can do is remove the line breaks at the start and at the end of the method, because IMHO that always makes sense. It can also reduce multiple line breaks to just one. So, from this code… METHOD do_something.
do_this( ).
then_that( ).
ENDMETHOD. …you would then get: METHOD do_something.
do_this( ).
then_that( ).
ENDMETHOD. However, what ABAP cleaner can't do is decide whether the remaining line break is intentional and should therefore be kept. That would require a human being looking at what the code does and whether it helps readability to structure it into several sections with a blank line between them. (Well, you could introduce an option that says "if my method only consists of a maximum of [3] lines, then always remove all blank lines). So, I guess this is a limitation of the approach ABAP cleaner has:
Kind regards, |
Hi Joachim, version 1.7.0 now allows to set this option to 0! Kind regards, |
The rule "Standardize empty line within methods" should be able to eliminate all blank lines.
As of now, this (example from abap cleaner) is the shortest I seem to be able to get:
What I want ist this:
... Setting "Max empty lines within methods" to 0 might/would/should do exactly that.

But I cannot set it to 0 -> it's always set back to 1 :-( .
The text was updated successfully, but these errors were encountered: