abapOpenChecks – Open source checks SAP Code Inspector / ATC
Over the last 6 months I’ve been working on a set of custom checks for code inspector, the project is available on github.
Currently it contains the following general purpose checks, some complex and some simple.
CHECK_02 – EXIT outside of loop
CHECK_06 – Check for use of pretty printer
CHECK_07 – Functional writing style for CALL METHOD
CHECK_09 – Tab instead of spaces
CHECK_10 – Use icon_ constants
CHECK_11 – Max one statement per line
CHECK_13 – Sequential blank lines
CHECK_17 – Definitions in top of routine
CHECK_21 – Unused FORM parameter
CHECK_22 – Conditions contain identical code
CHECK_23 – CHECK outside of loop
CHECK_24 – Identical code blocks
CHECK_25 – Selection screen data not referenced statically
CHECK_26 – No direct changes to standard tables
You can configure code inspector or ATC to use these checks in your default variant.
The checks are provided “AS IS”, some might not fit your development requirement, and some might be slow or not even work.
This is a box of chocolates; take the ones you like 🙂 . Some of the checks contains settings so it is possible to change to fit your requirements.
Feel free to submit pull requests or open issues. More checks will be added over time.
Thanks for sharing Lars. I'll try as soon as a new inspection project will come.
This is a great example of the value of our SCN.
Hi Lars,
Thanks a lot for sharing these checks.
I believe in SAP BASIS 7.02 CHECK_02 (EXIT outside of loop) and CHECK_23 (CHECK outside of loop) are part of the standard checks:
Anyway in lower releases it might not be there, so it makes sense to implement there.
Peter
Thanks, I've added your information in the Wiki page for CHECK_23, ZCL_AOC_CHECK_23 · larshp/abapOpenChecks Wiki · GitHub
I'll delete the code sometime in the future if it turns out its available on most SAP versions.
Great, that was fast 🙂
Peter
Found also an example for "EXIT statement outside a loop":
These 2 checks are part of "Extended Program Check" -> "Programming Guidelines".
There are some of the checks in "Programming Guidelines" that I personally don't like, whereas I like the CHECK / EXIT checks. Having these checks in abapOpenChecks allows for enabling and changing the message priority, as changes of message priorities for "Extended Program Check" is not supported(see note 1887255). I'll keep the note on the wiki page for the 2 checks so people can choose the approach they like.
You're right. Changing priorities is not supported for "Extended Program Check" (not even in 7.40 system). I didn't notice it before. 🙁
Peter
One note on message priorities for abapOpenChecks, the "Management of" -> "Message Priorities" is not supported. Instead its possible to define the message priority in the check variant, this allows users to have different variants with different message priorities for the same check.
Setting message priorities for extended check is now possible via ZCL_AOC_CHECK_31 · larshp/abapOpenChecks Wiki · GitHub
Nice one. I'll give it a shot in my testsystem and will report if there is something strange to me 😛
~Florian
nice post Lars, really help full and contains lots of information to reduce extra works after code writing.
🙂 Happy Learning.
Praveer.
Great Checks! Thanks a lot for providing them!
thanks, new checks has been added since the blog post, however there are still a lot of bugs, if you find any bugs feel free to add an issue on github
see current list of checks at Home · larshp/abapOpenChecks Wiki · GitHub
oh, regarding clones, CHECK 24 can help finding identical code blocks within the same object(class/program), it does not compare across objects.
update, new feature to compare methods across classes to find cloned methods, see report ZAOC_CLONES
abapOpenChecks/zaoc_clones.prog.abap at master · larshp/abapOpenChecks · GitHub
Following checks has been added after the blog was posted:
CHECK_27 - Last statement is RETURN
CHECK_28 - Space before . or ,
CHECK_29 - Naming, Local test classes
CHECK_30 - EXPORTING can be omitted
CHECK_31 - Extended Program Check, Filterable
CHECK_32 - Database access
CHECK_33 - Append structure field names
CHECK_34 - Large WHEN construct
CHECK_35 - Message not in use
CHECK_36 - Exception text not in use
CHECK_37 - Define message texts in SE91
CHECK_38 - Avoid use of SELECT-ENDSELECT
It seems that there are some checks included, which need an additional product called CVA (SAP NetWeaver Application Server addon for code vulnerability analysis).
Can you confirm it and if so, can I find a overview, what checks need this?
Thank you
~Florian
It is intended to work as a standalone package without dependencies. Though it might use a few standard SAP function modules that are not available on all versions, I will try to rewrite logic if this is the case, minimum ABAP version requirement is 702.
I don't have access to any systems with CVA, so I'm pretty sure it will work without. Do you get an error when installing/activating it? Please create an issue on github, then I'll try to help you out.
Hi Lars,
thank you for your answer. I'll check on that tomorrow and open an issue.
My system is a 7.40 SP8, so it should work fine.
~Florian
By the way, before the following commit, the code had security checks enabled for check 31,
fix for 730 · larshp/abapOpenChecks@ccee468 · GitHub
So it might be the reason you had some trouble?
I'll update the checks today before starting again. Thank you for this hint.
~Florian
Some more checks have been added:
CHECK_39 - Smartforms global definitions naming conventions
CHECK_40 - Check SY-SUBRC
CHECK_41 - Empty line in statement
CHECK_42 - Identical WHEN code
CHECK_43 - Parameter name can be omitted
Lars Hvam Loving this. Just installed and checking out.
I just recently got a bug in code (not mine) due to not sorting table prior to binary search with a full list of fields. I tried standart check for read but it didn't react. I'd like to make myself a new one, probably by starting on your examples. Any tips where to start on writing your own?
cool, I suggest start reading through some of the AOC checks plus standard code to get a feeling on how the CI checks work.
And then just do it, start out with a simple example, ABAP is a crazy language so all scnearios are usually not covered in the initial implementation of a check.
Hi Expert,
I trying to import the abapOpenChecks-master.zip (which downloaded from (https://github.com/larshp/abapOpenChecks) via offline option. The import was completed fine.
But, In SCI, goto Management of, Tests, the openABAPcheck option was not there. And, in the check variant also not appear in the list.
Any idea?
Hi Steve,
I don´t know if you solved. The option is checks. In SCI, goto Management of, Checks.
Best regards.
Ana
Hi Ana Isabel,
Yes, we had resolved the issue. Thanks
Regards,
Steve Chai