Skip to content

Commit a86f9d1

Browse files
authored
1.16.0 (#440)
2021-11-01 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) * Pseudo Comment Usage: Multiple Inline Entries (#494) * Prefer Pragmas to Pseudo Comments: Multiple Pseudo Comments (#489) * Y_CHECK_MESSAGE_EASY_TO_FIND dump (#492) * Chain Declaration for Complex Structures (#488) * Empty Catch Alternative Pseudo Comment (#337) + Alternative Pseudo Comment (#486) * line_exists does not support the operator IN (#484) * Empty Catch: Test Double Framework (#483) * Y_CHECK_FORM: Screen Events (#454) * Magic Number: CASE SY-TABIX and CO NUMBERS (#480) * Magic Number: Leading Zeros (#479) * Prefer New to Create Object: Dynamic Type (#469) * Magic Number: Table Index (#468) * Use native *_wa variables (#474) * Refactoring (#436,#452,#458) * Cannot run unit tests on 752 (#461) * Profiles: Allow Exemptions (#447) * BAdI example class vs Percentage Comment (#443) * Unit-Test Assert Validator (#450) + Prefer Pragmas to Pseudo Comments (#421) + COLLECT restriction (#441) * RAP needs CREATE OBJECT ... FOR TESTING (#444) * Filter functional operands in "Unit Test Assert" check (#460)
1 parent a77fb07 commit a86f9d1

File tree

121 files changed

+3621
-2302
lines changed

Some content is hidden

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

121 files changed

+3621
-2302
lines changed

Diff for: .cspell.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
"msgid",
5252
"msgty",
5353
"msgno",
54-
"UNDETEC"
54+
"UNDETEC",
55+
"SLIN"
5556
],
5657
// flagWords - list of words to be always considered incorrect
5758
// This is useful for offensive words and common spelling errors.

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Together, we both support you in writing a clean ABAP code.
3535

