Skip to content

Commit 47c95dc

Browse files
authored
Check now both on ASSERT and CHECK issue #610 (#612)
* Check now both on ASSERT and CHECK issue #610 Added test to check that both ASSERT and CHECK is checked. Removed filter in constructor. Added filter to where condition in loop in inspect_tokens * Check now both on ASSERT and CHECK issue #610 Change the test class to move the ASSERT and CHECK to the 2nd and 3th * Check now both on ASSERT and CHECK issue #610 Error in test for check
1 parent 58e9f75 commit 47c95dc

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

src/checks/y_check_prefer_is_not.clas.abap

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ CLASS y_check_prefer_is_not IMPLEMENTATION.
4343
settings-threshold = 0.
4444
settings-documentation = |{ c_docs_path-checks }prefer-is-not-to-not-is.md|.
4545

46-
relevant_statement_types = VALUE #( ( scan_struc_stmnt_type-if ) ).
47-
relevant_structure_types = VALUE #( ).
48-
4946
set_check_message( 'Prefer IS NOT to NOT IS!' ).
5047
ENDMETHOD.
5148

@@ -56,7 +53,8 @@ CLASS y_check_prefer_is_not IMPLEMENTATION.
5653
OR str = 'ELSEIF'
5754
OR str = 'AND'
5855
OR str = 'OR'
59-
OR str = 'ASSERT'.
56+
OR str = 'ASSERT'
57+
or str = 'CHECK'.
6058

6159
DATA(position) = sy-tabix.
6260

@@ -147,4 +145,4 @@ CLASS y_check_prefer_is_not IMPLEMENTATION.
147145
ENDWHILE.
148146
ENDMETHOD.
149147

150-
ENDCLASS.
148+
ENDCLASS.

src/checks/y_check_prefer_is_not.clas.testclasses.abap

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,44 @@ CLASS ltc_not_is_initial IMPLEMENTATION.
5050

5151
ENDCLASS.
5252

53+
CLASS ltc_assert DEFINITION INHERITING FROM ltc_not_is_initial FOR TESTING RISK LEVEL HARMLESS DURATION SHORT.
54+
PROTECTED SECTION.
55+
METHODS get_code_with_issue REDEFINITION.
56+
ENDCLASS.
57+
58+
CLASS ltc_assert IMPLEMENTATION.
59+
60+
METHOD get_code_with_issue.
61+
result = VALUE #(
62+
( 'REPORT y_example. ' )
63+
64+
( ' START-OF-SELECTION. ' )
65+
( ' DATA(count) = 0. ' )
66+
( ' ASSERT NOT count IS INITIAL. ' )
67+
).
68+
ENDMETHOD.
69+
70+
ENDCLASS.
71+
72+
CLASS ltc_check DEFINITION INHERITING FROM ltc_not_is_initial FOR TESTING RISK LEVEL HARMLESS DURATION SHORT.
73+
PROTECTED SECTION.
74+
METHODS get_code_with_issue REDEFINITION.
75+
ENDCLASS.
76+
77+
CLASS ltc_check IMPLEMENTATION.
78+
79+
METHOD get_code_with_issue.
80+
result = VALUE #(
81+
( 'REPORT y_example. ' )
82+
83+
( ' START-OF-SELECTION. ' )
84+
( ' DATA(count) = 0. ' )
85+
( ' CHECK NOT count IS INITIAL. ' )
86+
).
87+
ENDMETHOD.
88+
89+
ENDCLASS.
90+
5391
CLASS ltc_not_contains_pattern DEFINITION INHERITING FROM y_unit_test_base FOR TESTING RISK LEVEL HARMLESS DURATION SHORT.
5492
PROTECTED SECTION.
5593
METHODS get_cut REDEFINITION.
@@ -698,4 +736,4 @@ CLASS ltc_method_return_structure IMPLEMENTATION.
698736
).
699737
ENDMETHOD.
700738

701-
ENDCLASS.
739+
ENDCLASS.

0 commit comments

Comments
 (0)