Skip to content

Commit 4da128b

Browse files
Eugen Güntherlucasborin
Eugen Günther
andauthored
Part 1 - core feature - allow pseudo comment exception #329 (#357)
* feature - allow pseudo comment exception * Update y_check_unit_test_assert.clas.abap Co-authored-by: Lucas Borin <[email protected]>
1 parent 8b9f804 commit 4da128b

9 files changed

+189
-101
lines changed

src/foundation/y_check_base.clas.abap

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ CLASS y_check_base DEFINITION PUBLIC ABSTRACT
3030
apply_on_test_code TYPE ycicc_testcode,
3131
documentation TYPE c LENGTH 1000,
3232
is_threshold_reversed TYPE abap_bool,
33+
allow_pseudo_comments TYPE abap_bool,
3334
END OF settings.
3435

3536
METHODS constructor.
@@ -104,8 +105,7 @@ CLASS y_check_base DEFINITION PUBLIC ABSTRACT
104105
parameter_04 TYPE csequence OPTIONAL
105106
is_include_specific TYPE sci_inclspec DEFAULT ' '
106107
additional_information TYPE xstring OPTIONAL
107-
checksum TYPE int4 OPTIONAL
108-
pseudo_comments TYPE t_comments OPTIONAL. "#EC OPTL_PARAM
108+
checksum TYPE int4 OPTIONAL. "#EC OPTL_PARAM
109109

110110
METHODS get_column_abs REDEFINITION.
111111
METHODS get_column_rel REDEFINITION.
@@ -149,14 +149,14 @@ CLASS y_check_base DEFINITION PUBLIC ABSTRACT
149149
METHODS is_structure_type_relevant IMPORTING structure TYPE sstruc
150150
RETURNING VALUE(result) TYPE abap_bool.
151151

152-
METHODS is_app_comp_in_scope IMPORTING level TYPE stmnt_levl
153-
RETURNING value(result) TYPE abap_bool.
152+
METHODS is_app_comp_in_scope IMPORTING level TYPE stmnt_levl
153+
RETURNING VALUE(result) TYPE abap_bool.
154154

155155
ENDCLASS.
156156

157157

158158

159-
CLASS y_check_base IMPLEMENTATION.
159+
CLASS Y_CHECK_BASE IMPLEMENTATION.
160160

161161

162162
METHOD check_start_conditions.
@@ -181,6 +181,7 @@ CLASS y_check_base IMPLEMENTATION.
181181
settings-apply_on_productive_code = abap_true.
182182
settings-apply_on_test_code = abap_true.
183183
settings-documentation = |{ c_docs_path-main }check_documentation.md|.
184+
settings-allow_pseudo_comments = abap_true.
184185

185186
has_attributes = do_attributes_exist( ).
186187

@@ -298,7 +299,7 @@ CLASS y_check_base IMPLEMENTATION.
298299
check_configuration-object_creation_date = settings-object_created_on.
299300
check_configuration-prio = settings-prio.
300301
check_configuration-threshold = settings-threshold.
301-
302+
check_configuration-allow_pseudo_comments = settings-allow_pseudo_comments.
302303
APPEND check_configuration TO check_configurations.
303304
ENDIF.
304305
EXPORT
@@ -307,6 +308,7 @@ CLASS y_check_base IMPLEMENTATION.
307308
threshold = check_configuration-threshold
308309
apply_on_productive_code = check_configuration-apply_on_productive_code
309310
apply_on_testcode = check_configuration-apply_on_testcode
311+
allow_pseudo_comments = check_configuration-allow_pseudo_comments
310312
TO DATA BUFFER p_attributes.
311313
ENDMETHOD.
312314

@@ -512,6 +514,7 @@ CLASS y_check_base IMPLEMENTATION.
512514
check_configuration-apply_on_productive_code = settings-apply_on_productive_code.
513515
check_configuration-apply_on_testcode = settings-apply_on_test_code.
514516
check_configuration-threshold = settings-threshold.
517+
check_configuration-allow_pseudo_comments = settings-allow_pseudo_comments.
515518
ENDIF.
516519

