Skip to content

Commit e9cb839

Browse files
committed
saving progress
solves #295 probably solves #296 changes pseudo comment position (must adjust documentation as well) new attributs to handle relevant statement/structure types
1 parent 0aabce5 commit e9cb839

File tree

62 files changed

+1171
-1474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1171
-1474
lines changed

src/checks/y_check_boolean_input_param.clas.abap

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
CLASS y_check_boolean_input_param DEFINITION PUBLIC INHERITING FROM y_check_base CREATE PUBLIC .
22
PUBLIC SECTION.
33
METHODS constructor.
4+
45
PROTECTED SECTION.
5-
METHODS execute_check REDEFINITION.
66
METHODS inspect_tokens REDEFINITION.
7+
78
PRIVATE SECTION.
89
METHODS is_setter_method IMPORTING statement TYPE sstmnt
910
RETURNING VALUE(result) TYPE abap_bool.
11+
1012
METHODS has_boolean_input_param IMPORTING statement TYPE sstmnt
1113
RETURNING VALUE(result) TYPE abap_bool.
1214
ENDCLASS.
1315

1416

1517
CLASS y_check_boolean_input_param IMPLEMENTATION.
1618

19+
1720
METHOD constructor.
1821
super->constructor( ).
1922

@@ -22,35 +25,12 @@ CLASS y_check_boolean_input_param IMPLEMENTATION.
2225
settings-threshold = 0.
2326
settings-documentation = |{ c_docs_path-checks }boolean-input-parameter.md|.
2427

28+
relevant_statement_types = VALUE #( ( scan_struc_stmnt_type-class_definition ) ).
29+
relevant_structure_types = VALUE #( ).
30+
2531
set_check_message( 'Split method instead of Boolean input parameter!' ).
2632
ENDMETHOD.
2733

28-
METHOD execute_check.
29-
LOOP AT ref_scan_manager->get_structures( ) ASSIGNING FIELD-SYMBOL(<structure>)
30-
WHERE stmnt_type = scan_struc_stmnt_type-class_definition.
31-
32-
is_testcode = test_code_detector->is_testcode( <structure> ).
33-
34-
TRY.
35-
DATA(check_configuration) = check_configurations[ apply_on_testcode = abap_true ].
36-
CATCH cx_sy_itab_line_not_found.
37-
IF is_testcode EQ abap_true.
38-
CONTINUE.
39-
ENDIF.
40-
ENDTRY.
41-
42-
DATA(index) = <structure>-stmnt_from.
43-
44-
LOOP AT ref_scan_manager->get_statements( ) ASSIGNING FIELD-SYMBOL(<statement>)
45-
FROM <structure>-stmnt_from TO <structure>-stmnt_to.
46-
47-
inspect_tokens( index = index
48-
structure = <structure>
49-
statement = <statement> ).
50-
index = index + 1.
51-
ENDLOOP.
52-
ENDLOOP.
53-
ENDMETHOD.
5434

5535
METHOD inspect_tokens.
5636

@@ -71,14 +51,16 @@ CLASS y_check_boolean_input_param IMPLEMENTATION.
7151

7252
ENDMETHOD.
7353

54+
7455
METHOD is_setter_method.
7556
DATA(method_name) = get_token_abs( statement-from + 1 ).
7657
result = COND #( WHEN method_name CS 'SET_' THEN abap_true ).
7758
ENDMETHOD.
7859

60+
7961
METHOD has_boolean_input_param.
8062
DATA(skip) = abap_true.
81-
LOOP AT ref_scan_manager->get_tokens( ) ASSIGNING FIELD-SYMBOL(<token>)
63+
LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL(<token>)
8264
FROM statement-from TO statement-to.
8365

8466
IF <token>-str = 'IMPORTING'.
@@ -101,4 +83,5 @@ CLASS y_check_boolean_input_param IMPLEMENTATION.
10183
ENDLOOP.
10284
ENDMETHOD.
10385

86+
10487
ENDCLASS.

