Skip to content

Feature allow pseudo comment exception #361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1162355
feature - allow pseudo comment exception
Apr 7, 2021
d85625e
Update y_check_unit_test_assert.clas.abap
Apr 7, 2021
f25d909
Merge branch '1.14.0' into feature-allow-pseudo-comment-exception
lucasborin Apr 7, 2021
354e4d4
Merge branch '1.14.0' into feature-allow-pseudo-comment-exception
lucasborin Apr 7, 2021
0cf47bc
update
Apr 8, 2021
8cf4e3b
minor update
Apr 8, 2021
cfb9c41
requested changes
Apr 8, 2021
7a14340
Merge branch '1.14.0' into feature-allow-pseudo-comment-exception
lucasborin Apr 8, 2021
39f6537
Merge branch '1.14.0' into feature-allow-pseudo-comment-exception
lucasborin Apr 8, 2021
25dd24a
Update src/profiles/y_profile_admin_classes.prog.abap
lucasborin Apr 8, 2021
cc20afc
UX update
Apr 9, 2021
829ce00
abaplint fix
Apr 9, 2021
2655582
Merge branch '1.14.0' into feature-allow-pseudo-comment-exception
lucasborin Apr 9, 2021
ca63914
Update y_check_base.clas.abap
lucasborin Apr 9, 2021
f19f8ad
Merge branch '1.14.0' into feature-allow-pseudo-comment-exception
lucasborin Apr 9, 2021
ba84176
Update y_profile_admin_classes.prog.abap
lucasborin Apr 9, 2021
b795c06
Update y_profile_manager.clas.abap
lucasborin Apr 9, 2021
0224e02
Update src/profiles/y_profile_admin_classes.prog.abap
lucasborin Apr 9, 2021
3480f7d
Update y_profile_administrator.prog.xml
lucasborin Apr 9, 2021
17166ae
Update y_profile_admin_classes.prog.abap
lucasborin Apr 9, 2021
636e3ac
Update y_profile_admin_classes.prog.abap
lucasborin Apr 9, 2021
5984610
minor change
Apr 13, 2021
988f97b
abaplint fix
Apr 13, 2021
f132e27
Update y_check_base.clas.abap
Apr 13, 2021
2755020
update
Apr 13, 2021
20ac51d
update
Apr 13, 2021
6c29134
Update y_profile_admin_classes.prog.abap
Apr 13, 2021
ab71bae
update
Apr 13, 2021
eef4326
Merge branch '1.14.0' into feature-allow-pseudo-comment-exception
lucasborin Apr 13, 2021
4929032
Update how-to-configure.md
lucasborin Apr 13, 2021
ab7c07a
Update how-to-configure.md
lucasborin Apr 13, 2021
6ac8305
Update how-to-configure.md
lucasborin Apr 13, 2021
fe17609
Update changelog.txt
lucasborin Apr 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Whenever you upgrade code pal for ABAP, it is highly recommended to execute the

