diff --git a/changelog.txt b/changelog.txt index 97e8c634..d576e9cd 100644 --- a/changelog.txt +++ b/changelog.txt @@ -8,6 +8,15 @@ Legend + : added - : removed +2020-10-10 v1.05.0 +------------------ +* profile message check runs only once +! check messages +- db access in ut when OSQL/CDS framework is being used +! category description ++ report to activate or deactivate the SCI entries ++ add/remove all check in profiles + 2020-10-05 v1.04.1 ------------------ * magic number to support numeric strings (#142) diff --git a/pages/how-to-install.md b/pages/how-to-install.md index 65b568c5..8addf1fa 100644 --- a/pages/how-to-install.md +++ b/pages/how-to-install.md @@ -12,30 +12,18 @@ Follow the step-by-step available in the abapGit documentation: [Installing onli ![how to clone repository](imgs/clone-repository.png) -### 2. Activate code pal for ABAP category +### 2. Activate code pal for ABAP -Start the transaction `SCI`, and go to the `Code Inspector > Management of > Checks` menu. -Then, select the `Y_CATEGORY_CODE_PAL` check class and save it. +Execute the report `Y_CI_CHECK_REGISTRATION` using the run mode `Activate`. -![how to activate the category](imgs/sci-management-of-checks.png) - -(In some system releases, the path to the `Check Management` might differ from the screenshot.) - -### 3. Activate code pal for ABAP checks - -Start the transaction `SCI` again, and go to the `Code Inspector > Management of > Checks` menu. -Then, select all the `Y_CHECK_*` check classes and save it. - -![how to activate the checks](imgs/sci-checks.png) - -### 4. Create code inspector variant +### 3. Create code inspector variant Start the transaction `SCI` again, and create a new global check variant. Then, select the `code pal for ABAP` group and save it. ![how to create code inspector variant](imgs/sci-check-variant.png) -### 5. User Parameter +### 4. User Parameter It requires you to set the ABAP Test Cockpit (ATC) to run in Code Inspector mode. @@ -43,7 +31,7 @@ Start the transaction `SU3`, and add/set the user parameter `SATC_CI_MODE` to `X ![user parameter](imgs/user-parameter.png) -### 6. Service +### 5. Service > :warn: Optional Feature! diff --git a/pages/imgs/sci-checks.png b/pages/imgs/sci-checks.png deleted file mode 100644 index 773a9b36..00000000 Binary files a/pages/imgs/sci-checks.png and /dev/null differ diff --git a/pages/imgs/sci-management-of-checks.png b/pages/imgs/sci-management-of-checks.png deleted file mode 100644 index 4b8656f1..00000000 Binary files a/pages/imgs/sci-management-of-checks.png and /dev/null differ diff --git a/src/categories/y_category_code_pal.clas.abap b/src/categories/y_category_code_pal.clas.abap index cd3cbb90..1206d627 100644 --- a/src/categories/y_category_code_pal.clas.abap +++ b/src/categories/y_category_code_pal.clas.abap @@ -1,14 +1,14 @@ -CLASS y_category_code_pal DEFINITION - PUBLIC - INHERITING FROM cl_ci_category_root - CREATE PUBLIC . +class Y_CATEGORY_CODE_PAL definition + public + inheriting from CL_CI_CATEGORY_ROOT + create public . - PUBLIC SECTION. +public section. - METHODS constructor . + methods CONSTRUCTOR . - METHODS if_ci_test~display_documentation - REDEFINITION . + methods IF_CI_TEST~DISPLAY_DOCUMENTATION + redefinition . PROTECTED SECTION. METHODS get_class_description RETURNING VALUE(result) TYPE string. @@ -16,7 +16,8 @@ CLASS y_category_code_pal DEFINITION ENDCLASS. -CLASS y_category_code_pal IMPLEMENTATION. + +CLASS Y_CATEGORY_CODE_PAL IMPLEMENTATION. METHOD constructor. @@ -54,5 +55,4 @@ CLASS y_category_code_pal IMPLEMENTATION. result = 'Description Not Available'. ENDTRY. ENDMETHOD. - ENDCLASS. diff --git a/src/categories/y_category_code_pal.clas.xml b/src/categories/y_category_code_pal.clas.xml index b0d50a8b..12d15ac9 100644 --- a/src/categories/y_category_code_pal.clas.xml +++ b/src/categories/y_category_code_pal.clas.xml @@ -5,7 +5,7 @@ Y_CATEGORY_CODE_PAL E - code pal for ABAP + code pal for ABAP (open source plugin) 1 X X diff --git a/src/checks/y_check_branch_coverage.clas.abap b/src/checks/y_check_branch_coverage.clas.abap index 37bcefa4..d9368322 100644 --- a/src/checks/y_check_branch_coverage.clas.abap +++ b/src/checks/y_check_branch_coverage.clas.abap @@ -19,9 +19,10 @@ CLASS y_check_branch_coverage IMPLEMENTATION. settings-is_threshold_reversed = abap_true. settings-disable_on_prodcode_selection = abap_true. settings-disable_on_testcode_selection = abap_true. + settings-apply_on_test_code = abap_false. settings-documentation = |{ c_docs_path-checks }unit-test-coverages.md|. - set_check_message( 'Branch Coverage of &1% is under the threshold of &2%.' ). + set_check_message( 'Branch Coverage of &1% does not reach the threshold of &2%!' ). ENDMETHOD. diff --git a/src/checks/y_check_call_method_usage.clas.abap b/src/checks/y_check_call_method_usage.clas.abap index cf498fbd..ca1eb8b8 100644 --- a/src/checks/y_check_call_method_usage.clas.abap +++ b/src/checks/y_check_call_method_usage.clas.abap @@ -23,7 +23,7 @@ CLASS y_check_call_method_usage IMPLEMENTATION. settings-threshold = 0. settings-documentation = |{ c_docs_path-checks }call-method-usage.md|. - set_check_message( '"CALL METHOD" Statement should not be used!' ). + set_check_message( '"CALL METHOD" statement should not be used!' ). ENDMETHOD. diff --git a/src/checks/y_check_check_stmnt_position.clas.abap b/src/checks/y_check_check_stmnt_position.clas.abap index b4b210bf..17add468 100644 --- a/src/checks/y_check_check_stmnt_position.clas.abap +++ b/src/checks/y_check_check_stmnt_position.clas.abap @@ -33,7 +33,7 @@ CLASS Y_CHECK_CHECK_STMNT_POSITION IMPLEMENTATION. settings-threshold = 0. settings-documentation = |{ c_docs_path-checks }check-statement-position.md|. - set_check_message( '"CHECK" Statement should be the very first statement.' ). + set_check_message( '"CHECK" statement should be the very first statement!' ). ENDMETHOD. diff --git a/src/checks/y_check_comment_usage.clas.abap b/src/checks/y_check_comment_usage.clas.abap index a7171001..304ab0f0 100644 --- a/src/checks/y_check_comment_usage.clas.abap +++ b/src/checks/y_check_comment_usage.clas.abap @@ -69,7 +69,7 @@ CLASS Y_CHECK_COMMENT_USAGE IMPLEMENTATION. settings-threshold = 10. settings-documentation = |{ c_docs_path-checks }comment-usage.md|. - set_check_message( '&1 comments found! This is &2% of the productive code, exceeding threshold of &3%' ). + set_check_message( '&1 comments found! This is &2% of the productive code reaching threshold of &3%!' ). ENDMETHOD. diff --git a/src/checks/y_check_cyclomatic_complexity.clas.abap b/src/checks/y_check_cyclomatic_complexity.clas.abap index 406a1b54..ee870ac5 100644 --- a/src/checks/y_check_cyclomatic_complexity.clas.abap +++ b/src/checks/y_check_cyclomatic_complexity.clas.abap @@ -60,7 +60,7 @@ CLASS Y_CHECK_CYCLOMATIC_COMPLEXITY IMPLEMENTATION. settings-threshold = 10. settings-documentation = |{ c_docs_path-checks }cyclomatic-complexity.md|. - set_check_message( 'Cyclomatic complexity is &1, exceeding threshold of &2' ). + set_check_message( 'Cyclomatic complexity is &1 reaching threshold of &2!' ). ENDMETHOD. diff --git a/src/checks/y_check_db_access_in_ut.clas.abap b/src/checks/y_check_db_access_in_ut.clas.abap index c49dfd58..0cce332f 100644 --- a/src/checks/y_check_db_access_in_ut.clas.abap +++ b/src/checks/y_check_db_access_in_ut.clas.abap @@ -1,30 +1,18 @@ -CLASS y_check_db_access_in_ut DEFINITION - PUBLIC - INHERITING FROM y_check_base - CREATE PUBLIC . - +CLASS y_check_db_access_in_ut DEFINITION PUBLIC INHERITING FROM y_check_base CREATE PUBLIC. PUBLIC SECTION. - METHODS constructor . + METHODS constructor. PROTECTED SECTION. METHODS execute_check REDEFINITION. METHODS inspect_tokens REDEFINITION. - + METHODS has_osql_or_cds_framework RETURNING VALUE(result) TYPE abap_bool. PRIVATE SECTION. - - METHODS is_persistent_object - IMPORTING - !obj_name TYPE string - RETURNING - VALUE(result) TYPE abap_bool . - - METHODS check_if_error - IMPORTING - !index TYPE i OPTIONAL - !statement TYPE sstmnt OPTIONAL . + METHODS is_persistent_object IMPORTING obj_name TYPE string + RETURNING VALUE(result) TYPE abap_bool . + METHODS check_if_error IMPORTING index TYPE i OPTIONAL + statement TYPE sstmnt OPTIONAL . ENDCLASS. - CLASS Y_CHECK_DB_ACCESS_IN_UT IMPLEMENTATION. @@ -45,6 +33,9 @@ CLASS Y_CHECK_DB_ACCESS_IN_UT IMPLEMENTATION. METHOD execute_check. + + CHECK has_osql_or_cds_framework( ) = abap_false. + LOOP AT ref_scan_manager->get_structures( ) ASSIGNING FIELD-SYMBOL() WHERE stmnt_type EQ scan_struc_stmnt_type-method. @@ -144,4 +135,14 @@ CLASS Y_CHECK_DB_ACCESS_IN_UT IMPLEMENTATION. parameter_01 = |{ key_word }| ). ENDMETHOD. + + METHOD has_osql_or_cds_framework. + DATA(tokens) = ref_scan_manager->get_tokens( ). + + IF line_exists( tokens[ str = 'IF_OSQL_TEST_ENVIRONMENT' ] ) + OR line_exists( tokens[ str = 'IF_CDS_TEST_ENVIRONMENT' ] ). + result = abap_true. + ENDIF. + ENDMETHOD. + ENDCLASS. diff --git a/src/checks/y_check_db_access_in_ut.clas.testclasses.abap b/src/checks/y_check_db_access_in_ut.clas.testclasses.abap index f07d9cb5..fb04920b 100644 --- a/src/checks/y_check_db_access_in_ut.clas.testclasses.abap +++ b/src/checks/y_check_db_access_in_ut.clas.testclasses.abap @@ -476,3 +476,105 @@ CLASS ltc_commit IMPLEMENTATION. ENDMETHOD. ENDCLASS. + +CLASS ltc_osql_framework DEFINITION INHERITING FROM y_unit_test_base FOR TESTING RISK LEVEL HARMLESS DURATION SHORT. + PROTECTED SECTION. + METHODS get_cut REDEFINITION. + METHODS get_code_with_issue REDEFINITION. + METHODS get_code_without_issue REDEFINITION. + METHODS get_code_with_exemption REDEFINITION. +ENDCLASS. + +CLASS ltc_osql_framework IMPLEMENTATION. + + METHOD get_cut. + result ?= NEW y_check_db_access_in_ut( ). + ENDMETHOD. + + METHOD get_code_with_issue. + result = VALUE #( + ( ' REPORT ut_test. ' ) + + ( ' CLASS lcl_classname DEFINITION FOR TESTING. ' ) + ( ' PUBLIC SECTION. ' ) + ( ' METHODS example FOR TESTING. ' ) + ( ' ENDCLASS.' ) + + ( ' CLASS lcl_classname IMPLEMENTATION. ' ) + ( ' METHOD example. ' ) + ( ' DATA tadir TYPE tadir. ' ) + ( ' SELECT SINGLE * FROM tadir INTO tadir. ' ) + ( ' ENDMETHOD. ' ) + ( ' ENDCLASS. ' ) + ). + ENDMETHOD. + + METHOD get_code_without_issue. + result = VALUE #( + ( ' REPORT ut_test. ' ) + + ( ' CLASS lcl_classname DEFINITION FOR TESTING. ' ) + ( ' PUBLIC SECTION. ' ) + ( ' METHODS scenario FOR TESTING. ' ) + ( ' PROTECTED SECTION. ' ) + ( ' METHODS given_fake_value. ' ) + ( ' METHODS when_select. ' ) + ( ' METHODS then_has_entry. ' ) + ( ' PRIVATE SECTION. ' ) + ( ' CLASS-DATA osql_test_environment TYPE REF TO if_osql_test_environment. ' ) + ( ' DATA cut TYPE tadir. ' ) + ( ' CLASS-METHODS class_setup. ' ) + ( ' CLASS-METHODS class_teardown. ' ) + ( ' ENDCLASS.' ) + + ( ' CLASS lcl_classname IMPLEMENTATION. ' ) + + ( ' METHOD class_setup. ' ) + ( | osql_test_environment = cl_osql_test_environment=>create( VALUE #( ( 'tadir' ) ) ). | ) + ( ' ENDMETHOD. ' ) + + ( ' METHOD class_teardown. ' ) + ( ' osql_test_environment->destroy( ). ' ) + ( ' ENDMETHOD. ' ) + + ( ' METHOD given_fake_value. ' ) + ( ' "osql_test_environment->insert_test_data( data ). ' ) + ( ' ENDMETHOD. ' ) + + ( ' METHOD when_select. ' ) + ( ' SELECT SINGLE * FROM tadir INTO cut. ' ) + ( ' ENDMETHOD. ' ) + + ( ' METHOD then_has_entry. ' ) + ( ' cl_aunit_assert=>assert_not_initial( cut ). ' ) + ( ' ENDMETHOD. ' ) + + ( ' METHOD scenario. ' ) + ( ' given_fake_value( ). ' ) + ( ' when_select( ). ' ) + ( ' then_has_entry( ). ' ) + ( ' ENDMETHOD. ' ) + + ( ' ENDCLASS. ' ) + ). + ENDMETHOD. + + METHOD get_code_with_exemption. + result = VALUE #( + ( ' REPORT ut_test. ' ) + + ( ' CLASS lcl_classname DEFINITION FOR TESTING. ' ) + ( ' PUBLIC SECTION. ' ) + ( ' METHODS example FOR TESTING. ' ) + ( ' ENDCLASS.' ) + + ( ' CLASS lcl_classname IMPLEMENTATION. ' ) + ( ' METHOD example. ' ) + ( ' DATA tadir TYPE tadir. ' ) + ( ' SELECT SINGLE * FROM tadir INTO tadir. "#EC DB_ACCESS_UT ' ) + ( ' ENDMETHOD. ' ) + ( ' ENDCLASS. ' ) + ). + ENDMETHOD. + +ENDCLASS. diff --git a/src/checks/y_check_deprecated_key_words.clas.abap b/src/checks/y_check_deprecated_key_words.clas.abap index eb20f3bc..55a0b5a9 100644 --- a/src/checks/y_check_deprecated_key_words.clas.abap +++ b/src/checks/y_check_deprecated_key_words.clas.abap @@ -28,7 +28,7 @@ CLASS Y_CHECK_DEPRECATED_KEY_WORDS IMPLEMENTATION. settings-threshold = 0. settings-documentation = |{ c_docs_path-checks }deprecated-key-word.md|. - set_check_message( '"&1" is deprecated' ). + set_check_message( '"&1" is deprecated!' ). ENDMETHOD. diff --git a/src/checks/y_check_is_interface_in_class.clas.abap b/src/checks/y_check_is_interface_in_class.clas.abap index 8f80e2d1..e7197e7f 100644 --- a/src/checks/y_check_is_interface_in_class.clas.abap +++ b/src/checks/y_check_is_interface_in_class.clas.abap @@ -28,7 +28,7 @@ CLASS Y_CHECK_IS_INTERFACE_IN_CLASS IMPLEMENTATION. settings-prio = c_warning. settings-documentation = |{ c_docs_path-checks }interface-in-class.md|. - set_check_message( '&1 public methods without interface' ). + set_check_message( '&1 public methods without interface!' ). ENDMETHOD. diff --git a/src/checks/y_check_magic_number.clas.abap b/src/checks/y_check_magic_number.clas.abap index a8a9f35a..8fa3a7ae 100644 --- a/src/checks/y_check_magic_number.clas.abap +++ b/src/checks/y_check_magic_number.clas.abap @@ -45,7 +45,7 @@ CLASS Y_CHECK_MAGIC_NUMBER IMPLEMENTATION. settings-apply_on_test_code = abap_false. settings-documentation = |{ c_docs_path-checks }magic-number.md|. - set_check_message( 'Magic Number Violation - &1 is a Magic Number' ). + set_check_message( 'Magic Number Violation - &1 is a Magic Number!' ). ENDMETHOD. diff --git a/src/checks/y_check_max_nesting_depth.clas.abap b/src/checks/y_check_max_nesting_depth.clas.abap index 4e07eabf..3d0f2ccf 100644 --- a/src/checks/y_check_max_nesting_depth.clas.abap +++ b/src/checks/y_check_max_nesting_depth.clas.abap @@ -54,7 +54,7 @@ CLASS Y_CHECK_MAX_NESTING_DEPTH IMPLEMENTATION. settings-pseudo_comment = '"#EC CI_NESTING' ##NO_TEXT. settings-documentation = |{ c_docs_path-checks }maximum-nesting-depth.md|. - set_check_message( 'Maximal nesting depth is &1, exceeding threshold of &2' ). + set_check_message( 'Maximal nesting depth is &1 reaching threshold of &2!' ). ENDMETHOD. diff --git a/src/checks/y_check_num_exec_statements.clas.abap b/src/checks/y_check_num_exec_statements.clas.abap index f539b688..c1c9e5e2 100644 --- a/src/checks/y_check_num_exec_statements.clas.abap +++ b/src/checks/y_check_num_exec_statements.clas.abap @@ -52,7 +52,7 @@ CLASS Y_CHECK_NUM_EXEC_STATEMENTS IMPLEMENTATION. add_obj_type( c_type_program ). - set_check_message( '&1 executable statements in method, exceeds threshold &2' ). + set_check_message( '&1 executable statements in method reaching threshold of &2!' ). ENDMETHOD. diff --git a/src/checks/y_check_num_output_parameter.clas.abap b/src/checks/y_check_num_output_parameter.clas.abap index 6b3d56a5..618c38cb 100644 --- a/src/checks/y_check_num_output_parameter.clas.abap +++ b/src/checks/y_check_num_output_parameter.clas.abap @@ -21,7 +21,7 @@ CLASS Y_CHECK_NUM_OUTPUT_PARAMETER IMPLEMENTATION. settings-threshold = 2. settings-documentation = |{ c_docs_path-checks }number-output-parameter.md|. - set_check_message( 'Too many output parameters!' ). + set_check_message( '&1 output parameters reaching threshold of &2!' ). ENDMETHOD. @@ -67,7 +67,9 @@ CLASS Y_CHECK_NUM_OUTPUT_PARAMETER IMPLEMENTATION. raise_error( statement_level = statement-level statement_index = index statement_from = statement-from + 1 - error_priority = configuration-prio ). + error_priority = configuration-prio + parameter_01 = |{ outputs_of_statement }| + parameter_02 = |{ configuration-threshold }| ). ENDMETHOD. diff --git a/src/checks/y_check_num_public_attributes.clas.abap b/src/checks/y_check_num_public_attributes.clas.abap index b7aae8ae..0b88f692 100644 --- a/src/checks/y_check_num_public_attributes.clas.abap +++ b/src/checks/y_check_num_public_attributes.clas.abap @@ -83,7 +83,7 @@ CLASS Y_CHECK_NUM_PUBLIC_ATTRIBUTES IMPLEMENTATION. settings-threshold = 1. settings-documentation = |{ c_docs_path-checks }number-public-attributes.md|. - set_check_message( '&1 public attributes. All attributes should be private by default.' ). + set_check_message( '&1 public attributes. All attributes should be private/protected by default!' ). ENDMETHOD. diff --git a/src/checks/y_check_number_attributes.clas.abap b/src/checks/y_check_number_attributes.clas.abap index b03b1fc9..7ae17806 100644 --- a/src/checks/y_check_number_attributes.clas.abap +++ b/src/checks/y_check_number_attributes.clas.abap @@ -77,7 +77,7 @@ CLASS Y_CHECK_NUMBER_ATTRIBUTES IMPLEMENTATION. settings-threshold = 12. settings-documentation = |{ c_docs_path-checks }number-attributes.md|. - set_check_message( '&1 attributes, exceeding threshold &2' ). + set_check_message( '&1 attributes reaching threshold of &2!' ). ENDMETHOD. diff --git a/src/checks/y_check_number_events.clas.abap b/src/checks/y_check_number_events.clas.abap index b2e31589..73a11c00 100644 --- a/src/checks/y_check_number_events.clas.abap +++ b/src/checks/y_check_number_events.clas.abap @@ -45,7 +45,7 @@ CLASS Y_CHECK_NUMBER_EVENTS IMPLEMENTATION. settings-pseudo_comment = '"#EC NUMBER_EVENTS' ##NO_TEXT. settings-documentation = |{ c_docs_path-checks }number-events.md|. - set_check_message( 'There are &1 events, exceeding threshold of &2' ). + set_check_message( '&1 events reaching threshold of &2!' ). ENDMETHOD. diff --git a/src/checks/y_check_number_interfaces.clas.abap b/src/checks/y_check_number_interfaces.clas.abap index 03aaf6c9..f925bf8e 100644 --- a/src/checks/y_check_number_interfaces.clas.abap +++ b/src/checks/y_check_number_interfaces.clas.abap @@ -47,7 +47,7 @@ CLASS Y_CHECK_NUMBER_INTERFACES IMPLEMENTATION. settings-threshold = 4. settings-documentation = |{ c_docs_path-checks }number-interfaces.md|. - set_check_message( 'There are &1 interfaces, exceeding threshold of &2' ). + set_check_message( '&1 interfaces reaching threshold of &2!' ). ENDMETHOD. diff --git a/src/checks/y_check_number_methods.clas.abap b/src/checks/y_check_number_methods.clas.abap index 7255754a..8ec1fe6f 100644 --- a/src/checks/y_check_number_methods.clas.abap +++ b/src/checks/y_check_number_methods.clas.abap @@ -49,7 +49,7 @@ CLASS Y_CHECK_NUMBER_METHODS IMPLEMENTATION. settings-threshold = 20. settings-documentation = |{ c_docs_path-checks }number-methods.md|. - set_check_message( '&1 methods, exceeding threshold of &2' ). + set_check_message( '&1 methods reaching threshold of &2!' ). ENDMETHOD. diff --git a/src/checks/y_check_procedure_coverage.clas.abap b/src/checks/y_check_procedure_coverage.clas.abap index 5652f6e6..537f4edd 100644 --- a/src/checks/y_check_procedure_coverage.clas.abap +++ b/src/checks/y_check_procedure_coverage.clas.abap @@ -19,9 +19,10 @@ CLASS y_check_procedure_coverage IMPLEMENTATION. settings-is_threshold_reversed = abap_true. settings-disable_on_prodcode_selection = abap_true. settings-disable_on_testcode_selection = abap_true. + settings-apply_on_test_code = abap_false. settings-documentation = |{ c_docs_path-checks }unit-test-coverages.md|. - set_check_message( 'Procedure Coverage of &1% is under the threshold of &2%.' ). + set_check_message( 'Procedure Coverage of &1% does not reach the threshold of &2%!' ). ENDMETHOD. diff --git a/src/checks/y_check_profile_message.clas.abap b/src/checks/y_check_profile_message.clas.abap index 6d8a176b..a745b76a 100644 --- a/src/checks/y_check_profile_message.clas.abap +++ b/src/checks/y_check_profile_message.clas.abap @@ -7,7 +7,12 @@ CLASS y_check_profile_message DEFINITION PROTECTED SECTION. METHODS execute_check REDEFINITION. METHODS inspect_tokens REDEFINITION. + METHODS inform REDEFINITION. PRIVATE SECTION. + 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. ENDCLASS. CLASS y_check_profile_message IMPLEMENTATION. @@ -26,12 +31,13 @@ CLASS y_check_profile_message IMPLEMENTATION. settings-apply_on_productive_code = abap_true. settings-prio = c_note. - set_check_message( 'code pal for ABAP Profile is being used.' ). + set_check_message( '&1 Profile(s) in use: &2.' ). ENDMETHOD. METHOD execute_check. + CHECK ran = abap_false. CHECK has_attributes = abap_false. DATA(check_configuration) = detect_check_configuration( VALUE #( level = 1 ) ). @@ -40,10 +46,16 @@ CLASS y_check_profile_message IMPLEMENTATION. RETURN. ENDIF. + DATA(profiles) = get_profiles( ). + raise_error( statement_level = 1 statement_index = 1 statement_from = 1 - error_priority = check_configuration-prio ). + error_priority = check_configuration-prio + parameter_01 = |{ lines( profiles ) }| + parameter_02 = |{ list_profiles( profiles ) }| ). + + ran = abap_true. ENDMETHOD. @@ -53,4 +65,45 @@ CLASS y_check_profile_message IMPLEMENTATION. ENDMETHOD. + 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 + p_finding_origins = p_finding_origins ). + ENDMETHOD. + + + METHOD get_profiles. + TRY. + result = y_profile_manager=>create( )->select_profiles( sy-uname ). + CATCH ycx_entry_not_found. + RETURN. + ENDTRY. + + ENDMETHOD. + + + METHOD list_profiles. + LOOP AT profiles ASSIGNING FIELD-SYMBOL(). + result = COND #( WHEN result IS INITIAL THEN -profile + ELSE |{ result }, { -profile }| ). + ENDLOOP. + ENDMETHOD. + + ENDCLASS. diff --git a/src/checks/y_check_profile_message.clas.xml b/src/checks/y_check_profile_message.clas.xml index cd776883..84e2a986 100644 --- a/src/checks/y_check_profile_message.clas.xml +++ b/src/checks/y_check_profile_message.clas.xml @@ -5,7 +5,7 @@ Y_CHECK_PROFILE_MESSAGE E - code pal for ABAP Profile Message + Profile Feature Notification (code pal for ABAP) 1 X X diff --git a/src/checks/y_check_pseudo_comment_usage.clas.abap b/src/checks/y_check_pseudo_comment_usage.clas.abap index cc06e608..ee38e13d 100644 --- a/src/checks/y_check_pseudo_comment_usage.clas.abap +++ b/src/checks/y_check_pseudo_comment_usage.clas.abap @@ -61,7 +61,7 @@ CLASS Y_CHECK_PSEUDO_COMMENT_USAGE IMPLEMENTATION. settings-apply_on_productive_code = abap_true. settings-prio = c_note. - set_check_message( '&1 pseudo comments' ). + set_check_message( '&1 pseudo comments!' ). ENDMETHOD. diff --git a/src/checks/y_check_statement_coverage.clas.abap b/src/checks/y_check_statement_coverage.clas.abap index ea02ce31..b3a89211 100644 --- a/src/checks/y_check_statement_coverage.clas.abap +++ b/src/checks/y_check_statement_coverage.clas.abap @@ -19,9 +19,10 @@ CLASS y_check_statement_coverage IMPLEMENTATION. settings-is_threshold_reversed = abap_true. settings-disable_on_prodcode_selection = abap_true. settings-disable_on_testcode_selection = abap_true. + settings-apply_on_test_code = abap_false. settings-documentation = |{ c_docs_path-checks }unit-test-coverages.md|. - set_check_message( 'Statement Coverage of &1% is under the threshold of &2%.' ). + set_check_message( 'Statement Coverage of &1% does not reach the threshold of &2%!' ). ENDMETHOD. diff --git a/src/checks/y_check_test_seam_usage.clas.abap b/src/checks/y_check_test_seam_usage.clas.abap index 25038a05..cf341826 100644 --- a/src/checks/y_check_test_seam_usage.clas.abap +++ b/src/checks/y_check_test_seam_usage.clas.abap @@ -25,7 +25,7 @@ CLASS Y_CHECK_TEST_SEAM_USAGE IMPLEMENTATION. settings-threshold = 0. settings-documentation = |{ c_docs_path-checks }test-seam-usage.md|. - set_check_message( '"TEST-SEAM" Statement should no longer be used!' ). + set_check_message( '"TEST-SEAM" statement should no longer be used!' ). ENDMETHOD. diff --git a/src/foundation/y_ci_check_registration.prog.abap b/src/foundation/y_ci_check_registration.prog.abap new file mode 100644 index 00000000..393a5c33 --- /dev/null +++ b/src/foundation/y_ci_check_registration.prog.abap @@ -0,0 +1,206 @@ +REPORT y_ci_check_registration. + +DATA: BEGIN OF comments, + title TYPE string VALUE 'code pal for ABAP - Check Activation Tool (Local Only)', + runmode TYPE string VALUE 'Please choose a run mode', + END OF comments. + +DATA: BEGIN OF messages, + checks_not_found TYPE string VALUE 'Code Pal Checks not found.', + successfully_activated TYPE string VALUE 'Entrys Successfully activated (category + checks)', + failed_activation TYPE string VALUE 'Entrys Failed to activate', + successfully_deactivated TYPE string VALUE 'Entrys Successfully deactivated (category + checks)', + failed_deactivation TYPE string VALUE 'Entrys Failed to deactivate', + done TYPE string VALUE 'Done!', + END OF messages. + +CONSTANTS: BEGIN OF reference, + check_base TYPE sci_chk VALUE 'Y_CHECK_BASE', + class TYPE tadir-object VALUE 'CLAS', + foundation TYPE string VALUE 'FOUNDATION', + checks TYPE string VALUE 'CHECKS', + modifiable TYPE e070-trstatus VALUE 'D', + modifiable_protected TYPE e070-trstatus VALUE 'L', + error TYPE c LENGTH 1 VALUE 'E', + END OF reference. + +CLASS lcl_check_registration DEFINITION. + PUBLIC SECTION. + CLASS-DATA name_tab TYPE STANDARD TABLE OF scitests-name. + + CLASS-METHODS select_object_list + RETURNING VALUE(result) LIKE name_tab + RAISING cx_failed. + + CLASS-METHODS activate_check + IMPORTING name TYPE sci_chk + RAISING cx_failed + cx_sy_create_object_error. + + CLASS-METHODS deactivate_check + IMPORTING name TYPE sci_chk + RAISING cx_failed + cx_sy_create_object_error. + + CLASS-METHODS is_check_compatible + IMPORTING name TYPE sci_chk + RAISING cx_sy_create_object_error. + + CLASS-METHODS get_category_name + RETURNING VALUE(result) TYPE sci_chk. + + PROTECTED SECTION. + PRIVATE SECTION. +ENDCLASS. + +CLASS lcl_check_registration IMPLEMENTATION. + METHOD get_category_name. + result = cl_abap_objectdescr=>describe_by_object_ref( NEW y_category_code_pal( ) )->get_relative_name( ). + ENDMETHOD. + + METHOD is_check_compatible. + IF name NE get_category_name( ). + DATA code_pal_check TYPE REF TO y_check_base. + CREATE OBJECT code_pal_check TYPE (name). + ENDIF. + ENDMETHOD. + + METHOD select_object_list. + SELECT SINGLE devclass FROM tadir + WHERE obj_name EQ @reference-check_base + AND object EQ @reference-class + AND delflag EQ @abap_false + INTO @DATA(packagename). + IF sy-subrc <> 0. + RAISE EXCEPTION TYPE cx_failed. + ENDIF. + + REPLACE reference-foundation IN packagename WITH reference-checks. + + SELECT obj_name FROM tadir + WHERE devclass EQ @packagename + AND object EQ @reference-class + AND delflag EQ @abap_false + INTO TABLE @result. + IF sy-subrc <> 0. + RAISE EXCEPTION TYPE cx_failed. + ENDIF. + + APPEND get_category_name( ) TO result. + SORT result ASCENDING AS TEXT. + ENDMETHOD. + + METHOD activate_check. + is_check_compatible( name ). + + INSERT scitests FROM name. + IF sy-subrc <> 0. + RAISE EXCEPTION TYPE cx_failed. + ENDIF. + ENDMETHOD. + + METHOD deactivate_check. + is_check_compatible( name ). + + DELETE FROM scitests WHERE name = name. + IF sy-subrc <> 0. + RAISE EXCEPTION TYPE cx_failed. + ENDIF. + ENDMETHOD. + +ENDCLASS. + +CLASS lcl_util DEFINITION. + PUBLIC SECTION. + CLASS-METHODS activate_all_checks. + + CLASS-METHODS deactivate_all_checks. + + PROTECTED SECTION. + PRIVATE SECTION. + CLASS-METHODS get_obj_list + RETURNING VALUE(result) LIKE lcl_check_registration=>name_tab. + +ENDCLASS. + +CLASS lcl_util IMPLEMENTATION. + + METHOD get_obj_list. + TRY. + result = lcl_check_registration=>select_object_list( ). + CATCH cx_failed. + MESSAGE messages-checks_not_found TYPE reference-error. + ENDTRY. + ENDMETHOD. + + METHOD activate_all_checks. + DATA(count_successes) = 0. + DATA(count_errors) = 0. + LOOP AT get_obj_list( ) ASSIGNING FIELD-SYMBOL(). + TRY. + lcl_check_registration=>activate_check( ). + count_successes = count_successes + 1. + CATCH cx_failed. + count_errors = count_errors + 1. + + + DATA dta TYPE REF TO cl_ci_tests. + + ENDTRY. + ENDLOOP. + WRITE: / |{ count_successes } { messages-successfully_activated }|. + WRITE: / |{ count_errors } { messages-failed_activation }|. + ENDMETHOD. + + METHOD deactivate_all_checks. + DATA(count_successes) = 0. + DATA(count_faults) = 0. + LOOP AT get_obj_list( ) ASSIGNING FIELD-SYMBOL(). + TRY. + lcl_check_registration=>deactivate_check( ). + count_successes = count_successes + 1. + CATCH cx_failed. + count_faults = count_faults + 1. + ENDTRY. + ENDLOOP. + WRITE: / |{ count_successes } { messages-successfully_deactivated }|. + WRITE: / |{ count_faults } { messages-failed_deactivation }|. + ENDMETHOD. + +ENDCLASS. + +START-OF-SELECTION. + + SELECTION-SCREEN BEGIN OF BLOCK part0. + SELECTION-SCREEN COMMENT /1(83) comm0 MODIF ID mg1. + + SELECTION-SCREEN BEGIN OF BLOCK part1 WITH FRAME. + SELECTION-SCREEN COMMENT /1(60) comm1 MODIF ID mg1. + PARAMETERS: p_activa RADIOBUTTON GROUP g1, + p_deacti RADIOBUTTON GROUP g1, + p_reacti RADIOBUTTON GROUP g1 DEFAULT 'X'. + SELECTION-SCREEN END OF BLOCK part1. + SELECTION-SCREEN END OF BLOCK part0. + +AT SELECTION-SCREEN OUTPUT. + comm0 = comments-title. + comm1 = comments-runmode. + +START-OF-SELECTION. + WRITE: / comments-title. + WRITE: / space. + + IF p_activa = abap_true. + lcl_util=>activate_all_checks( ). + + ELSEIF p_deacti = abap_true. + lcl_util=>deactivate_all_checks( ). + + ELSEIF p_reacti = abap_true. + lcl_util=>deactivate_all_checks( ). + lcl_util=>activate_all_checks( ). + + ENDIF. + COMMIT WORK. + + WRITE: / |{ messages-done }|. diff --git a/src/foundation/y_ci_check_registration.prog.xml b/src/foundation/y_ci_check_registration.prog.xml new file mode 100644 index 00000000..9573122d --- /dev/null +++ b/src/foundation/y_ci_check_registration.prog.xml @@ -0,0 +1,51 @@ + + + + + + Y_CI_CHECK_REGISTRATION + 1 + E + X + X + + + + R + Program Y_CHECK_REGISTRATION + 28 + + + S + P_ACTIVA + Activate + 16 + + + S + P_DEACTI + Deactivate + 18 + + + S + P_LOCAL + Keep the checks local? + 30 + + + S + P_REACTI + Reactivate + 18 + + + S + P_TRANSP + Transport ID + 20 + + + + + diff --git a/src/profiles/y_profile_admin_classes.prog.abap b/src/profiles/y_profile_admin_classes.prog.abap index 14ef1a3d..6deb48c3 100644 --- a/src/profiles/y_profile_admin_classes.prog.abap +++ b/src/profiles/y_profile_admin_classes.prog.abap @@ -258,11 +258,18 @@ CLASS lcl_util DEFINITION. "#EC NUMBER_METHODS CLASS-METHODS: get_cursor_field RETURNING VALUE(result) TYPE char20, - call_check_info. + call_check_info, + add_all_checks. + CLASS-METHODS add_check + IMPORTING + edit_mode TYPE abap_bool DEFAULT abap_false + RAISING + cx_failed. + CLASS-METHODS remove_all_checks. PRIVATE SECTION. - CLASS-METHODS request_to_replace + CLASS-METHODS request_confirmation IMPORTING - profile TYPE ytab_profiles-profile. + text_question TYPE string. ENDCLASS. @@ -387,6 +394,12 @@ CLASS lcl_check_events IMPLEMENTATION. WHEN 'BTN_REMOVE'. lcl_util=>remove_selected_check( ). + WHEN 'BTN_ADD_ALL'. + lcl_util=>add_all_checks( ). + + WHEN 'BTN_REMOVE_ALL'. + lcl_util=>remove_all_checks( ). + ENDCASE. lcl_util=>refresh_checks( ). ENDMETHOD. @@ -463,6 +476,7 @@ CLASS lcl_util IMPLEMENTATION. sy_repid = sy_repid events = NEW lcl_check_events( ) ). + checks_tree->toolbar_control( )->add_button( fcode = 'BTN_ADD' icon = '@04@' butn_type = cntb_btype_button @@ -483,6 +497,16 @@ CLASS lcl_util IMPLEMENTATION. butn_type = cntb_btype_button quickinfo = 'Check Documentation'(052) ). + checks_tree->toolbar_control( )->add_button( fcode = 'BTN_ADD_ALL' + icon = '@VY@' + butn_type = cntb_btype_button + quickinfo = 'Add All'(058) ). + + checks_tree->toolbar_control( )->add_button( fcode = 'BTN_REMOVE_ALL' + icon = '@VZ@' + butn_type = cntb_btype_button + quickinfo = 'Remove All'(059) ). + checks_tree->set_field_visibility( fieldname = 'START_DATE' is_visible = abap_true ). checks_tree->set_field_visibility( fieldname = 'END_DATE' @@ -997,7 +1021,7 @@ CLASS lcl_util IMPLEMENTATION. ENDTRY. IF profile_manager->profile_exists( structure-profile-profile ) = abap_true. - request_to_replace( structure-profile-profile ). + request_confirmation( | Would you like to replace the { structure-profile-profile } profile? | ). check_check_rights( structure-profile-profile ). ENDIF. @@ -1146,7 +1170,7 @@ CLASS lcl_util IMPLEMENTATION. METHOD init_add_check. DATA obj TYPE REF TO y_check_base. - io_check_id = ''. + "io_check_id = ''. io_check_description = ''. io_start_date = '20190101'. io_end_date = '99991231'. @@ -1193,46 +1217,59 @@ CLASS lcl_util IMPLEMENTATION. ENDMETHOD. METHOD check_customization. - CHECK user_command EQ 'ENTR_400' AND - io_check_id NE space. + CHECK user_command EQ 'ENTR_400' + AND io_check_id NE space. + + add_check( edit_mode ). + ENDMETHOD. + METHOD add_check. TRY. - DATA(check) = VALUE ytab_checks( profile = lcl_util=>get_selected_profile( )-profile - checkid = io_check_id - start_date = io_start_date - end_date = io_end_date - objects_created_on = io_creation_date - threshold = io_threshold - prio = io_prio - apply_on_productive_code = chbx_on_prodcode - apply_on_testcode = chbx_on_testcode - last_changed_by = sy-uname - last_changed_on = sy-datum - last_changed_at = sy-timlo ). + DATA(profile) = lcl_util=>get_selected_profile( )-profile. + CATCH ycx_entry_not_found. + MESSAGE 'Please select a profile!'(005) TYPE 'I'. + ENDTRY. - TRY. - profile_manager->get_check_description( check-checkid ). + DATA(check) = VALUE ytab_checks( profile = profile + checkid = io_check_id + start_date = io_start_date + end_date = io_end_date + objects_created_on = io_creation_date + threshold = io_threshold + prio = io_prio + apply_on_productive_code = chbx_on_prodcode + apply_on_testcode = chbx_on_testcode + last_changed_by = sy-uname + last_changed_on = sy-datum + last_changed_at = sy-timlo ). - CATCH ycx_entry_not_found. - MESSAGE 'Check is not registered!'(044) TYPE 'I'. - RAISE EXCEPTION TYPE cx_failed. - ENDTRY. - IF chbx_on_prodcode EQ abap_false AND chbx_on_testcode EQ abap_false. - MESSAGE 'Please choose Productive Code and/or Testcode for check execution!'(051) TYPE 'I'. - RAISE EXCEPTION TYPE cx_failed. - ENDIF. - IF edit_mode EQ abap_true. + TRY. + profile_manager->get_check_description( check-checkid ). + CATCH ycx_entry_not_found. + MESSAGE 'Check is not registered!'(044) TYPE 'I'. + RAISE EXCEPTION TYPE cx_failed. + ENDTRY. + + IF chbx_on_prodcode = abap_false + AND chbx_on_testcode = abap_false. + MESSAGE 'Please choose Productive Code and/or Testcode for check execution!'(051) TYPE 'I'. + RAISE EXCEPTION TYPE cx_failed. + ENDIF. + + TRY. + IF edit_mode = abap_true. profile_manager->check_time_overlap( check = check selected_check = lcl_util=>get_selected_check( ) ). + profile_manager->delete_check( lcl_util=>get_selected_check( ) ). ELSE. profile_manager->check_time_overlap( check = check ). ENDIF. profile_manager->insert_check( check ). - CATCH ycx_entry_not_found. - MESSAGE 'Please select a check!'(015) TYPE 'I'. + MESSAGE 'Check is not registered!'(044) TYPE 'I'. + RAISE EXCEPTION TYPE cx_failed. CATCH ycx_failed_to_add_a_line ycx_failed_to_remove_a_line. @@ -1281,13 +1318,13 @@ CLASS lcl_util IMPLEMENTATION. ENDTRY. ENDMETHOD. - METHOD request_to_replace. + METHOD request_confirmation. DATA answer TYPE c. CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING titlebar = | Confirmation | - text_question = | Would you like to replace the { profile } profile? | + text_question = text_question display_cancel_button = abap_false IMPORTING answer = answer. @@ -1297,4 +1334,72 @@ CLASS lcl_util IMPLEMENTATION. ENDIF. ENDMETHOD. + METHOD add_all_checks. + TRY. + DATA(profile) = lcl_util=>get_selected_profile( )-profile. + CATCH ycx_entry_not_found. + MESSAGE 'Please select a profile!'(005) TYPE 'I'. + ENDTRY. + + TRY. + profile_manager->check_delegation_rights( profile ). + CATCH ycx_no_delegation_rights. + MESSAGE 'You are not a delegate of the profile!'(006) TYPE 'W'. + ENDTRY. + + TRY. + profile_manager->select_checks( profile ). + request_confirmation( | Would you like to replace the current checks? | ). + CATCH ycx_entry_not_found. + request_confirmation( | Would you like to add all the checks? | ). + ENDTRY. + + profile_manager->remove_all_checks( profile ). + + TRY. + DATA(available_checks) = profile_manager->select_existing_checks( ). + CATCH ycx_entry_not_found. + MESSAGE 'Checks not registered!'(021) TYPE 'S'. + ENDTRY. + + LOOP AT available_checks ASSIGNING FIELD-SYMBOL(). + io_check_id = -checkid. + init_add_check( ). + TRY. + add_check( ). + CATCH cx_failed. + CONTINUE. + ENDTRY. + ENDLOOP. + + MESSAGE 'Action Executed Successfully!'(056) TYPE 'S'. + ENDMETHOD. + + + METHOD remove_all_checks. + TRY. + DATA(profile) = lcl_util=>get_selected_profile( )-profile. + CATCH ycx_entry_not_found. + MESSAGE 'Please select a profile!'(005) TYPE 'I'. + ENDTRY. + + TRY. + profile_manager->check_delegation_rights( profile ). + CATCH ycx_no_delegation_rights. + MESSAGE 'You are not a delegate of the profile!'(006) TYPE 'W'. + ENDTRY. + + TRY. + DATA(checks) = profile_manager->select_checks( profile ). + CATCH ycx_entry_not_found. + RETURN. + ENDTRY. + + request_confirmation( | Would you like to remove all the checks? | ). + + profile_manager->remove_all_checks( profile ). + + MESSAGE 'Action Executed Successfully!'(056) TYPE 'S'. + ENDMETHOD. + ENDCLASS. diff --git a/src/profiles/y_profile_administrator.prog.xml b/src/profiles/y_profile_administrator.prog.xml index c7b72b08..b093d337 100644 --- a/src/profiles/y_profile_administrator.prog.xml +++ b/src/profiles/y_profile_administrator.prog.xml @@ -1542,6 +1542,18 @@ Action Canceled 25 + + I + 058 + Add All + 17 + + + I + 059 + Remove All + 27 + R Profile Administrator for code pal for ABAP diff --git a/src/y_code_pal_version.intf.abap b/src/y_code_pal_version.intf.abap index 2d486691..32f2392a 100644 --- a/src/y_code_pal_version.intf.abap +++ b/src/y_code_pal_version.intf.abap @@ -1,3 +1,3 @@ INTERFACE y_code_pal_version PUBLIC. - CONSTANTS abap TYPE string VALUE '1.04.1' ##NO_TEXT. + CONSTANTS abap TYPE string VALUE '1.05.0' ##NO_TEXT. ENDINTERFACE.