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
Currently the CLI tool only allows to change the source files directly based on the given rules.
For code review purposes I propose a --check-only CLI flag, that only reports the findings without changing the checked files.
nice idea – what kind of reporting of findings would you expect? Currently, there are options for summarized output …
--stats Write statistical summary to standard output.
--usedrules Write list of used rules to standard output.
… but I wonder whether you would also want a list of concrete findings, e.g. "[<source file><TAB>]<line number><TAB><to-be-used rule>"? This would then be a bit like the output of ATC (and possibly get longer than the actual code ;-)
15 Remove space before commas and period
32 Simplify a chain with one element
36 Convert upper and lower case
36 Use CamelCase for known CDS names
42 Align declarations
...
the flag requested here should only have an effect on whether or not the analyzed files are being changed. With the flag active, the checked files should only be analyzed and not be changed (read-only). The result should be returned to stdout in both cases (not sure if an additional flag makes sense to log the result additionally to a file, as this could be easily achieved by redirecting the output).
Combined with the alternative output formats requested in #263, the result output could be easily parsed, and the formatting state could be easily checked in e.g. CI without actually changing any files.
I now added the flag --simulate, with which cleanup is run, but no result code is written to a file or to console, so you could typically combine --simulate with --stats and/or --usedrules (unless you only want to measure the runtime duration):
> .\abap-cleanerc.exe --sourcedir "C:\temp\" --filepattern "*.abap" --simulate --stats
\cl_any_class.abap
95 cleanup rules applied to 1.125 code lines in 785 ms. 623 lines changed.
\cl_other_class.abap
95 cleanup rules applied to 15 code lines in 15 ms. 16 lines changed.
> .\abap-cleanerc.exe --sourcedir "C:\temp\" --filepattern "*.abap" --simulate --usedrules
\cl_any_class.abap
33 Standardize empty lines within methods
28 Separate methods and classes with empty lines
4 Standardize empty lines in class definitions
17 Close brackets at line end
[...]
\cl_other_class.abap
1 Separate methods and classes with empty lines
3 Standardize empty lines in class definitions
3 Remove space before commas and period
9 Convert upper and lower case
5 Indent lines
> .\abap-cleanerc.exe --sourcedir "C:\temp\" --targetdir "C:\target\" --overwrite --simulate --stats --usedrules
Invalid combination: --targetdir cannot be used together with --simulate
Invalid combination: --overwrite cannot be used together with --simulate
I liked "simulate" better than "check-only", because ABAP cleaner is more about changing code than checking code – it's rather the user who might then check whether the output of --stats or --usedrules is as expected.
Activity
jmgrassau commentedon Mar 29, 2024
Hi Benedikt,
nice idea – what kind of reporting of findings would you expect? Currently, there are options for summarized output …
… but I wonder whether you would also want a list of concrete findings, e.g. "[<source file><TAB>]<line number><TAB><to-be-used rule>"? This would then be a bit like the output of ATC (and possibly get longer than the actual code ;-)
Kind regards,
Jörg-Michael
bnichell commentedon Apr 4, 2024
Hi Jörg-Michael,
the flag requested here should only have an effect on whether or not the analyzed files are being changed. With the flag active, the checked files should only be analyzed and not be changed (read-only). The result should be returned to stdout in both cases (not sure if an additional flag makes sense to log the result additionally to a file, as this could be easily achieved by redirecting the output).
Combined with the alternative output formats requested in #263, the result output could be easily parsed, and the formatting state could be easily checked in e.g. CI without actually changing any files.
Cheers,
Benedikt
jmgrassau commentedon Dec 13, 2024
Hi Benedikt,
I now added the flag
--simulate, with which cleanup is run, but no result code is written to a file or to console, so you could typically combine--simulatewith--statsand/or--usedrules(unless you only want to measure the runtime duration):I liked "simulate" better than "check-only", because ABAP cleaner is more about changing code than checking code – it's rather the user who might then check whether the output of
--statsor--usedrulesis as expected.Kind regards,
Jörg-Michael
bnichell commentedon Dec 13, 2024
Hi Jörg-Michael,
this is a great addition and will greatly simplify the usage within CI pipelines.
Thank you very much.
Cheers,
Benedikt
enhance command line with --simulate parameter (SAP#264)
enhance command line with --simulate parameter (#264)
jmgrassau commentedon Dec 16, 2024
Hi Benedikt,
the new
--simulateparameter is now available with version 1.21.0, which was just released!Kind regards,
Jörg-Michael