2021-04-** v.1.14.0
------------------
+ Additional option to disable exceptions/pragmas (#329)
! abapLint Rules
* Diffs for TABL (#359)
+ Unit Test Without/With Invalid Assert (#288)
Expand Down
3 changes: 2 additions & 1 deletion pages/how-to-configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ By the Check configuration: You can,
* Define check's severity;
* Define check's threshold (if applicable);
* Define if it is applicable in productive code (if applicable);
* Define if it is applicable in test code (if applicable).
* Define if it is applicable in test code (if applicable);
* Define if it allows exemption via pseudo comments (if applicable).

Check behavior:

Expand Down
87 changes: 58 additions & 29 deletions src/foundation/y_check_base.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ CLASS y_check_base DEFINITION PUBLIC ABSTRACT
apply_on_test_code TYPE ycicc_testcode,
documentation TYPE c LENGTH 1000,
is_threshold_reversed TYPE abap_bool,
ignore_pseudo_comments TYPE abap_bool,
END OF settings.

METHODS constructor.
Expand Down Expand Up @@ -103,8 +104,7 @@ CLASS y_check_base DEFINITION PUBLIC ABSTRACT
parameter_04 TYPE csequence OPTIONAL
is_include_specific TYPE sci_inclspec DEFAULT ' '
additional_information TYPE xstring OPTIONAL
checksum TYPE int4 OPTIONAL
pseudo_comments TYPE t_comments OPTIONAL. "#EC OPTL_PARAM
checksum TYPE int4 OPTIONAL. "#EC OPTL_PARAM

METHODS get_column_abs REDEFINITION.
METHODS get_column_rel REDEFINITION.
Expand Down Expand Up @@ -148,14 +148,17 @@ CLASS y_check_base DEFINITION PUBLIC ABSTRACT
METHODS is_structure_type_relevant IMPORTING structure TYPE sstruc
RETURNING VALUE(result) TYPE abap_bool.

METHODS is_app_comp_in_scope IMPORTING level TYPE stmnt_levl
RETURNING value(result) TYPE abap_bool.
METHODS is_app_comp_in_scope IMPORTING level TYPE stmnt_levl
RETURNING VALUE(result) TYPE abap_bool.

METHODS switch_bool IMPORTING boolean TYPE abap_bool
RETURNING VALUE(result) TYPE abap_bool.

ENDCLASS.



CLASS y_check_base IMPLEMENTATION.
CLASS Y_CHECK_BASE IMPLEMENTATION.


METHOD check_start_conditions.
Expand All @@ -180,6 +183,7 @@ CLASS y_check_base IMPLEMENTATION.
settings-apply_on_productive_code = abap_true.
settings-apply_on_test_code = abap_true.
settings-documentation = |{ c_docs_path-main }check_documentation.md|.
settings-ignore_pseudo_comments = abap_false.

has_attributes = do_attributes_exist( ).

Expand Down Expand Up @@ -219,10 +223,12 @@ CLASS y_check_base IMPLEMENTATION.
CONTINUE.
ENDIF.

IF result IS INITIAL OR is_config_setup_valid( previous_config = result
config = <configuration> ) = abap_true.
IF result IS INITIAL
OR is_config_setup_valid( previous_config = result
config = <configuration> ) = abap_true.
result = <configuration>.
ENDIF.

ENDLOOP.

IF result IS INITIAL.
Expand Down Expand Up @@ -296,7 +302,7 @@ CLASS y_check_base IMPLEMENTATION.
check_configuration-object_creation_date = settings-object_created_on.
check_configuration-prio = settings-prio.
check_configuration-threshold = settings-threshold.

check_configuration-ignore_pseudo_comments = settings-ignore_pseudo_comments.
APPEND check_configuration TO check_configurations.
ENDIF.
EXPORT
Expand All @@ -305,6 +311,7 @@ CLASS y_check_base IMPLEMENTATION.
threshold = check_configuration-threshold
apply_on_productive_code = check_configuration-apply_on_productive_code
apply_on_testcode = check_configuration-apply_on_testcode
ignore_pseudo_comments = check_configuration-ignore_pseudo_comments
TO DATA BUFFER p_attributes.
ENDMETHOD.

Expand Down Expand Up @@ -503,6 +510,7 @@ CLASS y_check_base IMPLEMENTATION.
check_configuration-apply_on_productive_code = settings-apply_on_productive_code.
check_configuration-apply_on_testcode = settings-apply_on_test_code.
check_configuration-threshold = settings-threshold.
check_configuration-ignore_pseudo_comments = settings-ignore_pseudo_comments.
ENDIF.

INSERT VALUE #(
Expand Down Expand Up @@ -541,6 +549,16 @@ CLASS y_check_base IMPLEMENTATION.
) INTO TABLE sci_attributes.
ENDIF.

check_configuration-ignore_pseudo_comments = switch_bool( check_configuration-ignore_pseudo_comments ).

IF settings-pseudo_comment IS NOT INITIAL.
INSERT VALUE #(
kind = ''
ref = REF #( check_configuration-ignore_pseudo_comments )
text = |Allow { settings-pseudo_comment }|
) INTO TABLE sci_attributes.
ENDIF.

title = description.

attributes_ok = abap_false.
Expand All @@ -552,8 +570,10 @@ CLASS y_check_base IMPLEMENTATION.
p_message = message
p_display = p_display ) = abap_true.
attributes_ok = abap_true.
check_configuration-ignore_pseudo_comments = switch_bool( check_configuration-ignore_pseudo_comments ).
RETURN.
ENDIF.

IF check_configuration-apply_on_productive_code = abap_false AND
check_configuration-apply_on_testcode = abap_false.
message = 'Choose the Type of Code to be checked'(300).
Expand All @@ -568,6 +588,8 @@ CLASS y_check_base IMPLEMENTATION.
ENDIF.
ENDWHILE.

check_configuration-ignore_pseudo_comments = switch_bool( check_configuration-ignore_pseudo_comments ).

CLEAR check_configurations.
APPEND check_configuration TO check_configurations.
use_default_attributes = abap_false.
Expand All @@ -588,7 +610,7 @@ CLASS y_check_base IMPLEMENTATION.
ENDIF.

