Skip to content

Commit 9a3cbc3

Browse files
lucasborinEugen GuentherEugen Güntherabaplint[bot]
authored
Feature allow pseudo comment exception (#361)
* feature - allow pseudo comment exception * Update y_check_unit_test_assert.clas.abap * update * minor update * requested changes * Update src/profiles/y_profile_admin_classes.prog.abap Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * UX update * abaplint fix * Update y_check_base.clas.abap * Update y_profile_admin_classes.prog.abap * Update y_profile_manager.clas.abap * Update src/profiles/y_profile_admin_classes.prog.abap Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * Update y_profile_administrator.prog.xml * Update y_profile_admin_classes.prog.abap * Update y_profile_admin_classes.prog.abap * minor change * abaplint fix * Update y_check_base.clas.abap * update * update * Update y_profile_admin_classes.prog.abap * update * Update how-to-configure.md * Update how-to-configure.md * Update how-to-configure.md * Update changelog.txt Co-authored-by: Eugen Guenther <[email protected]> Co-authored-by: Eugen Günther <[email protected]> Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com>
1 parent 288335a commit 9a3cbc3

12 files changed

+255
-119
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Whenever you upgrade code pal for ABAP, it is highly recommended to execute the
1414

1515
2021-04-** v.1.14.0
1616
------------------
17+
+ Additional option to disable exceptions/pragmas (#329)
1718
! abapLint Rules
1819
* Diffs for TABL (#359)
1920
+ Unit Test Without/With Invalid Assert (#288)

pages/how-to-configure.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ By the Check configuration: You can,
2121
* Define check's severity;
2222
* Define check's threshold (if applicable);
2323
* Define if it is applicable in productive code (if applicable);
24-
* Define if it is applicable in test code (if applicable).
24+
* Define if it is applicable in test code (if applicable);
25+
* Define if it allows exemption via pseudo comments (if applicable).
2526

2627
Check behavior:
2728

src/foundation/y_check_base.clas.abap

Lines changed: 58 additions & 29 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+
ignore_pseudo_comments TYPE abap_bool,
3334
END OF settings.
3435

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

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

151-
METHODS is_app_comp_in_scope IMPORTING level TYPE stmnt_levl
152-
RETURNING value(result) TYPE abap_bool.
151+
METHODS is_app_comp_in_scope IMPORTING level TYPE stmnt_levl
152+
RETURNING VALUE(result) TYPE abap_bool.
153+
154+
METHODS switch_bool IMPORTING boolean TYPE abap_bool
155+
RETURNING VALUE(result) TYPE abap_bool.
153156

154157
ENDCLASS.
155158

156159

157160

158-
CLASS y_check_base IMPLEMENTATION.
161+
CLASS Y_CHECK_BASE IMPLEMENTATION.
159162

160163

161164
METHOD check_start_conditions.
@@ -180,6 +183,7 @@ CLASS y_check_base IMPLEMENTATION.
180183
settings-apply_on_productive_code = abap_true.
181184
settings-apply_on_test_code = abap_true.
182185
settings-documentation = |{ c_docs_path-main }check_documentation.md|.
186+
settings-ignore_pseudo_comments = abap_false.
183187

184188
has_attributes = do_attributes_exist( ).
185189

@@ -219,10 +223,12 @@ CLASS y_check_base IMPLEMENTATION.
219223
CONTINUE.
220224
ENDIF.
221225

222-
IF result IS INITIAL OR is_config_setup_valid( previous_config = result
223-
config = <configuration> ) = abap_true.
226+
IF result IS INITIAL
227+
OR is_config_setup_valid( previous_config = result
228+
config = <configuration> ) = abap_true.
224229
result = <configuration>.
225230
ENDIF.
231+
226232
ENDLOOP.
227233

228234
IF result IS INITIAL.
@@ -296,7 +302,7 @@ CLASS y_check_base IMPLEMENTATION.
296302
check_configuration-object_creation_date = settings-object_created_on.
297303
check_configuration-prio = settings-prio.
298304
check_configuration-threshold = settings-threshold.
299-
305+
check_configuration-ignore_pseudo_comments = settings-ignore_pseudo_comments.
300306
APPEND check_configuration TO check_configurations.
301307
ENDIF.
302308
EXPORT
@@ -305,6 +311,7 @@ CLASS y_check_base IMPLEMENTATION.
305311
threshold = check_configuration-threshold
306312
apply_on_productive_code = check_configuration-apply_on_productive_code
307313
apply_on_testcode = check_configuration-apply_on_testcode
314+
ignore_pseudo_comments = check_configuration-ignore_pseudo_comments
308315
TO DATA BUFFER p_attributes.
309316
ENDMETHOD.
310317

@@ -503,6 +510,7 @@ CLASS y_check_base IMPLEMENTATION.
503510
check_configuration-apply_on_productive_code = settings-apply_on_productive_code.
504511
check_configuration-apply_on_testcode = settings-apply_on_test_code.
505512
check_configuration-threshold = settings-threshold.
513+
check_configuration-ignore_pseudo_comments = settings-ignore_pseudo_comments.
506514
ENDIF.
507515

508516
INSERT VALUE #(
@@ -541,6 +549,16 @@ CLASS y_check_base IMPLEMENTATION.
541549
) INTO TABLE sci_attributes.
542550
ENDIF.
543551

552+
check_configuration-ignore_pseudo_comments = switch_bool( check_configuration-ignore_pseudo_comments ).
553+
554+
IF settings-pseudo_comment IS NOT INITIAL.
555+
INSERT VALUE #(
556+
kind = ''
557+
ref = REF #( check_configuration-ignore_pseudo_comments )
558+
text = |Allow { settings-pseudo_comment }|
559+
) INTO TABLE sci_attributes.
560+
ENDIF.
561+
544562
title = description.
545563

546564
attributes_ok = abap_false.
@@ -552,8 +570,10 @@ CLASS y_check_base IMPLEMENTATION.
552570
p_message = message
553571
p_display = p_display ) = abap_true.
554572
attributes_ok = abap_true.
573+
check_configuration-ignore_pseudo_comments = switch_bool( check_configuration-ignore_pseudo_comments ).
555574
RETURN.
556575
ENDIF.
576+
557577
IF check_configuration-apply_on_productive_code = abap_false AND
558578
check_configuration-apply_on_testcode = abap_false.
559579
message = 'Choose the Type of Code to be checked'(300).
@@ -568,6 +588,8 @@ CLASS y_check_base IMPLEMENTATION.
568588
ENDIF.
569589
ENDWHILE.
570590

591+
check_configuration-ignore_pseudo_comments = switch_bool( check_configuration-ignore_pseudo_comments ).
592+
571593
CLEAR check_configurations.
572594
APPEND check_configuration TO check_configurations.
573595
use_default_attributes = abap_false.
@@ -588,7 +610,7 @@ CLASS y_check_base IMPLEMENTATION.
588610
ENDIF.
589611

590612
IF clean_code_exemption_handler IS NOT BOUND.
591-
clean_code_exemption_handler = new y_exemption_handler( ).
613+
clean_code_exemption_handler = NEW y_exemption_handler( ).
592614
ENDIF.
593615

594616
IF test_code_detector IS NOT BOUND.
@@ -629,6 +651,7 @@ CLASS y_check_base IMPLEMENTATION.
629651
threshold = check_configuration-threshold
630652
apply_on_productive_code = check_configuration-apply_on_productive_code
631653
apply_on_testcode = check_configuration-apply_on_testcode
654+
ignore_pseudo_comments = check_configuration-ignore_pseudo_comments
632655
FROM DATA BUFFER p_attributes.
633656
APPEND check_configuration TO check_configurations.
634657
CATCH cx_root. "#EC NEED_CX_ROOT
@@ -638,13 +661,15 @@ CLASS y_check_base IMPLEMENTATION.
638661

639662

640663
METHOD raise_error.
664+
DATA(pseudo_comment) = COND #( WHEN settings-ignore_pseudo_comments = abap_false THEN settings-pseudo_comment ).
665+
DATA(pcom_detector) = NEW y_pseudo_comment_detector( )->is_pseudo_comment( ref_scan_manager = ref_scan_manager
666+
scimessages = scimessages
667+
test = myname
668+
code = get_code( error_priority )
669+
suppress = pseudo_comment
670+
position = statement_index ).
641671
statistics->collect( kind = error_priority
642-
pc = NEW y_pseudo_comment_detector( )->is_pseudo_comment( ref_scan_manager = ref_scan_manager
643-
scimessages = scimessages
644-
test = myname
645-
code = get_code( error_priority )
646-
suppress = settings-pseudo_comment
647-
position = statement_index ) ).
672+
pc = pcom_detector ).
648673