517520
INSERT VALUE #(
@@ -550,6 +553,14 @@ CLASS y_check_base IMPLEMENTATION.
550553
) INTO TABLE sci_attributes.
551554
ENDIF.
552555

556+
IF settings-pseudo_comment IS NOT INITIAL.
557+
INSERT VALUE #(
558+
kind = ''
559+
ref = REF #( check_configuration-allow_pseudo_comments )
560+
text = |Allow { settings-pseudo_comment }|
561+
) INTO TABLE sci_attributes.
562+
ENDIF.
563+
553564
title = description.
554565

555566
attributes_ok = abap_false.
@@ -597,7 +608,7 @@ CLASS y_check_base IMPLEMENTATION.
597608
ENDIF.
598609

599610
IF clean_code_exemption_handler IS NOT BOUND.
600-
clean_code_exemption_handler = new y_exemption_handler( ).
611+
clean_code_exemption_handler = NEW y_exemption_handler( ).
601612
ENDIF.
602613

603614
IF test_code_detector IS NOT BOUND.
@@ -638,6 +649,7 @@ CLASS y_check_base IMPLEMENTATION.
638649
threshold = check_configuration-threshold
639650
apply_on_productive_code = check_configuration-apply_on_productive_code
640651
apply_on_testcode = check_configuration-apply_on_testcode
652+
allow_pseudo_comments = check_configuration-allow_pseudo_comments
641653
FROM DATA BUFFER p_attributes.
642654
APPEND check_configuration TO check_configurations.
643655
CATCH cx_root. "#EC NEED_CX_ROOT
@@ -647,12 +659,15 @@ CLASS y_check_base IMPLEMENTATION.
647659

648660

649661
METHOD raise_error.
662+
DATA(pseudo_comment) = COND sci_pcom( WHEN settings-allow_pseudo_comments = abap_false THEN settings-pseudo_comment
663+
ELSE space ).
664+
650665
statistics->collect( kind = error_priority
651666
pc = NEW y_pseudo_comment_detector( )->is_pseudo_comment( ref_scan_manager = ref_scan_manager
652667
scimessages = scimessages
653668
test = myname
654669
code = get_code( error_priority )
655-
suppress = settings-pseudo_comment
670+
suppress = pseudo_comment
656671
position = statement_index ) ).
657672

658673
IF cl_abap_typedescr=>describe_by_object_ref( ref_scan_manager )->get_relative_name( ) EQ 'Y_REF_SCAN_MANAGER'.
@@ -665,17 +680,15 @@ CLASS y_check_base IMPLEMENTATION.
665680
p_kind = error_priority
666681
p_test = myname
667682
p_code = get_code( error_priority )
668-
p_suppress = settings-pseudo_comment
683+
p_suppress = pseudo_comment
669684
p_param_1 = parameter_01
670685
p_param_2 = parameter_02
671686
p_param_3 = parameter_03
672687
p_param_4 = parameter_04
673688
p_inclspec = is_include_specific
674689
p_detail = additional_information
675-
p_checksum_1 = checksum
676-
p_comments = pseudo_comments ).
690+
p_checksum_1 = checksum ).
677691
ENDIF.
678-
679692
ENDMETHOD.
680693

681694

@@ -797,6 +810,4 @@ CLASS y_check_base IMPLEMENTATION.
797810
result = abap_true.
798811
ENDTRY.
799812
ENDMETHOD.
800-
801-
802813
ENDCLASS.

src/foundation/y_clean_code_manager.clas.abap

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@ CLASS y_clean_code_manager DEFINITION PUBLIC CREATE PUBLIC.
44
ALIASES calculate_obj_creation_date FOR y_if_clean_code_manager~calculate_obj_creation_date.
55
ALIASES read_check_customizing FOR y_if_clean_code_manager~read_check_customizing.
66

7+
PROTECTED SECTION.
78
PRIVATE SECTION.
89
METHODS determine_profiles RETURNING VALUE(result) TYPE string_table
9-
RAISING ycx_no_check_customizing.
10+
RAISING ycx_no_check_customizing.
1011