src/checks/y_check_branch_coverage.clas.abap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
CLASS y_check_branch_coverage DEFINITION PUBLIC INHERITING FROM y_check_base CREATE PUBLIC .
22
PUBLIC SECTION.
33
METHODS constructor.
4+
45
PROTECTED SECTION.
56
METHODS execute_check REDEFINITION.
67
METHODS inspect_tokens REDEFINITION.
8+
79
ENDCLASS.
810

911

src/checks/y_check_call_method_usage.clas.abap

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
CLASS y_check_call_method_usage DEFINITION
2-
PUBLIC
3-
INHERITING FROM y_check_base
4-
CREATE PUBLIC .
5-
1+
CLASS y_check_call_method_usage DEFINITION PUBLIC INHERITING FROM y_check_base CREATE PUBLIC .
62
PUBLIC SECTION.
73
METHODS constructor .
4+
85
PROTECTED SECTION.
96
METHODS inspect_tokens REDEFINITION.
10-
PRIVATE SECTION.
7+
118
ENDCLASS.
129

1310

@@ -49,4 +46,6 @@ CLASS y_check_call_method_usage IMPLEMENTATION.
4946
error_priority = check_configuration-prio ).
5047
ENDIF.
5148
ENDMETHOD.
49+
50+
5251
ENDCLASS.

src/checks/y_check_chain_decl_usage.clas.abap

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
CLASS y_check_chain_decl_usage DEFINITION PUBLIC INHERITING FROM y_check_base CREATE PUBLIC .
1+
CLASS y_check_chain_decl_usage DEFINITION PUBLIC INHERITING FROM y_check_base CREATE PUBLIC.
22
PUBLIC SECTION.
33
METHODS constructor.
4+
45
PROTECTED SECTION.
56
METHODS inspect_tokens REDEFINITION.
7+
68
PRIVATE SECTION.
79
DATA rows_with_colon TYPE STANDARD TABLE OF stmnt_crow.
10+
811
METHODS has_error_not_raised_yet IMPORTING statement TYPE sstmnt RETURNING VALUE(result) TYPE abap_bool.
12+
913
ENDCLASS.
1014

1115

src/checks/y_check_check_in_loop.clas.abap

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ CLASS y_check_check_in_loop DEFINITION PUBLIC INHERITING FROM y_check_base CREAT
33
METHODS constructor .
44

55
PROTECTED SECTION.
6-
METHODS execute_check REDEFINITION.
76
METHODS inspect_tokens REDEFINITION.
87

98
PRIVATE SECTION.
@@ -25,35 +24,10 @@ CLASS y_check_check_in_loop IMPLEMENTATION.
2524
settings-threshold = 0.
2625
settings-documentation = |{ c_docs_path-checks }check-in-loop.md|.
2726

28-
set_check_message( 'Use an IF statement in combination with CONTINUE instead CHECK!' ).
29-
ENDMETHOD.
30-
31-
32-
METHOD execute_check.
33-
LOOP AT ref_scan_manager->get_structures( ) ASSIGNING FIELD-SYMBOL(<structure>)
34-
WHERE stmnt_type EQ scan_struc_stmnt_type-check.
35-
36-
is_testcode = test_code_detector->is_testcode( <structure> ).
27+
relevant_statement_types = VALUE #( ( scan_struc_stmnt_type-check ) ).
28+
relevant_structure_types = VALUE #( ).
3729

38-
TRY.
39-
DATA(check_configuration) = check_configurations[ apply_on_testcode = abap_true ].
40-
CATCH cx_sy_itab_line_not_found.
41-
IF is_testcode EQ abap_true.
42-
CONTINUE.
43-
ENDIF.
44-
ENDTRY.
45-
46-
DATA(index) = <structure>-stmnt_from.
47-
48-
LOOP AT ref_scan_manager->get_statements( ) ASSIGNING FIELD-SYMBOL(<statement>)
49-
FROM <structure>-stmnt_from TO <structure>-stmnt_to.
50-
51-
inspect_tokens( index = index
52-
structure = <structure>
53-
statement = <statement> ).
54-
index = index + 1.
55-
ENDLOOP.
56-
ENDLOOP.
30+
set_check_message( 'Use an IF statement in combination with CONTINUE instead CHECK!' ).
5731
ENDMETHOD.
5832

