Skip to content

Commit 91c85c9

Browse files
lucasborinLucas Borin
andauthored
Magic Number: Leading Zeros (#479)
* fixing magic number for leading zeros * changelog Co-authored-by: Lucas Borin <5233413+lucasborin@users.noreply.github.co>
1 parent 5e7761d commit 91c85c9

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Legend
1818

1919
2021-08-XX v.1.16.0
2020
------------------
21+
* Magic Number: Leading Zeros (#479)
2122
* Prefer New to Create Object: Dynamic Type (#469)
2223
* Magic Number: Table Index (#468)
2324
* Use native *_wa variables (#474)

src/checks/y_check_magic_number.clas.abap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ CLASS y_check_magic_number IMPLEMENTATION.
7272
METHOD is_magic_number.
7373
DATA(string) = token_wa-str.
7474
REPLACE ALL OCCURRENCES OF |'| IN string WITH ||.
75+
7576
result = xsdbool( string IS NOT INITIAL
7677
AND string CO '0123456789'
77-
AND string <> '0'
78+
AND string CN '0'
7879
AND string <> '1' ).
7980
ENDMETHOD.
8081

src/checks/y_check_magic_number.clas.testclasses.abap

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,23 @@ CLASS ltc_empty_string IMPLEMENTATION.
336336
ENDMETHOD.
337337

338338
ENDCLASS.
339+
340+
341+
CLASS ltc_leading_zeros DEFINITION INHERITING FROM ltc_if FOR TESTING RISK LEVEL HARMLESS DURATION SHORT.
342+
PROTECTED SECTION.
343+
METHODS get_code_without_issue REDEFINITION.
344+
ENDCLASS.
345+
346+
CLASS ltc_leading_zeros IMPLEMENTATION.
347+
348+
METHOD get_code_without_issue.
349+
result = VALUE #(
350+
( ' REPORT ut_test.' )
351+
( ' START-OF-SELECTION.' )
352+
( | DATA char TYPE c LENGTH 6. | )
353+
( | IF char = '000000'. | )
354+
( ' ENDIF. ' )
355+
).
356+
ENDMETHOD.
357+
358+
ENDCLASS.

0 commit comments

Comments
 (0)