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
Bug/Feature Request: Missing newline (lf) character at the end, if output target is file #124
If working with abapGit repositories, each ABAP file is always ended with a newline (lf) character. The abapGit report adds this newline behind the scene, as the web editors like GitHub are doing the same thing.
ABAP Cleaner currently does not do this, and so I would have always at least this one diff if I clean a whole lot of files.
The code adjustment would be very simple. I am not sure if an extra cli option is required for this, as a newline at the end of file will not hurt anyone - I think 😉.
just to be sure I understand this correctly: This is just meant for the case of command line usage, i.e. for FrmMain.writeCleanUpResult(), right? Because I think in other contexts (e.g. returning the cleanup result to the ADT editor), the final LF would not be helpful.
And would "cr lf" (\r\n) be fine as well? Because this is always used between ABAP statements (ABAP.LINE_SEPARATOR).
correct. This is only for cli usage.
Regarding crlf vs lf. I think it has to be lf. Then ABAP Cleaner would be conform with abapGit (cl_abap_char_utilities=>newline = lf).
I will check if crlf will cause any problems or not.
okay, I enhanced this to persistency.writeAllTextToFile(targetPath, output + ABAP.LINE_SEPARATOR);
Regarding crlf versus lf, I think I chose crlf because that is what ABAP cleaner gets from the ADT editor (if I remember correctly), at least on Windows.
I also checked if it would make a difference with crlf or not. I couldn't detect one. At least no visible diff from git. Could also be because of the git setting core.autocrlf = true. So I think it should be fine either way 🤞.
great, thanks for checking! Actually, I realized that the method must check whether a lf or crlf is missing at the end, and only then add it; otherwise, if the source file ends with 3 line feeds, you'd get 4 line feeds in the target file etc. (this is because the parser ignores a single line feed at the end, but not multiple line feeds).
I also enhanced this method a bit to write the "sourceFolderFile" to the console if(!) --stats and/or --usedrules are requested. Otherwise you wouldn't know which file the respective information belongs to.
Activity
jmgrassau commentedon Sep 30, 2023
Hi Ludwig,
just to be sure I understand this correctly: This is just meant for the case of command line usage, i.e. for FrmMain.writeCleanUpResult(), right? Because I think in other contexts (e.g. returning the cleanup result to the ADT editor), the final LF would not be helpful.
And would "cr lf" (\r\n) be fine as well? Because this is always used between ABAP statements (ABAP.LINE_SEPARATOR).
Kind regards,
Jörg-Michael
stockbal commentedon Sep 30, 2023
Hi Jörg-Michael,
correct. This is only for cli usage.
Regarding
crlfvslf. I think it has to belf. Then ABAP Cleaner would be conform with abapGit (cl_abap_char_utilities=>newline =lf).I will check if
crlfwill cause any problems or not.Kind regards,
Ludwig
jmgrassau commentedon Sep 30, 2023
Hi Ludwig,
okay, I enhanced this to
persistency.writeAllTextToFile(targetPath, output + ABAP.LINE_SEPARATOR);Regarding
crlfversuslf, I think I chosecrlfbecause that is what ABAP cleaner gets from the ADT editor (if I remember correctly), at least on Windows.Kind regards,
Jörg-Michael
stockbal commentedon Sep 30, 2023
Hi Jörg-Michael,
I also checked if it would make a difference with
crlfor not. I couldn't detect one. At least no visible diff from git. Could also be because of the git settingcore.autocrlf = true. So I think it should be fine either way 🤞.Kind regards,
Ludwig
jmgrassau commentedon Sep 30, 2023
Hi Ludwig,
great, thanks for checking! Actually, I realized that the method must check whether a
lforcrlfis missing at the end, and only then add it; otherwise, if the source file ends with 3 line feeds, you'd get 4 line feeds in the target file etc. (this is because the parser ignores a single line feed at the end, but not multiple line feeds).I also enhanced this method a bit to write the "sourceFolderFile" to the console if(!)
--statsand/or--usedrulesare requested. Otherwise you wouldn't know which file the respective information belongs to.Kind regards,
Jörg-Michael
fix command line cleanup adding LF at end of file (SAP#124)
fix command line cleanup adding LF at end of file (#124)
jmgrassau commentedon Oct 2, 2023
Hi Ludwig,
this was now released with version 1.6.0, so files cleaned via command line will now always end with at least one
crlf!Kind regards,
Jörg-Michael
ConjuringCoffee commentedon Oct 2, 2023
Jörg-Michael, you're really on a roll in the past few days! Thanks for the work you do 😄