Exclude Checks for Test Code
Nobody has claimed this yet.
- 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_TABof the classY_CHECK_BASEit 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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