Skip to content

Commit 7e49c5f

Browse files
authored
Merge pull request #292 from SAP/1.11.0
1.11.0
2 parents 7903ab6 + 3bcf450 commit 7e49c5f

File tree

80 files changed

+1727
-1839
lines changed

Some content is hidden

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

80 files changed

+1727
-1839
lines changed

changelog.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ Upgrade Note
1212
------------------
1313
Whenever you upgrade code pal for ABAP, it is highly recommended to execute the Y_CI_CHECK_REGISTRATION report to activate/reactivate the Checks (SE38 transaction) and regenerate the respective code inspector variant (SCI transaction)
1414

15+
2021-01-18 v1.11.0
16+
------------------
17+
* CHECK position after comments (#301)
18+
* Modify an Internal Table is no DB Access (#300)
19+
+ Enhancing coverage to run for multiple objects (#294)
20+
! Disabling profiles when the API executes the regression (#293)
21+
* DELETE from internal table gives a "Database access" prio 1 error (#290)
22+
! The pseudo comment position of the Form Routine Check was moved from the 'ENDFORM' to 'FORM' statement
23+
! The pseudo comment position of the Number of Public Attributes was moved from the 'CLASS DEFINITION.' to 'PUBLIC SECTION' statement
24+
1525
2020-12-14 v1.10.0
1626
------------------
1727
+ New Check: Scope of the Variable (#276)

docs/checks/form-routine.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ Use classes and methods instead. Methods are similar to subroutines and can be u
2323
### What to do in case of exception?
2424

2525
You can suppress Code Inspector findings generated by this check using the pseudo comment `"#EC CI_FORM`.
26-
The pseudo comment must be placed right after the `ENDFORM`.
26+
The pseudo comment must be placed right after the `FORM` declaration.
2727

2828
```abap
29-
FORM my_form.
29+
FORM my_form. "#EC CI_FORM
3030
" Form content
31-
ENDFORM. "#EC CI_FORM
31+
ENDFORM.
3232
```
3333

3434
### Further Readings & Knowledge

docs/checks/number-public-attributes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ Make those attributes `PRIVATE` or `PROTECTED`. You can grant the read access wi
2323
### What to do in case of exception?
2424

2525
You can suppress Code Inspector findings generated by this check using the pseudo comment `"#EC NUM_PUBLIC_ATTR`.
26-
The pseudo comment must be placed right after the class definition header.
26+
The pseudo comment must be placed right after the `PUBLIC SECTION` statement.
2727

2828
```abap
29-
CLASS class_name DEFINITION. "#EC NUM_PUBLIC_ATTR
30-
PUBLIC SECTION.
29+
CLASS class_name DEFINITION.
30+
PUBLIC SECTION. "#EC NUM_PUBLIC_ATTR
3131
DATA attribute1 TYPE i.
3232
DATA attribute2 TYPE i.
3333
ENDCLASS.

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: 10 additions & 3 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

@@ -34,11 +36,14 @@ CLASS y_check_branch_coverage IMPLEMENTATION.
3436
DATA(coverage) = y_unit_test_coverage=>get( program_name = program_name
3537
object = VALUE #( object = object_type obj_name = object_name )
3638
coverage_type = ce_scv_coverage_type=>branch ).
39+
40+
DATA(branch) = round( val = coverage->get_percentage( )
41+
dec = 2 ).
3742
CATCH cx_scv_execution_error.
3843
RETURN.
3944
ENDTRY.
4045

41-
DATA(check_configuration) = detect_check_configuration( error_count = CONV #( coverage )
46+
DATA(check_configuration) = detect_check_configuration( error_count = CONV #( branch )
4247
statement = VALUE #( level = 1 ) ).
4348

4449
IF check_configuration IS INITIAL.
@@ -49,8 +54,10 @@ CLASS y_check_branch_coverage IMPLEMENTATION.
4954
statement_index = 1
5055
statement_from = 1
5156
error_priority = check_configuration-prio
52-
parameter_01 = |{ coverage }|
53-
parameter_02 = |{ check_configuration-threshold }| ).
57+
parameter_01 = |{ branch }|
58+
parameter_02 = |{ check_configuration-threshold }|
59+
parameter_03 = |{ coverage->get_total( ) }|
60+
parameter_04 = |{ coverage->get_executed( ) }| ).
5461

5562
ENDMETHOD.
5663

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: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,24 @@ CLASS y_check_check_stmnt_position IMPLEMENTATION.
6666
OR token EQ 'DATA'
6767
OR token EQ 'TYPES'
6868
OR token EQ 'CHECK'
69-
OR token EQ 'FIELD-SYMBOLS' ).
69+
OR token EQ 'FIELD-SYMBOLS'
70+
OR token EQ 'CONSTANTS' ).
7071
ENDMETHOD.
7172

7273

7374
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>)
75+
LOOP AT ref_scan_manager->statements ASSIGNING FIELD-SYMBOL(<statement>)
7776
FROM structure-stmnt_from TO structure-stmnt_to.
77+
IF <statement>-type = scan_stmnt_type-empty
78+
OR <statement>-type = scan_stmnt_type-comment
79+
OR <statement>-type = scan_stmnt_type-comment_in_stmnt.
80+
CONTINUE.
81+
ENDIF.
82+
7883
IF <statement>-number = check-number.
7984
RETURN.
8085
ENDIF.
86+
8187
IF is_not_relevant_token( get_token_abs( <statement>-from ) ) = abap_false.
8288
result = abap_true.
8389
RETURN.
@@ -87,7 +93,7 @@ CLASS y_check_check_stmnt_position IMPLEMENTATION.
8793

8894

8995
METHOD is_check_in_loop.
90-
LOOP AT ref_scan_manager->get_tokens( ) ASSIGNING FIELD-SYMBOL(<token>)
96+
LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL(<token>)
9197
FROM structure-stmnt_from TO check-from
9298
WHERE str = 'LOOP'
9399
OR str = 'ENDLOOP'.

0 commit comments

Comments
 (0)