You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Align declarations inserts an unexpected number of spaces #14
TYPES: BEGIN OF al11_file,
dirname TYPE dirname_al11,
name TYPE filename_al11,
type TYPE cLENGTH10,
len TYPE pLENGTH8DECIMALS0,
owner TYPE fileowner_al11,
mtime TYPE pLENGTH6DECIMALS0,
mode TYPE cLENGTH9,
useable TYPE cLENGTH1,
subrc TYPE cLENGTH4,
errno TYPE cLENGTH3,
errmsg TYPE cLENGTH40,
mod_date TYPE d,
mod_time TYPE cLENGTH8,
seen TYPE cLENGTH1,
changed TYPE cLENGTH1,
status TYPE cLENGTH1,
END OF al11_file,
al11_file_tab TYPE STANDARD TABLE OF al11_file.
FIELD-SYMBOLS<file_list> TYPE al11_file_tab.
After
TYPES: BEGIN OF al11_file,
dirname TYPE dirname_al11,
name TYPE filename_al11,
type TYPE cLENGTH10,
len TYPE pLENGTH8DECIMALS0,
owner TYPE fileowner_al11,
mtime TYPE pLENGTH6DECIMALS0,
mode TYPE cLENGTH9,
useable TYPE cLENGTH1,
subrc TYPE cLENGTH4,
errno TYPE cLENGTH3,
errmsg TYPE cLENGTH40,
mod_date TYPE d,
mod_time TYPE cLENGTH8,
seen TYPE cLENGTH1,
changed TYPE cLENGTH1,
status TYPE cLENGTH1,
END OF al11_file,
al11_file_tab TYPE STANDARD TABLE OF al11_file.
FIELD-SYMBOLS<file_list> TYPE al11_file_tab.
I found some other examples. It seems like the LENGTH addition is aligned after the type of the longest definition in the chain, therefore above STANDARD TABLE OF al11_file. Which I guess is fine if you know about it. Or the component in the type statement that is not part of the BEGIN OF / END OF could have been extracted to its own statement. Here's a more reasonable example of the same:
TYPES:
access_type TYPE cLENGTH1,
mode TYPE cLENGTH15,
encoding TYPE cLENGTH15,
linefeed TYPE cLENGTH10,
endian TYPE cLENGTH1,
BEGIN OF mode_options,
encoding TYPEencoding,
linefeed TYPElinefeed,
endian TYPEendian,
codepage TYPE cpcodepage,
END OF mode_options,
BEGIN OF os_additions,
type TYPE string,
filter TYPE string,
END OF os_additions,
replacement_character TYPE cLENGTH1.
thanks a lot for these examples, this should also be fixed in version 1.2! Now, with default settings in "Align declarations", I get (original code -> cleaned code):
Also doesn't this directly implement the anti pattern listed in the Clean ABAP rule?
Yes, it indeed does – that's why the "Align declarations" rule is deactivated in the "essential" Profile (in which only those rules are active which are explicitly demanded by the style guide).
However, from my experience, this is a rather controversial rule in the style guide, so ABAP cleaner offers "Align declarations" to whoever likes it. And you could argue: If nobody wanted to align TYPEs, then why does Pretty Printer do it on chains, structures and METHODS declarations? Why does the style guide itself have many positive examples with aligned TYPEs? …
Thanks! My initial understanding of the tool was that the default settings do implement the rules of the Clean ABAP styleguide. After reading https://github.com/SAP/abap-cleaner/blob/main/docs/profiles.md I see the non-default Essential profile does that instead. I also found out what the "<->" means in the configuration dialog by reading that.
I do wonder though why this isn't the other way around as at least according to the guide itself it is the official reference guide for S/4HANA development, therefore I would have assumed most users want those settings.
Regarding the rule itself I have no opinion, especially when there's no manual work involved in following it. I just find the "alignment" / consistency between the tools (Code Pal, ADT, ABAP Cleaner) and guidelines (Clean ABAP GitHub, Clean ABAP Book) to be very important for adoption without frustration.
Activity
fabianlupa commentedon May 19, 2023
I found some other examples. It seems like the LENGTH addition is aligned after the type of the longest definition in the chain, therefore above STANDARD TABLE OF al11_file. Which I guess is fine if you know about it. Or the component in the type statement that is not part of the BEGIN OF / END OF could have been extracted to its own statement. Here's a more reasonable example of the same:
fabianlupa commentedon May 19, 2023
Also doesn't this directly implement the anti pattern listed in the Clean ABAP rule?
https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#dont-align-type-clauses
Independant statements are also aligned which is the exact example of what you are not supposed to do?
add option on 'Alignment of nested structures' (SAP#9, SAP#14)
jmgrassau commentedon May 21, 2023
Hi Fabian,
thanks a lot for these examples, this should also be fixed in version 1.2! Now, with default settings in "Align declarations", I get (original code -> cleaned code):
Yes, it indeed does – that's why the "Align declarations" rule is deactivated in the "essential" Profile (in which only those rules are active which are explicitly demanded by the style guide).
However, from my experience, this is a rather controversial rule in the style guide, so ABAP cleaner offers "Align declarations" to whoever likes it. And you could argue: If nobody wanted to align TYPEs, then why does Pretty Printer do it on chains, structures and METHODS declarations? Why does the style guide itself have many positive examples with aligned TYPEs? …
Kind regards,
Jörg-Michael
fabianlupa commentedon May 21, 2023
Thanks! My initial understanding of the tool was that the default settings do implement the rules of the Clean ABAP styleguide. After reading https://github.com/SAP/abap-cleaner/blob/main/docs/profiles.md I see the non-default Essential profile does that instead. I also found out what the "<->" means in the configuration dialog by reading that.
I do wonder though why this isn't the other way around as at least according to the guide itself it is the official reference guide for S/4HANA development, therefore I would have assumed most users want those settings.
Regarding the rule itself I have no opinion, especially when there's no manual work involved in following it. I just find the "alignment" / consistency between the tools (Code Pal, ADT, ABAP Cleaner) and guidelines (Clean ABAP GitHub, Clean ABAP Book) to be very important for adoption without frustration.
add option on 'Alignment of nested structures' (#9, #14)