IF clean_code_exemption_handler IS NOT BOUND.
clean_code_exemption_handler = new y_exemption_handler( ).
clean_code_exemption_handler = NEW y_exemption_handler( ).
ENDIF.

IF test_code_detector IS NOT BOUND.
Expand Down Expand Up @@ -629,6 +651,7 @@ CLASS y_check_base IMPLEMENTATION.
threshold = check_configuration-threshold
apply_on_productive_code = check_configuration-apply_on_productive_code
apply_on_testcode = check_configuration-apply_on_testcode
ignore_pseudo_comments = check_configuration-ignore_pseudo_comments
FROM DATA BUFFER p_attributes.
APPEND check_configuration TO check_configurations.
CATCH cx_root. "#EC NEED_CX_ROOT
Expand All @@ -638,13 +661,15 @@ CLASS y_check_base IMPLEMENTATION.


METHOD raise_error.
DATA(pseudo_comment) = COND #( WHEN settings-ignore_pseudo_comments = abap_false THEN settings-pseudo_comment ).
DATA(pcom_detector) = NEW y_pseudo_comment_detector( )->is_pseudo_comment( ref_scan_manager = ref_scan_manager
scimessages = scimessages
test = myname
code = get_code( error_priority )
suppress = pseudo_comment
position = statement_index ).
statistics->collect( kind = error_priority
pc = NEW y_pseudo_comment_detector( )->is_pseudo_comment( ref_scan_manager = ref_scan_manager
scimessages = scimessages
test = myname
code = get_code( error_priority )
suppress = settings-pseudo_comment
position = statement_index ) ).
pc = pcom_detector ).

IF cl_abap_typedescr=>describe_by_object_ref( ref_scan_manager )->get_relative_name( ) = 'Y_REF_SCAN_MANAGER'.
inform( p_sub_obj_type = object_type
Expand All @@ -656,17 +681,15 @@ CLASS y_check_base IMPLEMENTATION.
p_kind = error_priority
p_test = myname
p_code = get_code( error_priority )
p_suppress = settings-pseudo_comment
p_suppress = pseudo_comment
p_param_1 = parameter_01
p_param_2 = parameter_02
p_param_3 = parameter_03
p_param_4 = parameter_04
p_inclspec = is_include_specific
p_detail = additional_information
p_checksum_1 = checksum
p_comments = pseudo_comments ).
p_checksum_1 = checksum ).
ENDIF.

ENDMETHOD.


Expand Down Expand Up @@ -730,24 +753,27 @@ CLASS y_check_base IMPLEMENTATION.


METHOD is_config_setup_valid.
result = xsdbool( ( previous_config-prio = config-prio AND is_treshold_config_valid( config_threshold = config-threshold
previous_threshold = previous_config-threshold ) = abap_true ) OR
( previous_config-prio <> c_error AND config-prio = c_error ) OR
( previous_config-prio = c_note AND config-prio = c_warning ) ).
result = xsdbool( ( previous_config-prio = config-prio
AND is_treshold_config_valid( config_threshold = config-threshold
previous_threshold = previous_config-threshold ) = abap_true )
OR ( previous_config-prio <> c_error AND config-prio = c_error )
OR ( previous_config-prio = c_note AND config-prio = c_warning )
OR ( previous_config-ignore_pseudo_comments = abap_false
AND config-ignore_pseudo_comments = abap_true ) ).
ENDMETHOD.


METHOD is_skipped.
result = xsdbool( ( config-threshold < error_count AND settings-is_threshold_reversed = abap_true ) OR
( config-threshold > error_count AND settings-is_threshold_reversed = abap_false ) OR
( is_testcode = abap_true AND config-apply_on_testcode = abap_false ) OR
( is_testcode = abap_false AND config-apply_on_productive_code = abap_false ) ).
result = xsdbool( ( config-threshold < error_count AND settings-is_threshold_reversed = abap_true )
OR ( config-threshold > error_count AND settings-is_threshold_reversed = abap_false )
OR ( is_testcode = abap_true AND config-apply_on_testcode = abap_false )
OR ( is_testcode = abap_false AND config-apply_on_productive_code = abap_false ) ).
ENDMETHOD.


METHOD is_treshold_config_valid.
result = xsdbool( ( previous_threshold >= config_threshold AND settings-is_threshold_reversed = abap_false ) OR
( previous_threshold < config_threshold AND settings-is_threshold_reversed = abap_true ) ).
result = xsdbool( ( previous_threshold >= config_threshold AND settings-is_threshold_reversed = abap_false )
OR ( previous_threshold < config_threshold AND settings-is_threshold_reversed = abap_true ) ).
ENDMETHOD.


