Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB Access in UT: False Positive #513

Merged
merged 3 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Legend

2021-11-03 v.1.16.1
------------------
* DB Access in UT: False Positive (#513)

2021-11-01 v.1.16.0
------------------
Expand Down
18 changes: 12 additions & 6 deletions src/checks/y_check_db_access_in_ut.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ CLASS y_check_db_access_in_ut DEFINITION PUBLIC INHERITING FROM y_check_base CRE
END OF keys.

TYPES: BEGIN OF properties,
name TYPE string,
program_name TYPE string,
class_name TYPE string,
risk_level TYPE string,
has_framework TYPE abap_bool,
END OF properties.
Expand Down Expand Up @@ -128,12 +129,14 @@ CLASS Y_CHECK_DB_ACCESS_IN_UT IMPLEMENTATION.

METHOD add_line_to_defined_classes.
TRY.
DATA(class_config) = VALUE properties( name = get_class_name( structure ) ).
DATA(class_config) = VALUE properties( program_name = program_name
class_name = get_class_name( structure ) ).
CATCH cx_sy_itab_line_not_found.
RETURN.
ENDTRY.

IF line_exists( defined_classes[ name = class_config-name ] ).
IF line_exists( defined_classes[ program_name = program_name
class_name = class_config-class_name ] ).
RETURN.
ENDIF.

Expand Down Expand Up @@ -191,7 +194,8 @@ CLASS Y_CHECK_DB_ACCESS_IN_UT IMPLEMENTATION.
RETURN.
ENDIF.

DATA(defined_superclass) = VALUE #( defined_classes[ name = superclass ] OPTIONAL ).
DATA(defined_superclass) = VALUE #( defined_classes[ program_name = program_name
class_name = superclass ] OPTIONAL ).

" Avoiding false-positives (inheriting from global class which is out of scan scope)
result = xsdbool( defined_superclass-has_framework = abap_true
Expand All @@ -206,7 +210,8 @@ CLASS Y_CHECK_DB_ACCESS_IN_UT IMPLEMENTATION.
RETURN.
ENDTRY.

IF NOT line_exists( defined_classes[ name = class_name
IF NOT line_exists( defined_classes[ program_name = program_name
class_name = class_name
has_framework = abap_false ] ).
RETURN.
ENDIF.
Expand Down Expand Up @@ -238,7 +243,8 @@ CLASS Y_CHECK_DB_ACCESS_IN_UT IMPLEMENTATION.


METHOD get_forbidden_tokens.
DATA(class) = VALUE #( defined_classes[ name = class_name ] OPTIONAL ).
DATA(class) = VALUE #( defined_classes[ program_name = program_name
class_name = class_name ] OPTIONAL ).

DATA(risk_lvl) = COND #( WHEN class IS NOT INITIAL THEN class-risk_level
ELSE space ).
Expand Down