Skip to content

adjust of ignore pseudocomment on relevant checks #375

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 4 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 9 additions & 11 deletions src/checks/y_check_branch_coverage.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ CLASS y_check_branch_coverage DEFINITION PUBLIC INHERITING FROM y_check_base CRE
PROTECTED SECTION.
METHODS execute_check REDEFINITION.
METHODS inspect_tokens REDEFINITION.

ENDCLASS.


Expand All @@ -24,6 +23,7 @@ CLASS y_check_branch_coverage IMPLEMENTATION.
settings-disable_on_prodcode_selection = abap_true.
settings-disable_on_testcode_selection = abap_true.
settings-apply_on_test_code = abap_false.
settings-ignore_pseudo_comments = abap_true.
settings-documentation = |{ c_docs_path-checks }unit-test-coverages.md|.

set_check_message( 'Branch Coverage must be higher than &2%! (&1%<=&2%)' ).
Expand All @@ -50,21 +50,19 @@ CLASS y_check_branch_coverage IMPLEMENTATION.
RETURN.
ENDIF.

raise_error( statement_level = 1
statement_index = 1
statement_from = 1
error_priority = check_configuration-prio
parameter_01 = |{ branch }|
parameter_02 = |{ check_configuration-threshold }|
parameter_03 = |{ coverage->get_total( ) }|
parameter_04 = |{ coverage->get_executed( ) }| ).
raise_error( statement_level = 1
statement_index = 1
statement_from = 1
error_priority = check_configuration-prio
parameter_01 = |{ branch }|
parameter_02 = |{ check_configuration-threshold }|
parameter_03 = |{ coverage->get_total( ) }|
parameter_04 = |{ coverage->get_executed( ) }| ).

ENDMETHOD.


METHOD inspect_tokens.
RETURN.
ENDMETHOD.


ENDCLASS.
8 changes: 4 additions & 4 deletions src/checks/y_check_comment_position.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ ENDCLASS.



CLASS Y_CHECK_COMMENT_POSITION IMPLEMENTATION.
CLASS y_check_comment_position IMPLEMENTATION.


METHOD constructor.
super->constructor( ).

settings-disable_threshold_selection = abap_true.
settings-ignore_pseudo_comments = abap_true.
settings-threshold = 0.
settings-documentation = |{ c_docs_path-checks }comment-position.md|.

Expand All @@ -41,7 +42,6 @@ CLASS Y_CHECK_COMMENT_POSITION IMPLEMENTATION.


METHOD inspect_tokens.

CHECK statement-type = 'P'.
CHECK has_wrong_position( statement ).

Expand All @@ -53,8 +53,8 @@ CLASS Y_CHECK_COMMENT_POSITION IMPLEMENTATION.

raise_error( statement_level = statement-level
statement_index = index
statement_from = statement-from
error_priority = configuration-prio ).
statement_from = statement-from
error_priority = configuration-prio ).

ENDMETHOD.

Expand Down
14 changes: 10 additions & 4 deletions src/checks/y_check_comment_type.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,24 @@ CLASS y_check_comment_type DEFINITION PUBLIC INHERITING FROM y_check_base CREATE
METHODS get_second_character IMPORTING token TYPE stokesx RETURNING VALUE(result) TYPE char1.
ENDCLASS.



CLASS y_check_comment_type IMPLEMENTATION.


METHOD constructor.
super->constructor( ).

settings-disable_threshold_selection = abap_true.
settings-ignore_pseudo_comments = abap_true.
settings-threshold = 0.
settings-documentation = |{ c_docs_path-checks }comment-type.md|.

set_check_message( 'Comment with ", not with *!' ).
ENDMETHOD.

METHOD inspect_tokens.

METHOD inspect_tokens.
CHECK statement-type = 'P'.
CHECK has_wrong_comment_type( statement ).

Expand All @@ -34,11 +38,12 @@ CLASS y_check_comment_type IMPLEMENTATION.

raise_error( statement_level = statement-level
statement_index = index
statement_from = statement-from
error_priority = configuration-prio ).
statement_from = statement-from
error_priority = configuration-prio ).

ENDMETHOD.


METHOD has_wrong_comment_type.
LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL(<token>)
FROM statement-from TO statement-to.
Expand All @@ -50,6 +55,7 @@ CLASS y_check_comment_type IMPLEMENTATION.
ENDLOOP.
ENDMETHOD.


METHOD get_first_character.
TRY.
result = token-str(1).
Expand All @@ -58,12 +64,12 @@ CLASS y_check_comment_type IMPLEMENTATION.
ENDTRY.
ENDMETHOD.