649674
IF cl_abap_typedescr=>describe_by_object_ref( ref_scan_manager )->get_relative_name( ) = 'Y_REF_SCAN_MANAGER'.
650675
inform( p_sub_obj_type = object_type
@@ -656,17 +681,15 @@ CLASS y_check_base IMPLEMENTATION.
656681
p_kind = error_priority
657682
p_test = myname
658683
p_code = get_code( error_priority )
659-
p_suppress = settings-pseudo_comment
684+
p_suppress = pseudo_comment
660685
p_param_1 = parameter_01
661686
p_param_2 = parameter_02
662687
p_param_3 = parameter_03
663688
p_param_4 = parameter_04
664689
p_inclspec = is_include_specific
665690
p_detail = additional_information
666-
p_checksum_1 = checksum
667-
p_comments = pseudo_comments ).
691+
p_checksum_1 = checksum ).
668692
ENDIF.
669-
670693
ENDMETHOD.
671694

672695

@@ -730,24 +753,27 @@ CLASS y_check_base IMPLEMENTATION.
730753

731754

732755
METHOD is_config_setup_valid.
733-
result = xsdbool( ( previous_config-prio = config-prio AND is_treshold_config_valid( config_threshold = config-threshold
734-
previous_threshold = previous_config-threshold ) = abap_true ) OR
735-
( previous_config-prio <> c_error AND config-prio = c_error ) OR
736-
( previous_config-prio = c_note AND config-prio = c_warning ) ).
756+
result = xsdbool( ( previous_config-prio = config-prio
757+
AND is_treshold_config_valid( config_threshold = config-threshold
758+
previous_threshold = previous_config-threshold ) = abap_true )
759+
OR ( previous_config-prio <> c_error AND config-prio = c_error )
760+
OR ( previous_config-prio = c_note AND config-prio = c_warning )
761+
OR ( previous_config-ignore_pseudo_comments = abap_false
762+
AND config-ignore_pseudo_comments = abap_true ) ).
737763
ENDMETHOD.
738764

