Comments (4)
Hi Fabian,
with the next release, the cleanup rule "Align parameters and components" will also consider the EXPORTING ... section in "RAISE EXCEPTION … MESSAGE … EXPORTING …" and "RAISE SHORTDUMP … MESSAGE … EXPORTING …" cases:
The position of EXPORTING itself depends on the context, so if MESSAGE is in a different place (e.g. because the rule "Align keywords with second word of first line" is not activated), then EXPORTING will be positioned accordingly:
This does not align the MESSAGE section itself – I guess that would be worth a rule of its own…
Kind regards,
Jörg-Michael
from abap-cleaner.
Hi Fabian,
looks like you have a sharp eye for inconsistencies :-), that's great!
For some background, the "Align keywords with second word of first line" rule indeed uses the approach "align with second keyword, unless a better, more specific rule applies". The main idea is that in some cases, multi-line commands confuse the eye w.r.t. where the command starts or ends:
LOOP AT mo_item_manager->get_all_items( )
ASSIGNING FIELD-SYMBOL(<lo_item>).
INSERT VALUE #( item_id = <lo_item>->ms_data-item_id
item_category = if_any_interface=>cos_item_type-empty )
INTO TABLE lth_any_hash_table.
ENDLOOP.
Looking at this, the first thought that comes to my mind is: "Wait, is there an 'ASSIGNING' command in ABAP?", before I then realize that this line is not a stand-alone command at the beginning of the LOOP body, but rather continues the LOOP command.
So, in some cases, it helps readability to indent the second, third etc. line far enough; and aligning it with the second word of the first line usually looks nice and tidy (the idea is from our team programming guideline).
However, RAISE EXCEPTION is a bit of an in-between case, because in its simple form, it is actually like a method call, passing parameters to the constructor of the exception class (similar to CREATE OBJECT). Preferring functional style, you would usually want to replace …
RAISE EXCEPTION TYPE zabc_path_exception
EXPORTING
previous = exception.
… with …
RAISE EXCEPTION NEW zabc_path_exception( previous = exception ).
… which is exactly what the "Replace RAISE … TYPE with RAISE … NEW" rule does. However, that is not possible with the MESSAGE addition, and that's why RAISE EXCEPTION is handled a bit inconsistently.
Therefore, you could argue that the inconsistency lies a bit in the RAISE EXCEPTION syntax itself. I do agree, however, that the "Align parameters and components" rule should apply to "RAISE EXCEPTION TYPE … MESSAGE … EXPORTING", too, and will enhance it accordingly!
Kind regards,
Jörg-Michael
P.S.: MESSAGE with all its variants and additions would in itself of course be worth a cleanup rule. It's not like we have already run out of ideas…
from abap-cleaner.
Thanks! After writing this I also thought about other use cases for consistency and indeed some do feel weird if the logic were applied though I cannot think of an objective way to rule them out. Like this seems unneccessary and doesn't provide any benefit.
CLASS my_class
DEFINITION
CREATE PRIVATE
PUBLIC.
CLASS my_class
DEFINITION
CREATE PRIVATE
PUBLIC.
from abap-cleaner.
Hi Fabian,
this should now work with version 1.4.0 (released today)!
Kind regards,
Jörg-Michael
from abap-cleaner.
Related Issues (20)
- Bug for S/4 readiness check psuedo comments HOT 3
- Aligning single parameters for functional calls HOT 4
- Remove extra spaces inside parentheses HOT 1
- Eclipse ADT - Update Site not reachable? HOT 3
- "Align parameters and components": Direct usage of structure looks weird in VALUE HOT 4
- BUG: Rules "Convert CHECK inside/outside loop..." HOT 5
- Differences with ABAP Formatter HOT 6
- "Align parameters and components" when using multiple indices in nested table expression HOT 4
- "Align conditional expressions": `THROW` not aligned nicely in `SWITCH` HOT 3
- "Align declarations": Line break if the line gets too long HOT 4
- Allow customization of `TODO` keyword HOT 2
- 'Align logical expression' does not recognize WHERE statement HOT 2
- RND parser categorizes as a CAT_LITERAL in ULINE length statement HOT 4
- "Align parameters and components": Options do not behave as expected HOT 5
- Feature request: Align FORM calls HOT 1
- Feature request: Align FORM definitions HOT 1
- Feature request: Standardize order of parameters when using `CL_ABAP_UNIT_ASSERT` HOT 1
- Feature Request: remove empty line-break(s) between ENDxxxxs. HOT 3
- "Delete unused variables": Incorrect result across multiple `TEST-INJECTION` blocks HOT 2
- Bug: "prefer_is_not..." in combination with "move and/or..." breaks when comments are present HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from abap-cleaner.