METHOD get_second_character.
TRY.
result = token-str(2).
CATCH cx_sy_range_out_of_bounds.
result = ''.
ENDTRY.
ENDMETHOD.

ENDCLASS.
22 changes: 10 additions & 12 deletions src/checks/y_check_comment_usage.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ CLASS y_check_comment_usage DEFINITION PUBLIC INHERITING FROM y_check_base CREAT

METHODS check_result IMPORTING structure TYPE sstruc.

METHODS is_code_disabled IMPORTING structure TYPE sstruc
statement TYPE sstmnt
METHODS is_code_disabled IMPORTING structure TYPE sstruc
statement TYPE sstmnt
RETURNING VALUE(result) TYPE abap_bool.

ENDCLASS.
Expand All @@ -32,6 +32,7 @@ CLASS y_check_comment_usage IMPLEMENTATION.
settings-prio = c_note.
settings-threshold = 10.
settings-documentation = |{ c_docs_path-checks }comment-usage.md|.
settings-ignore_pseudo_comments = abap_true.

relevant_statement_types = VALUE #( ( scan_struc_stmnt_type-class_definition )
( scan_struc_stmnt_type-class_implementation )
Expand All @@ -57,7 +58,6 @@ CLASS y_check_comment_usage IMPLEMENTATION.
METHOD inspect_tokens.
DATA(code_disabled) = is_code_disabled( statement = statement
structure = structure ).

IF code_disabled = abap_true.
RETURN.
ENDIF.
Expand Down Expand Up @@ -97,13 +97,13 @@ CLASS y_check_comment_usage IMPLEMENTATION.
RETURN.
ENDIF.

raise_error( statement_level = statement_for_message-level
statement_index = structure-stmnt_from
statement_from = statement_for_message-from
error_priority = check_configuration-prio
parameter_01 = |{ comment_number }|
parameter_02 = |{ percentage_of_comments }|
parameter_03 = |{ check_configuration-threshold }| ).
raise_error( statement_level = statement_for_message-level
statement_index = structure-stmnt_from
statement_from = statement_for_message-from
error_priority = check_configuration-prio
parameter_01 = |{ comment_number }|
parameter_02 = |{ percentage_of_comments }|
parameter_03 = |{ check_configuration-threshold }| ).
ENDMETHOD.


Expand All @@ -129,6 +129,4 @@ CLASS y_check_comment_usage IMPLEMENTATION.

result = xsdbool( is_function_module = abap_false ).
ENDMETHOD.


ENDCLASS.
20 changes: 9 additions & 11 deletions src/checks/y_check_procedure_coverage.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ CLASS y_check_procedure_coverage DEFINITION PUBLIC INHERITING FROM y_check_base
PROTECTED SECTION.
METHODS execute_check REDEFINITION.
METHODS inspect_tokens REDEFINITION.

ENDCLASS.


Expand All @@ -24,6 +23,7 @@ CLASS y_check_procedure_coverage IMPLEMENTATION.
settings-disable_on_prodcode_selection = abap_true.
settings-disable_on_testcode_selection = abap_true.
settings-apply_on_test_code = abap_false.
settings-ignore_pseudo_comments = abap_true.
settings-documentation = |{ c_docs_path-checks }unit-test-coverages.md|.

set_check_message( 'Procedure Coverage must be higher than &2%! (&1%<=&2%)' ).
Expand All @@ -50,21 +50,19 @@ CLASS y_check_procedure_coverage IMPLEMENTATION.
RETURN.
ENDIF.

raise_error( statement_level = 1
statement_index = 1
statement_from = 1
error_priority = check_configuration-prio
parameter_01 = |{ procedure }|
parameter_02 = |{ check_configuration-threshold }|
parameter_03 = |{ coverage->get_total( ) }|
parameter_04 = |{ coverage->get_executed( ) }| ).
raise_error( statement_level = 1
statement_index = 1
statement_from = 1
error_priority = check_configuration-prio
parameter_01 = |{ procedure }|
parameter_02 = |{ check_configuration-threshold }|
parameter_03 = |{ coverage->get_total( ) }|
parameter_04 = |{ coverage->get_executed( ) }| ).

ENDMETHOD.


METHOD inspect_tokens.
RETURN.
ENDMETHOD.


ENDCLASS.
55 changes: 28 additions & 27 deletions src/checks/y_check_profile_message.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ CLASS y_check_profile_message DEFINITION PUBLIC INHERITING FROM y_check_base CRE
CLASS-DATA ran TYPE abap_bool.
METHODS get_profiles RETURNING VALUE(result) TYPE y_if_profile_manager=>profile_assignments.
METHODS list_profiles IMPORTING profiles TYPE y_if_profile_manager=>profile_assignments
RETURNING value(result) TYPE string.
RETURNING VALUE(result) TYPE string.
ENDCLASS.



