Skip to content

Prefer New: Dynamic Call with Parameters #503

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

Merged
merged 2 commits into from
Oct 27, 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-08-XX v.1.16.0
------------------
* Prefer New: Dynamic Call with Parameters (#502)
* DB Access in UT: Global Inheritance (#500)
* DB Access in UT: Local Inheritance (#498)
* Skip 'Prefer RETURNING to EXPORTING' when both exist (#490)
Expand Down
5 changes: 3 additions & 2 deletions src/checks/y_check_prefer_new_to_crt_obj.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ CLASS y_check_prefer_new_to_crt_obj IMPLEMENTATION.
AND get_token_abs( statement-from + 1 ) = 'OBJECT'.

CHECK get_token_abs( statement-to - 1 ) <> 'FOR'
AND get_token_abs( statement-to ) <> 'TESTING'
AND get_token_abs( statement-to ) NA '()'.
AND get_token_abs( statement-to ) <> 'TESTING'.

CHECK next1( 'TYPE' ) NA '()'.

DATA(check_configuration) = detect_check_configuration( statement ).

Expand Down
23 changes: 23 additions & 0 deletions src/checks/y_check_prefer_new_to_crt_obj.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,29 @@ CLASS ltc_create_object IMPLEMENTATION.
ENDCLASS.



CLASS ltc_dynamic_object_with_param DEFINITION INHERITING FROM ltc_create_object FOR TESTING RISK LEVEL HARMLESS DURATION SHORT.
PROTECTED SECTION.
METHODS get_code_without_issue REDEFINITION.
ENDCLASS.

CLASS ltc_dynamic_object_with_param IMPLEMENTATION.

METHOD get_code_without_issue.
result = VALUE #(
( ' REPORT ut_test.' )
( ' START-OF-SELECTION.' )
( | DATA check TYPE REF TO y_check_base. | )
( | DATA params TYPE abap_parmbind_tab. | )
( | DATA(prefer_new) = 'y_check_prefer_new_to_crt_obj'. | )
( | CREATE OBJECT check TYPE (prefer_new) PARAMETER-TABLE params. | )
).
ENDMETHOD.

ENDCLASS.



CLASS ltc_dynamic_object DEFINITION INHERITING FROM ltc_create_object FOR TESTING RISK LEVEL HARMLESS DURATION SHORT.
PROTECTED SECTION.
METHODS get_code_without_issue REDEFINITION.
Expand Down