3636
- SAP NetWeaver **7.40 SP8** or higher
3737
- [abapGit](https://docs.abapgit.org/)
38+
- :new: [SAP Note 2527903 - Remote analysis (for check system)](https://launchpad.support.sap.com/#/notes/2527903)
3839

3940
## How-to Guides
4041

Diff for: abaplint.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"check_include": true,
3838
"check_no_handler_pragma": true,
3939
"check_subrc": false,
40-
"check_syntax": true,
40+
"check_syntax": false,
4141
"check_text_elements": false,
4242
"check_transformation_exists": false,
4343
"class_attribute_names": false,
@@ -125,7 +125,7 @@
125125
"parser_702_chaining": false,
126126
"parser_error": true,
127127
"parser_missing_space": true,
128-
"prefer_inline": false,
128+
"prefer_inline": true,
129129
"prefer_is_not": true,
130130
"prefer_raise_exception_new": true,
131131
"prefer_returning_to_exporting": true,

Diff for: changelog.txt

+38-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,50 @@
11
code-pal-for-abap changelog
22
=================
33

4+
Dependencies
5+
------------------
6+
1. SAP Note 2527903 - Remote analysis (for check system)
7+
8+
Upgrade Note
9+
------------------
10+
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)
11+
412
Legend
5-
------
13+
------------------
614
* : fixed
715
! : changed
816
+ : added
917
- : removed
1018

11-
Upgrade Note
12-
------------------
13-
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)
19+
2021-11-01 v.1.16.0
20+
------------------
21+
* Prefer New: Dynamic Call with Parameters (#502)
22+
* DB Access in UT: Global Inheritance (#500)
23+
* DB Access in UT: Local Inheritance (#498)
24+
* Skip 'Prefer RETURNING to EXPORTING' when both exist (#490)
25+
* Pseudo Comment Usage: Multiple Inline Entries (#494)
26+
* Prefer Pragmas to Pseudo Comments: Multiple Pseudo Comments (#489)
27+
* Y_CHECK_MESSAGE_EASY_TO_FIND dump (#492)
28+
* Chain Declaration for Complex Structures (#488)
29+
* Empty Catch Alternative Pseudo Comment (#337)
30+
+ Alternative Pseudo Comment (#486)
31+
* line_exists does not support the operator IN (#484)
32+
* Empty Catch: Test Double Framework (#483)
33+
* Y_CHECK_FORM: Screen Events (#454)
34+
* Magic Number: CASE SY-TABIX and CO NUMBERS (#480)
35+
* Magic Number: Leading Zeros (#479)
36+
* Prefer New to Create Object: Dynamic Type (#469)
37+
* Magic Number: Table Index (#468)
38+
* Use native *_wa variables (#474)
39+
* Refactoring (#436,#452,#458)
40+
* Cannot run unit tests on 752 (#461)
41+
* Profiles: Allow Exemptions (#447)
42+
* BAdI example class vs Percentage Comment (#443)
43+
* Unit-Test Assert Validator (#450)
44+
+ Prefer Pragmas to Pseudo Comments (#421)
45+
+ COLLECT restriction (#441)
46+
* RAP needs CREATE OBJECT ... FOR TESTING (#444)
47+
* Filter functional operands in "Unit Test Assert" check (#460)
1448

1549
2021-08-12 v.1.15.0
1650
------------------

Diff for: docs/check_documentation.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [Chain Declaration Usage](checks/chain-declaration-usage.md)
1111
- [CHECK Statement Position](checks/check-statement-position.md)
1212
- [CHECK in LOOP](checks/check-in-loop.md)
13+
- [COLLECT restriction](checks/collect.md)
1314
- [Combination of Output Parameters](checks/method-output-parameter.md)
1415
- [Comment Position](checks/comment-position.md)
1516
- [Comment Type](checks/comment-type.md)
@@ -46,6 +47,7 @@
4647
- [Prefer IS NOT to NOT IS](checks/prefer-is-not-to-not-is.md)
4748
- [Prefer LINE_EXISTS or LINE_INDEX to READ TABLE or LOOP AT](checks/prefer-line-exists.md)
4849
- [Prefer NEW to CREATE OBJECT](checks/prefer-new-to-create-object.md)
50+
- [Prefer Pragma to Pseudo Comment](checks/prefer-pragmas-to-pseudo-comments.md)
4951
- [Pseudo Comment Usage](checks/pseudo-comment-usage.md)
5052
- [Omit Optional EXPORTING](checks/omit-optional-exporting.md)
5153
- [Optional Parameters](checks/optional-parameters.md)

Diff for: docs/checks/chain-declaration-usage.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Change the chain up-front declarations to inline declarations.
1212

1313
### What to do in case of exception?
1414

15-
In exceptional cases, you can suppress this finding by using the pseudo comment `"#EC CHAIN_DECL_USAG` which should be placed after the `DATA:` statement:
15+
In exceptional cases, you can suppress this finding by using the pseudo comment `"#EC CHAIN_DECL_USAG` which should be placed after the declaration statement:
1616

1717
```abap
1818
DATA: "#EC CHAIN_DECL_USAG
@@ -21,6 +21,18 @@ In exceptional cases, you can suppress this finding by using the pseudo comment
2121
client LIKE sy-mandt.
2222
```
2323

24+
```abap
25+
TYPES: "#EC CHAIN_DECL_USAG
26+
name TYPE string,
27+
json TYPE REF TO cl_abap_json.
28+
```
29+
30+
```abap
31+
CONSTANTS: "#EC CHAIN_DECL_USAG
32+
min_age TYPE i VALUE 18,
33+
min_name_size TYPE i VALUE 3.
34+
```
35+
2436
### Example
2537

2638
Before the check:

Diff for: docs/checks/collect.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
[code pal for ABAP](../../README.md) > [Documentation](../check_documentation.md) > [COLLECT restriction](collect.md)
2+
3+
## COLLECT restriction
4+
5+
### What is the Intent of the Check?
6+
7+
The [ABAP - Keyword Documentation](https://help.sap.com/doc/abapdocu_755_index_htm/7.55/en-US/abencollect_guidl.htm?file=abencollect_guidl.htm) says:
8+
> **Rule**
9+
>
10+
> Do not fill standard tables with collections of lines
11+
>
12+
> Only use the statement COLLECT for hashed tables or sorted tables with a unique key. Do not use it any more for standard tables.
13+
>
14+
> **Details**
15+
>
16+
> The statement COLLECT is based on unique entries with respect to the primary key and stable key administration. This means that not all categories of internal tables are suitable for COLLECT:
17+
>
18+
> * If the statement COLLECT is applied to a standard table, this table first needs its own internal hash administration. Change operations on the table can invalidate this temporary hash administration. After a change operation of this type, the following COLLECT statements must resort to a linear search, which can affect performance considerably. The primary key of a standard table is also never unique.
19+
> * COLLECT can be used for sorted tables and hashed tables without any problems since these, unlike standard tables, always have a separate, stable key administration that can be utilized by COLLECT. COLLECT can work properly for sorted tables only if the primary key is unique. If a sorted table has a non-unique key, only COLLECT can be used to fill the table, which is difficult to guarantee. In hashed tables, the key values are always unique.
20+
21+
### How does the check work?
22+
23+
It searches for `COLLECT` in:
24+
* Internal tables typed as `SORTED TABLE` with `NON-UNIQUE KEY`;
25+
* Internal tables typed as `STANDARD TABLE`;
26+
27+
### How to solve the issue?
28+
29+
Change the internal table to `SORTED` or `HASHED` as recommended, or perform the collection manually.
30+
31+
### What to do in case of exception?
32+
33+
In exceptional cases, you can suppress this finding by using the pseudo comment `“#EC COLLECT` which should be placed after the `COLLECT` statement:
34+
35+
```abap
36+
COLLECT entry INTO table. "#EC COLLECT
37+
```
38+
39+
### Further Readings & Knowledge
40+
41+
* [ABAP - Keyword Documentation](https://help.sap.com/doc/abapdocu_755_index_htm/7.55/en-US/abencollect_guidl.htm?file=abencollect_guidl.htm)

Diff for: docs/checks/empty-catch.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,28 @@ Fill the `CATCH` block with an exception handling.
1212

1313
### What to do in case of exception?
1414

15-
In exceptional cases, you can suppress this finding by using the pseudo comment `"#EC EMPTY_CATCH` which should to be placed after the opening statement of the empty `CATCH`:
15+
In exceptional cases, you can suppress this finding by using the pseudo comment `"#EC EMPTY_CATCH` or `"#EC NO_HANDLER` which should to be placed after the opening statement of the empty `CATCH`:
1616

1717
```abap
1818
TRY.
1919
"some code
2020
CATCH cx_error. "#EC EMPTY_CATCH
2121
ENDTRY.
22+
```
2223

24+
```abap
2325
CATCH SYSTEM-EXCEPTIONS. "#EC EMPTY_CATCH
2426
ENDCATCH.
2527
```
28+
29+
```abap
30+
TRY.
31+
"some code
32+
CATCH cx_error. "#EC NO_HANDLER
33+
ENDTRY.
34+
```
35+
36+
```abap
37+
CATCH SYSTEM-EXCEPTIONS. "#EC NO_HANDLER
38+
ENDCATCH.
39+
```

Diff for: docs/checks/prefer-pragmas-to-pseudo-comments.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[code pal for ABAP](../../README.md) > [Documentation](../check_documentation.md) > [Prefer Pragmas to Pseudo Comments](prefer-pragmas-to-pseudo-comments.md)
2+
3+
## Prefer Pragmas to Pseudo Comments
4+
5+
### What is the Intent of the Check?
6+
7+
Based on the [Clean ABAP](https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-pragmas-to-pseudo-comments):
8+
> Prefer pragmas to pseudo comments to suppress irrelevant warnings and errors identified by the ATC. Pseudo comments have mostly become obsolete and have been replaced by pragmas
9+
10+
:bulb: Only the Pseudo Comments and Pragmas available in the `SLIN_DESC` table are in scope.
11+
12+
:wan: Code Pal does not support Pragmas.
13+
14+
### How to solve the issue?
15+
16+
Change the `"#EC ` (Pseudo Comment) to `##` (Pragma).
17+
18+
### What to do in case of exception?
19+
20+
This Check cannot be exempt.
21+
22+
### Example
23+
24+
Before the check:
25+
26+
```abap
27+
DATA a TYPE string. "#EC NEEDED
28+
```
29+
30+
After the check:
31+
32+
```abap
33+
DATA a TYPE string. ##NEEDED
34+
```
35+
36+
### Further Readings & Knowledge
37+
38+
* [Clean ABAP: Prefer pragmas to pseudo comments](https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-pragmas-to-pseudo-comments)
39+
* [ABAP - Keyword Documentation: Pseudo Comments for the Extended Program Check](https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abenpseudo_comment_slin.htm)

Diff for: src/checks/y_check_boolean_input_param.clas.abap

+3-7
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,10 @@ CLASS y_check_boolean_input_param IMPLEMENTATION.
4040

4141
DATA(configuration) = detect_check_configuration( statement ).
4242

43-
IF configuration IS INITIAL.
44-
RETURN.
45-
ENDIF.
46-
4743
raise_error( statement_level = statement-level
4844
statement_index = index
49-
statement_from = statement-from
50-
error_priority = configuration-prio ).
45+
statement_from = statement-from
46+
check_configuration = configuration ).
5147

5248
ENDMETHOD.
5349

@@ -60,7 +56,7 @@ CLASS y_check_boolean_input_param IMPLEMENTATION.
6056

6157
METHOD has_boolean_input_param.
6258
DATA(skip) = abap_true.
63-
LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL(<token>)
59+
LOOP AT ref_scan->tokens ASSIGNING FIELD-SYMBOL(<token>)
6460
FROM statement-from TO statement-to.
6561

6662
IF <token>-str = 'IMPORTING'.

Diff for: src/checks/y_check_branch_coverage.clas.abap

+11-11
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ CLASS y_check_branch_coverage IMPLEMENTATION.
3030

3131

3232
METHOD execute_check.
33-
3433
TRY.
3534
DATA(coverage) = y_unit_test_coverage=>get( program_name = program_name
3635
object = VALUE #( object = object_type obj_name = object_name )
@@ -42,22 +41,23 @@ CLASS y_check_branch_coverage IMPLEMENTATION.
4241
RETURN.
4342
ENDTRY.
4443

45-
DATA(check_configuration) = detect_check_configuration( error_count = CONV #( branch )
46-
statement = VALUE #( level = 1 ) ).
44+
TRY.
45+
DATA(first_statement) = ref_scan->statements[ 1 ].
46+
CATCH cx_sy_itab_line_not_found.
47+
RETURN.
48+
ENDTRY.
4749

48-
IF check_configuration IS INITIAL.
49-
RETURN.
50-
ENDIF.
50+
DATA(check_configuration) = detect_check_configuration( error_count = CONV #( branch )
51+
statement = first_statement ).
5152

52-
raise_error( statement_level = 1
53-
statement_index = 1
54-
statement_from = 1
55-
error_priority = check_configuration-prio
53+
raise_error( statement_level = first_statement-level
54+
statement_index = first_statement-from
55+
statement_from = first_statement-from
56+
check_configuration = check_configuration
5657
parameter_01 = |{ branch }|
5758
parameter_02 = |{ check_configuration-threshold }|
5859
parameter_03 = |{ coverage->get_total( ) }|
5960
parameter_04 = |{ coverage->get_executed( ) }| ).
60-
6161
ENDMETHOD.
6262

6363

Diff for: src/checks/y_check_call_method_usage.clas.abap

+8-10
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,14 @@ CLASS y_check_call_method_usage IMPLEMENTATION.
3535
OR token CP '*)=>*'
3636
OR token CP '(*)' ).
3737

38-
DATA(check_configuration) = detect_check_configuration( statement ).
39-
40-
IF check_configuration IS NOT INITIAL
41-
AND has_keyword = abap_true
42-
AND is_dynamic = abap_false.
43-
44-
raise_error( statement_level = statement-level
45-
statement_index = index
46-
statement_from = statement-from
47-
error_priority = check_configuration-prio ).
38+
IF has_keyword = abap_true
39+
AND is_dynamic = abap_false.
40+
DATA(check_configuration) = detect_check_configuration( statement ).
41+
42+
raise_error( statement_level = statement-level
43+
statement_index = index
44+
statement_from = statement-from
45+
check_configuration = check_configuration ).
4846
ENDIF.
4947
ENDMETHOD.
5048

0 commit comments

Comments
 (0)