CLASS y_check_profile_message IMPLEMENTATION.


Expand All @@ -28,6 +30,7 @@ CLASS y_check_profile_message IMPLEMENTATION.
settings-threshold = 0.
settings-apply_on_test_code = abap_true.
settings-apply_on_productive_code = abap_true.
settings-ignore_pseudo_comments = abap_true.
settings-prio = c_note.

set_check_message( '&1 Profile(s) in use: &2.' ).
Expand All @@ -46,12 +49,12 @@ CLASS y_check_profile_message IMPLEMENTATION.

DATA(profiles) = get_profiles( ).

raise_error( statement_level = 1
statement_index = 1
statement_from = 1
error_priority = check_configuration-prio
parameter_01 = |{ lines( profiles ) }|
parameter_02 = |{ list_profiles( profiles ) }| ).
raise_error( statement_level = 1
statement_index = 1
statement_from = 1
error_priority = check_configuration-prio
parameter_01 = |{ lines( profiles ) }|
parameter_02 = |{ list_profiles( profiles ) }| ).

ran = abap_true.
ENDMETHOD.
Expand All @@ -63,24 +66,24 @@ CLASS y_check_profile_message IMPLEMENTATION.


METHOD inform.
super->inform( p_sub_obj_type = 'TRAN'
p_sub_obj_name = 'Y_CODE_PAL_PROFILE'
p_position = ''
p_line = ''
p_column = ''
p_errcnt = p_errcnt
p_kind = p_kind
p_test = p_test
p_code = p_code
p_suppress = p_suppress
p_param_1 = p_param_1
p_param_2 = p_param_2
p_param_3 = p_param_3
p_param_4 = p_param_4
p_inclspec = p_inclspec
p_detail = p_detail
p_checksum_1 = p_checksum_1
p_comments = p_comments ).
super->inform( p_sub_obj_type = 'TRAN'
p_sub_obj_name = 'Y_CODE_PAL_PROFILE'
p_position = ''
p_line = ''
p_column = ''
p_errcnt = p_errcnt
p_kind = p_kind
p_test = p_test
p_code = p_code
p_suppress = p_suppress
p_param_1 = p_param_1
p_param_2 = p_param_2
p_param_3 = p_param_3
p_param_4 = p_param_4
p_inclspec = p_inclspec
p_detail = p_detail
p_checksum_1 = p_checksum_1
p_comments = p_comments ).
ENDMETHOD.


Expand All @@ -99,6 +102,4 @@ CLASS y_check_profile_message IMPLEMENTATION.
ELSE |{ result }, { <profile>-profile }| ).
ENDLOOP.
ENDMETHOD.


ENDCLASS.
13 changes: 6 additions & 7 deletions src/checks/y_check_pseudo_comment_usage.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ CLASS y_check_pseudo_comment_usage DEFINITION PUBLIC INHERITING FROM y_check_bas
METHODS check_result.

METHODS select_object_list RETURNING VALUE(result) LIKE name_tab
RAISING cx_failed.
RAISING cx_failed.

METHODS call_get_pseudo_comment IMPORTING obj_name TYPE stokesx-str
METHODS call_get_pseudo_comment IMPORTING obj_name TYPE stokesx-str
RETURNING VALUE(result) TYPE stokesx-str
RAISING cx_sy_create_object_error.
RAISING cx_sy_create_object_error.

ENDCLASS.

Expand Down Expand Up @@ -52,6 +52,7 @@ CLASS y_check_pseudo_comment_usage IMPLEMENTATION.
settings-threshold = 0.
settings-apply_on_test_code = abap_true.
settings-apply_on_productive_code = abap_true.
settings-ignore_pseudo_comments = abap_true.
settings-prio = c_note.

relevant_statement_types = VALUE #( BASE relevant_statement_types
Expand Down Expand Up @@ -112,8 +113,8 @@ CLASS y_check_pseudo_comment_usage IMPLEMENTATION.
raise_error( statement_level = 1
statement_index = 1
statement_from = 1
error_priority = check_configuration-prio
parameter_01 = |{ pseudo_comment_counter }| ).
error_priority = check_configuration-prio
parameter_01 = |{ pseudo_comment_counter }| ).
ENDMETHOD.


Expand All @@ -137,6 +138,4 @@ CLASS y_check_pseudo_comment_usage IMPLEMENTATION.
RAISE EXCEPTION TYPE cx_failed.
ENDIF.
ENDMETHOD.


ENDCLASS.
Loading