SAP / SAP/code-pal-for-abap

Exclude Checks for Test Code

Open Beginner friendly
#628 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
ABAP
Stars
435
Forks
77
PR merge metrics
No merged PRs in 30d

Description

Check Name

Empty Catch
Number of Public Attributes

Actual Behavior

Although the checks are set up for production code only (we exluded the test code for these checks), we keep receiving findings from unit tests.

Expected Behavior

Exclude unit tests from these checks according to the configuration.

Possible solution

In the method IS_STATEMENT_IN_AUNIT_TAB of the class Y_CHECK_BASE it is assumed that the table for unit tests is already filled which is not the case.

TRY.
    " Local Test Class
    aunit = ref_scan->aunit_tab[ incl_name = include ].
  CATCH cx_sy_itab_line_not_found.
    " Global Test Class
    aunit = ref_scan->aunit_tab[ incl_name = program_name ].
ENDTRY.

One possible solution could be adding

IF ref_scan->aunit_tab_determined = abap_false.
  ref_scan->determine_aunit_lines( ).
ENDIF.

into the method INSTANTIATE_OBJECTS of the same class after the verification IF ref_scan IS INITIAL.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in class Y_CHECK_BASE, inspect INSTANTIATE_OBJECTS and IS_STATEMENT_IN_AUNIT_TAB, and trace how ref_scan and aunit_tab are used for local and global test classes. Verify the behavior for the Empty Catch and Number of Public Attributes checks, ensuring configured unit-test exclusions no longer produce findings.

Written by the indexing model from the issue text.

Assessment

Domain
testing-qa, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.