739765

740766
METHOD is_skipped.
741-
result = xsdbool( ( config-threshold < error_count AND settings-is_threshold_reversed = abap_true ) OR
742-
( config-threshold > error_count AND settings-is_threshold_reversed = abap_false ) OR
743-
( is_testcode = abap_true AND config-apply_on_testcode = abap_false ) OR
744-
( is_testcode = abap_false AND config-apply_on_productive_code = abap_false ) ).
767+
result = xsdbool( ( config-threshold < error_count AND settings-is_threshold_reversed = abap_true )
768+
OR ( config-threshold > error_count AND settings-is_threshold_reversed = abap_false )
769+
OR ( is_testcode = abap_true AND config-apply_on_testcode = abap_false )
770+
OR ( is_testcode = abap_false AND config-apply_on_productive_code = abap_false ) ).
745771
ENDMETHOD.
746772

747773

748774
METHOD is_treshold_config_valid.
749-
result = xsdbool( ( previous_threshold >= config_threshold AND settings-is_threshold_reversed = abap_false ) OR
750-
( previous_threshold < config_threshold AND settings-is_threshold_reversed = abap_true ) ).
775+
result = xsdbool( ( previous_threshold >= config_threshold AND settings-is_threshold_reversed = abap_false )
776+
OR ( previous_threshold < config_threshold AND settings-is_threshold_reversed = abap_true ) ).
751777
ENDMETHOD.
752778

753779

@@ -790,4 +816,7 @@ CLASS y_check_base IMPLEMENTATION.
790816
ENDMETHOD.
791817

792818

819+
METHOD switch_bool.
820+
result = xsdbool( boolean = abap_false ).
821+
ENDMETHOD.
793822
ENDCLASS.

src/foundation/y_clean_code_manager.clas.abap

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ CLASS y_clean_code_manager DEFINITION PUBLIC CREATE PUBLIC.
66

77
PRIVATE SECTION.
88
METHODS determine_profiles RETURNING VALUE(result) TYPE string_table
9-
RAISING ycx_no_check_customizing.
9+
RAISING ycx_no_check_customizing.
1010

11-
METHODS determine_checks IMPORTING profile TYPE ycicc_profile
12-
checkid TYPE seoclsname
11+
METHODS determine_checks IMPORTING profile TYPE ycicc_profile
12+
checkid TYPE seoclsname
1313
RETURNING VALUE(result) TYPE y_if_clean_code_manager=>check_configurations
14-
RAISING ycx_no_check_customizing .
14+
RAISING ycx_no_check_customizing .
1515
ENDCLASS.
1616

1717

18-
CLASS y_clean_code_manager IMPLEMENTATION.
18+
19+
CLASS Y_CLEAN_CODE_MANAGER IMPLEMENTATION.
1920

2021

2122
METHOD determine_checks.
@@ -33,7 +34,8 @@ CLASS y_clean_code_manager IMPLEMENTATION.
3334
threshold = <check>-threshold
3435
prio = <check>-prio
3536
apply_on_productive_code = <check>-apply_on_productive_code
36-
apply_on_testcode = <check>-apply_on_testcode ).
37+
apply_on_testcode = <check>-apply_on_testcode
38+
ignore_pseudo_comments = <check>-ignore_pseudo_comments ).
3739
result = VALUE #( BASE result ( CORRESPONDING #( check_configuration ) ) ).
3840
ENDLOOP.
3941
ENDMETHOD.
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>Y_CODE_PAL_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>Ignore Pseudo Comments</DDTEXT>
14+
<REPTEXT>Ignore Pseudo Comments</REPTEXT>
15+
<SCRTEXT_S>Ign Ps Com</SCRTEXT_S>
16+
<SCRTEXT_M>IgnorePseudoComments</SCRTEXT_M>
17+
<SCRTEXT_L>Ignore Pseudo Comments</SCRTEXT_L>
18+
<DTELMASTER>E</DTELMASTER>
19+
<REFKIND>D</REFKIND>
20+
</DD04V>
21+
</asx:values>
22+
</asx:abap>
23+
</abapGit>
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+
ignore_pseudo_comments TYPE y_code_pal_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.

0 commit comments

Comments
 (0)