The new public enemy number one: static code analysis
Photo created by Elena and Michael Keller

The new public enemy number one: static code analysis

Static ABAP code analysis can be a real asset. It depends on the specific checks being performed. Personally, I’ve had very good experiences with the standard versions of the ABAP Test Cockpit (ATC) in the past.

However, I’ve also seen custom ATC check rules and third-party code analysis tools that could really ruin your workday. It’s understandable that such ATC versions and third-party tools don’t have many fans.

Nevertheless, I wouldn’t go so far as to try and circumvent static code analysis. But that’s exactly what I saw recently in a code review. A rather lonely decision by an ABAP developer. Especially since there was no professional justification and one was almost forced to assume that it fell into the category of “not wanting to do it properly”.

I’m sure there’s a better way. If you’re not happy with the result of a code analysis, here are a few suggestions on how to deal with it.

Let’s start with the suggestions if the check result is correct and therefore a code adjustment is necessary:

  1. If a suggested correction is provided, apply it if appropriate.
  2. Change the design of the affected code section. The goal here is to make it technically sound, not to try and trick the code check with a lot of imagination.

Here are the suggestions if the check result is incorrect and therefore no code adjustment is necessary:

  1. Inform the code analysis tool via Pseudo Comment or Pragma that it should no longer flag the code for that specific section.
  2. Request exemptions. Edge cases exist. (Note from Mike Pokraka . Many thanks, I hadn't even thought of this typical solution).
  3. Change the check rule. This may sometimes require collaboration with people from other departments. However, the effort is worthwhile because all developers will benefit.
  4. Modify the design of the code in question so that the code analysis tool can better assess it and consequently approve it.

These are just a few suggestions, quickly jotted down. Perhaps someone else has another suggestion?


Thank you for reading. If you enjoyed the post, please leave a like, comment, or share the article with your community. Thanks in advance.

Michael

Don‘t blindly rely on SAST results but combine it with manual reviews and testing. KPIs on SAST results only can yield to wrong incentives towards creating things that „look“ good but aren’t

Make the SAST tool you’re using integral part of the toolchain. Integrate into quality gates and adjust and expand rulesets to address the specific challenges in your environment.

You can advance “heavenly” buy using an objective static code analysis tool like CAST Highlight. But of course you need to mature and document your way of abap coding to standards like handbook and on going checks

Option 4: Request exemptions. Edge cases exist. And if properly set up, ATC can also be a great tool to enforce a targeted review and approval - e.g. to have a senior dev approve the use of dynamic sql.

It might sound obvious but it starts by documenting your coding standards, check, styling and linting rules in a central location. “If you want to work here, this is how we do things”. Then at regular intervals you can - should - revisit the document and adjust as necessary. Comes in handy, too, when you hire help.

To view or add a comment, sign in

More articles by Michael Keller

  • Code, Comments, AI

    In my early days as a developer, I wrote a lot of comments. They were necessary because otherwise I would have quickly…

    11 Comments
  • Attributes, states and time

    Classes, with their attributes and methods, unite two fundamental concepts of computer science: data and algorithms…

    4 Comments
  • Distinguish between the functionality and its implementing code

    Many ABAP source codes clearly show signs of having been modified repeatedly over the years. The code bears the…

    3 Comments
  • What you can find in an ABAP class

    What would you least expect to find in an ABAP class? Take your time to think about it and create your own top three…

    1 Comment
  • Example of External Tools in Eclipse for ABAP developers

    By choosing Eclipse as the development environment for ABAP, SAP has opted for open source software that is inherently…

    1 Comment
  • Technically possible but not good style in ABAP

    There are different solutions for many ABAP tasks. Even if the result of each solution appears to be the same at first…

    4 Comments
  • ABAP Development Tools for Eclipse on Ubuntu Desktop

    Recently, I noticed a sentence on the SAP Development Tools website stating that you don’t need an SAP GUI for ABAP…

    8 Comments
  • 4 experiences with FINAL in ABAP

    With the declaration operator FINAL, you can create immutable variables in ABAP. This means that a variable is…

    9 Comments
  • Thoughts about taking data records out of use

    Dear developer community, "taking data records out of use" is a common topic in IT. Many applications require such a…

  • Markdown table via ABAP CDS and ABAP SQL

    Dear SAP Community, since I really appreciate Markdown and you can easily design tables with it, I was wondering…

    4 Comments

Others also viewed

Explore content categories