Expand Down Expand Up @@ -790,4 +816,7 @@ CLASS y_check_base IMPLEMENTATION.
ENDMETHOD.


METHOD switch_bool.
result = xsdbool( boolean = abap_false ).
ENDMETHOD.
ENDCLASS.
14 changes: 8 additions & 6 deletions src/foundation/y_clean_code_manager.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ CLASS y_clean_code_manager DEFINITION PUBLIC CREATE PUBLIC.

PRIVATE SECTION.
METHODS determine_profiles RETURNING VALUE(result) TYPE string_table
RAISING ycx_no_check_customizing.
RAISING ycx_no_check_customizing.

METHODS determine_checks IMPORTING profile TYPE ycicc_profile
checkid TYPE seoclsname
METHODS determine_checks IMPORTING profile TYPE ycicc_profile
checkid TYPE seoclsname
RETURNING VALUE(result) TYPE y_if_clean_code_manager=>check_configurations
RAISING ycx_no_check_customizing .
RAISING ycx_no_check_customizing .
ENDCLASS.


CLASS y_clean_code_manager IMPLEMENTATION.

CLASS Y_CLEAN_CODE_MANAGER IMPLEMENTATION.


METHOD determine_checks.
Expand All @@ -33,7 +34,8 @@ CLASS y_clean_code_manager IMPLEMENTATION.
threshold = <check>-threshold
prio = <check>-prio
apply_on_productive_code = <check>-apply_on_productive_code
apply_on_testcode = <check>-apply_on_testcode ).
apply_on_testcode = <check>-apply_on_testcode
ignore_pseudo_comments = <check>-ignore_pseudo_comments ).
result = VALUE #( BASE result ( CORRESPONDING #( check_configuration ) ) ).
ENDLOOP.
ENDMETHOD.
Expand Down
23 changes: 23 additions & 0 deletions src/foundation/y_code_pal_pseudo_comments.dtel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_DTEL" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<DD04V>
<ROLLNAME>Y_CODE_PAL_PSEUDO_COMMENTS</ROLLNAME>
<DDLANGUAGE>E</DDLANGUAGE>
<DOMNAME>BOOLE</DOMNAME>
<HEADLEN>55</HEADLEN>
<SCRLEN1>10</SCRLEN1>
<SCRLEN2>20</SCRLEN2>
<SCRLEN3>40</SCRLEN3>
<DDTEXT>Ignore Pseudo Comments</DDTEXT>
<REPTEXT>Ignore Pseudo Comments</REPTEXT>
<SCRTEXT_S>Ign Ps Com</SCRTEXT_S>
<SCRTEXT_M>IgnorePseudoComments</SCRTEXT_M>
<SCRTEXT_L>Ignore Pseudo Comments</SCRTEXT_L>
<DTELMASTER>E</DTELMASTER>
<REFKIND>D</REFKIND>
</DD04V>
</asx:values>
</asx:abap>
</abapGit>
37 changes: 19 additions & 18 deletions src/foundation/y_if_clean_code_manager.intf.abap
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
interface Y_IF_CLEAN_CODE_MANAGER
public .
INTERFACE y_if_clean_code_manager
PUBLIC .


types:
TYPES:
BEGIN OF check_configuration,
object_creation_date TYPE datum,
threshold TYPE ycicc_threshold,
prio TYPE ycicc_message_kind,
apply_on_productive_code TYPE ycicc_productive_code,
apply_on_testcode TYPE ycicc_testcode,
ignore_pseudo_comments TYPE y_code_pal_pseudo_comments,
END OF check_configuration .
types:
TYPES:
check_configurations TYPE STANDARD TABLE OF check_configuration WITH DEFAULT KEY .

methods READ_CHECK_CUSTOMIZING
importing
CHECKID type SEOCLSNAME
returning
value(RESULT) type CHECK_CONFIGURATIONS
raising
YCX_NO_CHECK_CUSTOMIZING .
methods CALCULATE_OBJ_CREATION_DATE
importing
OBJECT_NAME type SOBJ_NAME
OBJECT_TYPE type TROBJTYPE
returning
value(RESULT) type CREATIONDT .
endinterface.
METHODS read_check_customizing
IMPORTING
checkid TYPE seoclsname
RETURNING
VALUE(result) TYPE check_configurations
RAISING
ycx_no_check_customizing .
METHODS calculate_obj_creation_date
IMPORTING
object_name TYPE sobj_name
object_type TYPE trobjtype
RETURNING
VALUE(result) TYPE creationdt .
ENDINTERFACE.
Loading