5933

@@ -75,12 +49,9 @@ CLASS y_check_check_in_loop IMPLEMENTATION.
7549

7650

7751
METHOD get_back_statement.
78-
DATA(structures) = ref_scan_manager->get_structures( ).
79-
DATA(statements) = ref_scan_manager->get_statements( ).
80-
8152
TRY.
82-
DATA(back_structure) = structures[ structure-back ].
83-
result = statements[ back_structure-stmnt_from ].
53+
DATA(back_structure) = ref_scan_manager->structures[ structure-back ].
54+
result = ref_scan_manager->statements[ back_structure-stmnt_from ].
8455
CATCH cx_sy_itab_line_not_found.
8556
CLEAR result.
8657
ENDTRY.

src/checks/y_check_check_stmnt_position.clas.abap

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ CLASS y_check_check_stmnt_position IMPLEMENTATION.
7171

7272

7373
METHOD has_wrong_position.
74-
DATA(statements) = ref_scan_manager->get_statements( ).
75-
76-
LOOP AT ref_scan_manager->get_statements( ) ASSIGNING FIELD-SYMBOL(<statement>)
74+
LOOP AT ref_scan_manager->statements ASSIGNING FIELD-SYMBOL(<statement>)
7775
FROM structure-stmnt_from TO structure-stmnt_to.
7876
IF <statement>-number = check-number.
7977
RETURN.
@@ -87,7 +85,7 @@ CLASS y_check_check_stmnt_position IMPLEMENTATION.
8785

8886

8987
METHOD is_check_in_loop.
90-
LOOP AT ref_scan_manager->get_tokens( ) ASSIGNING FIELD-SYMBOL(<token>)
88+
LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL(<token>)
9189
FROM structure-stmnt_from TO check-from
9290
WHERE str = 'LOOP'
9391
OR str = 'ENDLOOP'.

src/checks/y_check_comment_position.clas.abap

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,9 @@ CLASS Y_CHECK_COMMENT_POSITION IMPLEMENTATION.
6363

6464

6565
METHOD has_wrong_position.
66-
DATA(tokens) = ref_scan_manager->get_tokens( ).
67-
6866
TRY.
69-
DATA(previous_token) = tokens[ statement-to - 1 ].
70-
DATA(current_token) = tokens[ statement-to ].
67+
DATA(previous_token) = ref_scan_manager->tokens[ statement-to - 1 ].
68+
DATA(current_token) = ref_scan_manager->tokens[ statement-to ].
7169
CATCH cx_sy_itab_line_not_found.
7270
RETURN.
7371
ENDTRY.
@@ -132,9 +130,8 @@ CLASS Y_CHECK_COMMENT_POSITION IMPLEMENTATION.
132130

133131

134132
METHOD get_next_token.
135-
DATA(tokens) = ref_scan_manager->get_tokens( ).
136133
DATA(next_position) = current_position + 1.
137-
result = tokens[ next_position ].
134+
result = ref_scan_manager->tokens[ next_position ].
138135
IF is_pragma( result ) = abap_true.
139136
result = get_next_token( next_position ).
140137
ENDIF.

src/checks/y_check_comment_type.clas.abap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ CLASS y_check_comment_type IMPLEMENTATION.
4040
ENDMETHOD.
4141

4242
METHOD has_wrong_comment_type.
43-
LOOP AT ref_scan_manager->get_tokens( ) ASSIGNING FIELD-SYMBOL(<token>)
43+
LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL(<token>)
4444
FROM statement-from TO statement-to.
4545
IF get_first_character( <token> ) = '*'
4646
AND get_second_character( <token> ) <> '&'.

0 commit comments

Comments
 (0)