You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: changelog.txt
+20Lines changed: 20 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,26 @@ Legend
8
8
+ : added
9
9
- : removed
10
10
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)
14
+
15
+
2020-12-XX v1.10.0
16
+
------------------
17
+
+ New Check: Scope of the Variable (#276)
18
+
* Comment position when code has pseudo comments (#282)
19
+
* Y_CHECK_STATEMENT_POSITION: before DATA declarations (#272)
20
+
+ 'was' and 'were' as a method which returns boolean (#275)
21
+
! DB Access in UT has distinct behavior depending on test risk level (#267)
22
+
! Prefer Case to ElseIf is now reporting single conditions only (#262)
23
+
! Chain Declaration check is now warning by default (#266)
24
+
+ abapLint app integration in GitHub (#264)
25
+
+ API regression reports 'maintain attributes..." message (#259)
26
+
+ API improvements (#259)
27
+
* Missing space between string or character literal and parentheses (#253)
Copy file name to clipboardExpand all lines: docs/checks/check-statement-position.md
+5-7Lines changed: 5 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,15 +5,13 @@
5
5
## CHECK Statement Position Check
6
6
7
7
### What is the Intent of the Check?
8
-
The "Check Statement Position" verifies whether the `CHECK` statement is in the first position (first statement) within a method, function-module or form-routine.
9
-
Do not use `CHECK` outside of the initialization section of a method. The statement behaves differently in different positions and may lead to unclear, unexpected effects.
8
+
It verifies whether the `CHECK` statement is the first statement within a method, function-module, or form-routine.
The [Clean ABAP](https://github.com/SAP/styleguides/blob/master/clean-abap/CleanABAP.md#avoid-check-in-other-positions) says:
11
+
> Do not use `CHECK` outside of the initialization section of a method. The statement behaves differently in different positions and may lead to unclear, unexpected effects.
13
12
14
13
### How to solve the issue?
15
-
The `CHECK` statement shall be the first statement of a method (suggested even before any DATA declaration);
16
-
If not, try to substitute this keyword by an IF-statement instead.
14
+
The `CHECK` statement shall be the first statement of a method. If it is not possible, try to substitute this keyword with an IF-statement instead.
17
15
18
16
### What to do in case of exception?
19
17
In special cases you can suppress this finding by using the pseudo comment `"#EC CHECK_POSITION`.
@@ -43,7 +41,7 @@ METHOD example.
43
41
CHECK sy-mandt = 000.
44
42
...
45
43
ENDMETHOD.
46
-
```
44
+
```
47
45
48
46
### Further Readings & Knowledge
49
47
-[Avoid CHECK in other positions (Clean ABAP)](https://github.com/SAP/styleguides/blob/master/clean-abap/CleanABAP.md#avoid-check-in-other-positions)
[code pal for ABAP](../../README.md) > [Documentation](../check_documentation.md) > [Scope of Variable](scope-of-variable.md)
4
+
5
+
## Scope of Variable
6
+
7
+
### What is the Intent of the Check?
8
+
If a variable is declared in a statement, it should be used/referred to inside this statement only (not outside).
9
+
10
+
### How does the check work?
11
+
It searches for `DATA` and `FIELD-SYMBOLS` declaration inside of `IF`, `ELSEIF`, `ELSE`, `DO`, `CASE/WHEN`, `LOOP`, and `WHILE` statements, and for its usage/reference outside this statement.
12
+
13
+
### How to solve the issue?
14
+
Relocate the declaration.
15
+
16
+
### What to do in case of exception?
17
+
You can suppress Code Inspector findings generated by this check using the pseudo comment `"#EC SCOPE_OF_VAR`.
18
+
The pseudo comment must be placed right after the variable usage/referece.
19
+
20
+
```abap
21
+
IF has_entries = abap_true.
22
+
DATA(value) = 1.
23
+
ELSE.
24
+
value = 2. "#EC SCOPE_OF_VAR
25
+
ENDIF.
26
+
```
27
+
28
+
### Example
29
+
30
+
Before:
31
+
```abap
32
+
IF has_entries = abap_true.
33
+
DATA(value) = 1.
34
+
ELSE.
35
+
value = 2.
36
+
ENDIF.
37
+
```
38
+
39
+
After:
40
+
```abap
41
+
DATA value TYPE i.
42
+
43
+
IF has_entries = abap_true.
44
+
value = 1.
45
+
ELSE.
46
+
value = 2.
47
+
ENDIF.
48
+
```
49
+
50
+
### Further Readings & Knowledge
51
+
*[ABAP Styleguides on Clean Code](https://github.com/SAP/styleguides/blob/master/clean-abap/CleanABAP.md#dont-declare-inline-in-optional-branches)
0 commit comments