abaplint Rules

website·Indexed 32 days ago

https://rules.abaplint.org/

Documentation for abaplint static analysis rules, covering coding conventions, performance optimizations, and error detection for ABAP code, including checks for unreachable code, unused variables, and naming conventions.

Tokens
17.1K
Snippets
8
Records
240
Agent score
62%

What's inside abaplint

  1. Identify and refactor short CASE statements using abaplint

    The short_case rule checks for CASE statements that contain fewer than a specified number of branches. When a CASE construct is too short, it is generally recommended to refactor it into an IF statement for better readability and conciseness.
  2. Enforce statement alignment with the start_at_tab rule

    The start_at_tab rule in abaplint ensures that ABAP statements begin at valid tabstops, adhering to indentation standards. This rule is aligned with the Clean ABAP style guide regarding indentation and snapping to tabs. To prevent performance degradation or log flooding, the rule reports a maximum of 100 issues per file.
  3. Identify redundant database table indexes using index_completely_contained

    The index_completely_contained rule in abaplint detects database table indexes that are completely contained within other indexes. Redundant indexes should be removed to improve overall database performance.
  4. Use interfaces instead of abstract classes for constant-only definitions

    When a class is used solely to define constants, it is recommended to use an interface instead of an abstract class.
  5. Use xsdbool instead of boolc for boolean assignments

    The prefer_xsdbool rule in abaplint enforces the use of the xsdbool operator over boolc when setting boolean variables. This rule is active for ABAP language versions v740sp08 or higher and aligns with Clean ABAP style guidelines.
  6. Use string templates instead of && for text assembly in abaplint

    The prefer_string_template rule enforces the use of string templates instead of the chaining operator && when assembling text. This aligns with Clean ABAP style guidelines to improve readability and maintainability of string concatenations.
  7. Suppress unused method warnings using Pragmas

    To suppress warnings from the unused_methods rule for a specific method, use the ##CALLED pragma or the EC CALLED pseudo comment.
    METHOD my_unused_method.
      ##CALLED
    ENDMETHOD.
    
  8. Prevent local TABLES declarations with the tables_declared_locally rule

    The tables_declared_locally rule ensures that TABLES statements are declared globally. Because TABLES are always global in ABAP, declaring them locally is incorrect and should be avoided.
  9. Enforce omission of RECEIVING in method signatures using abaplint

    The omit_receiving rule in abaplint ensures that the RECEIVING addition is omitted from method signatures. This aligns with the Clean ABAP style guide, which recommends avoiding redundant keywords to keep code concise.
  10. Use INSERT INTO TABLE instead of APPEND for internal tables

    When adding entries to an internal table, prefer using INSERT INTO TABLE over APPEND. While APPEND always attempts to add a record to the end of the table, INSERT INTO TABLE respects the specific table type. Using APPEND on a sorted table can cause a runtime error (dump) if the operation would violate the table's sort order.
  11. Expand ABAP macro calls using the expand_macros rule

    The expand_macros rule in abaplint allows developers to expand macro calls within their code using available quick fixes. Note that macros defined via DEFINE are not supported in the ABAP Cloud programming model.
  12. Avoid inline declarations in optional branches (abaplint)

    The no_inline_in_optional_branches rule prevents the use of inline declarations within blocks of code that may not be executed. This ensures that variables are declared in a predictable scope and avoids potential issues where a variable is used later in the code but was never actually declared because the optional branch was skipped.

    Considered optional branches (where inline declarations are forbidden):

    • IF, ELSEIF, ELSE blocks
    • LOOP blocks
    • WHILE blocks
    • CASE, WHEN, and CASE TYPE OF blocks
    • DO blocks
    • SELECT loops

    Exceptions:

    • TRY, CATCH, and CLEANUP blocks are not considered optional branches and allow inline declarations.