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: docs/checks/magic-number.md
+5-12Lines changed: 5 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,10 @@
1
-
# code pal for ABAP
2
-
3
1
[code pal for ABAP](../../README.md) > [Documentation](../check_documentation.md) > [Magic Number Check](magic-number.md)
4
2
5
3
## Magic Number Usage Check
6
4
7
5
### What is the Intent of the Check?
8
6
9
-
The "Magic Number Usage" check searches for numbers which are present in the source code without being able to directly understand their meaning.
7
+
This check searches for arbitrary values in the source code having no meaningful conotation.
10
8
11
9
Using magic numbers has disadvantages:
12
10
@@ -15,28 +13,23 @@ Using magic numbers has disadvantages:
15
13
16
14
### How does the check work?
17
15
18
-
At the moment, the magic number check searches for numbers in the following statements only:
16
+
It searches for numbers/values in the following statements:
19
17
20
18
1.`IF`
21
19
2.`ELSEIF`
22
20
3.`WHEN`
23
21
4.`CHECK`
24
22
5.`DO`
25
23
26
-
For now, Magic Numbers associated with `SY-SUBRC` are not considered in this check. In addition, the numbers `0` and `1` are ignored.
27
-
28
-
### Which attributes can be maintained?
29
-
30
-

24
+
REMARK: Magic Numbers associated with `SY-SUBRC` are not considered by this check. In addition, the numbers `0` and `1` are ignored.
31
25
32
26
### How to solve the issue?
33
27
34
-
Create constants. By the name of the constants the number becomes a meaning which increases the readability. In addition, when maintaining the code, you only need to change the constant. This change can be done without the risk of introducing new errors or without forgetting some places where this change is required.
28
+
Create constants. By the name of the constant the number becomes a meaning which increases the readability. In addition, when maintaining the code, you only need to change the constant. This change can be done without the risk of introducing new errors or without forgetting some places where this change is required.
35
29
36
30
### What to do in case of exception?
37
31
38
-
You can suppress Code Inspector findings generated by this check using the pseudo comment `"#EC CI_MAGIC`.
39
-
The pseudo comment must be placed right after the statement containing the magic number.
32
+
In exceptional cases, you can suppress this finding by using the pseudo comment `"#EC CI_MAGIC` which should be placed right after the statement containing the magic number:
0 commit comments