11-
METHODS determine_checks IMPORTING profile TYPE ycicc_profile
12-
checkid TYPE seoclsname
12+
METHODS determine_checks IMPORTING profile TYPE ycicc_profile
13+
checkid TYPE seoclsname
1314
RETURNING VALUE(result) TYPE y_if_clean_code_manager=>check_configurations
14-
RAISING ycx_no_check_customizing .
15+
RAISING ycx_no_check_customizing .
1516
ENDCLASS.
1617

1718

18-
CLASS y_clean_code_manager IMPLEMENTATION.
19+
20+
CLASS Y_CLEAN_CODE_MANAGER IMPLEMENTATION.
1921

2022

2123
METHOD determine_checks.
@@ -33,7 +35,9 @@ CLASS y_clean_code_manager IMPLEMENTATION.
3335
threshold = <check>-threshold
3436
prio = <check>-prio
3537
apply_on_productive_code = <check>-apply_on_productive_code
36-
apply_on_testcode = <check>-apply_on_testcode ).
38+
apply_on_testcode = <check>-apply_on_testcode
39+
allow_pseudo_comments = <check>-ignore_pseudo_comments
40+
).
3741
result = VALUE #( BASE result ( CORRESPONDING #( check_configuration ) ) ).
3842
ENDLOOP.
3943
ENDMETHOD.
Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
interface Y_IF_CLEAN_CODE_MANAGER
2-
public .
1+
INTERFACE y_if_clean_code_manager
2+
PUBLIC .
33

44

5-
types:
5+
TYPES:
66
BEGIN OF check_configuration,
77
object_creation_date TYPE datum,
88
threshold TYPE ycicc_threshold,
99
prio TYPE ycicc_message_kind,
1010
apply_on_productive_code TYPE ycicc_productive_code,
1111
apply_on_testcode TYPE ycicc_testcode,
12+
allow_pseudo_comments TYPE ycicp_pseudo_comments,
1213
END OF check_configuration .
13-
types:
14+
TYPES:
1415
check_configurations TYPE STANDARD TABLE OF check_configuration WITH DEFAULT KEY .
1516

16-
methods READ_CHECK_CUSTOMIZING
17-
importing
18-
CHECKID type SEOCLSNAME
19-
returning
20-
value(RESULT) type CHECK_CONFIGURATIONS
21-
raising
22-
YCX_NO_CHECK_CUSTOMIZING .
23-
methods CALCULATE_OBJ_CREATION_DATE
24-
importing
25-
OBJECT_NAME type SOBJ_NAME
26-
OBJECT_TYPE type TROBJTYPE
27-
returning
28-
value(RESULT) type CREATIONDT .
29-
endinterface.
17+
METHODS read_check_customizing
18+
IMPORTING
19+
checkid TYPE seoclsname
20+
RETURNING
21+
VALUE(result) TYPE check_configurations
22+
RAISING
23+
ycx_no_check_customizing .
24+
METHODS calculate_obj_creation_date
25+
IMPORTING
26+
object_name TYPE sobj_name
27+
object_type TYPE trobjtype
28+
RETURNING
29+
VALUE(result) TYPE creationdt .
30+
ENDINTERFACE.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_DTEL" serializer_version="v1.0.0">
3+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
4+
<asx:values>
5+
<DD04V>
6+
<ROLLNAME>YCICP_PSEUDO_COMMENTS</ROLLNAME>
7+
<DDLANGUAGE>E</DDLANGUAGE>
8+
<DOMNAME>BOOLE</DOMNAME>
9+
<HEADLEN>55</HEADLEN>
10+
<SCRLEN1>10</SCRLEN1>
11+
<SCRLEN2>20</SCRLEN2>
12+
<SCRLEN3>40</SCRLEN3>
13+
<DDTEXT>Code Pal - Allow Pseudo Comments</DDTEXT>
14+
<REPTEXT>PseudCom</REPTEXT>
15+
<SCRTEXT_S>PseudCom</SCRTEXT_S>
16+
<SCRTEXT_M>PseudCom</SCRTEXT_M>
17+
<SCRTEXT_L>PseudCom</SCRTEXT_L>
18+
<DTELMASTER>E</DTELMASTER>
19+
<REFKIND>D</REFKIND>
20+
</DD04V>
21+
</asx:values>
22+
</asx:abap>
23+
</abapGit>

0 commit comments

Comments
 (0)