diff --git a/.cspell.json b/.cspell.json index 5099ad23..69dc04af 100644 --- a/.cspell.json +++ b/.cspell.json @@ -58,6 +58,8 @@ // This is useful for offensive words and common spelling errors. // For example "hte" should be "the" "flagWords": [ - "hte" + "hte", + "SUT", + "sut" ] } diff --git a/changelog.txt b/changelog.txt index 5d6cb7ba..77a5ba3d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -16,6 +16,14 @@ Legend + : added - : removed +2021-11-11 v.1.16.3 +------------------ +* Incompatibility with abapGit after commit dc4b3705216757c7533f5802d51 (#528) +* Unit test WITHOUT_ISSUE in Y_CHECK_COMMENT_USAGE fails (#527) +* Refactoring Function Check (#531) +* Unit test RFC_ENABLED in Y_CHECK_FUNCTION fails (#526) +- Remove static dependency to developer version of abapGit (#524) + 2021-11-05 v.1.16.2 ------------------ * Comment Position when Line Contains Pseudo Comment (#516) diff --git a/pages/how-to-configure.md b/pages/how-to-configure.md index 42a8c51e..8071b03b 100644 --- a/pages/how-to-configure.md +++ b/pages/how-to-configure.md @@ -82,18 +82,6 @@ You can import and export a Profile with its Delegates and Checks using a `JSON` ![import and export feature](imgs/import-export-feature.png) -### Import via API - -Once you export a profile to a `JSON` file, you can import it using the service created in the [How To Install](how-to-install.md) guide. - -To consume the API, you have to `POST` the `JSON` file to the service with the respective authentication you configured to the service (usually basic, user/pass) and with the headers `Content-Type` as `application/json` and `action` as `import_profile`. - -Possible returns: - -- `HTTP 400 - Bad Request` if the file format is not valid, or if the request has a wrong `Content-Type`; -- `HTTP 403 - Forbidden` if the profile already exists in the system and the authentication user is not listed as a delegate; -- `HTTP 500 - Internal Server Error` if the functionality is not working as expected. - ### Add / Remove All Checks You can add all and remove all the Checks from a Profile, here: diff --git a/pages/how-to-install.md b/pages/how-to-install.md index 6304e189..a09db487 100644 --- a/pages/how-to-install.md +++ b/pages/how-to-install.md @@ -29,12 +29,4 @@ It requires you to set the ABAP Test Cockpit (ATC) to run in Code Inspector mode Start the transaction `SU3`, and add/set the user parameter `SATC_CI_MODE` to `X`: -![user parameter](imgs/user-parameter.png) - -### 5. Service - -> :warning: Optional Feature! - -Start the transaction `SICF`, and create a service using the `Y_CODE_PAL_SERVICE` handler. Use procedure `Standard`, set the security session to `Completely Restricted` and check the `Use all logon procedures`. - -The client, user, and password will be empty as to will provide the authentication when you consume the API. +![user parameter](imgs/user-parameter.png) \ No newline at end of file diff --git a/src/checks/y_check_comment_usage.clas.testclasses.abap b/src/checks/y_check_comment_usage.clas.testclasses.abap index fc311301..0d117858 100644 --- a/src/checks/y_check_comment_usage.clas.testclasses.abap +++ b/src/checks/y_check_comment_usage.clas.testclasses.abap @@ -225,7 +225,7 @@ CLASS ltc_pragma IMPLEMENTATION. ( 'REPORT y_example. ' ) ( ' START-OF-SELECTION.' ) ( ' FORM example.' ) - ( | CONSTANTS mc_last_counter_values_synch TYPE sut_settings-name VALUE 'LAST_VALUES_SYNCH' ##NO_TEXT. | ) + ( | CONSTANTS mc_last_counter_values_synch TYPE string VALUE 'LAST_VALUES_SYNCH' ##NO_TEXT. | ) ( | CONSTANTS pragma_identifier VALUE '##'. | ) ( ' ENDFORM.' ) ). diff --git a/src/checks/y_check_function.clas.abap b/src/checks/y_check_function.clas.abap index e12e0d59..44206684 100644 --- a/src/checks/y_check_function.clas.abap +++ b/src/checks/y_check_function.clas.abap @@ -6,15 +6,13 @@ CLASS y_check_function DEFINITION PUBLIC INHERITING FROM y_check_base CREATE PUB METHODS inspect_tokens REDEFINITION. PRIVATE SECTION. - METHODS is_rfc_enabled IMPORTING name TYPE rs38l_fnam - RETURNING VALUE(result) TYPE abap_bool. + METHODS is_normal_mode RETURNING VALUE(result) TYPE abap_bool. ENDCLASS. -CLASS Y_CHECK_FUNCTION IMPLEMENTATION. - +CLASS y_check_function IMPLEMENTATION. METHOD constructor. super->constructor( ). @@ -32,17 +30,8 @@ CLASS Y_CHECK_FUNCTION IMPLEMENTATION. METHOD inspect_tokens. - CHECK statement-type <> scan_stmnt_type-comment. - CHECK statement-type <> scan_stmnt_type-comment_in_stmnt. - CHECK statement-type <> scan_stmnt_type-pragma. - - CHECK get_token_abs( statement-from ) = 'FUNCTION'. - - DATA(fm_name) = get_token_abs( statement-from + 1 ). - - IF is_rfc_enabled( CONV #( fm_name ) ) = abap_true. - RETURN. - ENDIF. + CHECK keyword( ) = if_kaizen_keywords_c=>gc_function. + CHECK is_normal_mode( ) = abap_true. DATA(check_configuration) = detect_check_configuration( statement ). @@ -53,12 +42,10 @@ CLASS Y_CHECK_FUNCTION IMPLEMENTATION. ENDMETHOD. - METHOD is_rfc_enabled. - SELECT SINGLE @abap_true - FROM tfdir - INTO @result - WHERE funcname = @name - AND fmode = 'R'. + METHOD is_normal_mode. + DATA(function_module) = next1( CONV #( if_kaizen_keywords_c=>gc_function ) ). + SELECT SINGLE pname INTO @DATA(function_group) FROM tfdir WHERE funcname = @function_module AND fmode = @space. + result = xsdbool( sy-subrc = 0 ). ENDMETHOD. ENDCLASS. diff --git a/src/checks/y_check_function.clas.testclasses.abap b/src/checks/y_check_function.clas.testclasses.abap index 4087e48e..e118f431 100644 --- a/src/checks/y_check_function.clas.testclasses.abap +++ b/src/checks/y_check_function.clas.testclasses.abap @@ -2,24 +2,33 @@ CLASS lth_function DEFINITION. PROTECTED SECTION. DATA cut TYPE REF TO ltd_check_function. - METHODS given_rfc_enabled. - METHODS given_rfc_disabled. + METHODS given_function_group. METHODS when_run. - METHODS then_has_issue. - METHODS then_no_issue. + METHODS then_finds. + + PRIVATE SECTION. + DATA expected_issues TYPE i. ENDCLASS. CLASS lth_function IMPLEMENTATION. - METHOD given_rfc_enabled. - SELECT SINGLE pname FROM tfdir INTO @DATA(function_group) WHERE fmode = 'R'. - cut->set_ref_scan( y_code_pal_ref_scan_double=>get_from_fuction_group( function_group ) ). - ENDMETHOD. + METHOD given_function_group. + " Get one that has RFC enabled and disabled + SELECT SINGLE tfdir~pname + FROM tfdir AS tfdir + INNER JOIN tfdir AS enabled ON enabled~pname = tfdir~pname + AND enabled~fmode <> @space + WHERE tfdir~fmode = @space + INTO @DATA(function_group). + + SELECT COUNT( * ) + FROM tfdir + WHERE pname = @function_group + AND tfdir~fmode = @space + INTO @expected_issues. - METHOD given_rfc_disabled. - SELECT SINGLE pname FROM tfdir INTO @DATA(function_group) WHERE fmode = 'X'. cut->set_ref_scan( y_code_pal_ref_scan_double=>get_from_fuction_group( function_group ) ). ENDMETHOD. @@ -27,21 +36,10 @@ CLASS lth_function IMPLEMENTATION. cut->run( ). ENDMETHOD. - METHOD then_no_issue. - cl_abap_unit_assert=>assert_initial( act = cut->get_statistics( )->count-errors - quit = if_aunit_constants=>quit-no ). - cl_abap_unit_assert=>assert_initial( act = cut->get_statistics( )->count-warnings - quit = if_aunit_constants=>quit-no ). - cl_abap_unit_assert=>assert_initial( act = cut->get_statistics( )->count-notes - quit = if_aunit_constants=>quit-no ). - cl_abap_unit_assert=>assert_initial( act = cut->get_statistics( )->count-pseudo_comments - quit = if_aunit_constants=>quit-no ). - ENDMETHOD. - - METHOD then_has_issue. - cl_abap_unit_assert=>assert_not_initial( act = cut->get_statistics( )->count-notes - quit = if_aunit_constants=>quit-no ). - + METHOD then_finds. + cl_abap_unit_assert=>assert_equals( act = cut->get_statistics( )->count-notes + exp = expected_issues + quit = if_aunit_constants=>quit-no ). cl_abap_unit_assert=>assert_initial( act = cut->get_statistics( )->count-errors quit = if_aunit_constants=>quit-no ). cl_abap_unit_assert=>assert_initial( act = cut->get_statistics( )->count-warnings @@ -56,8 +54,7 @@ ENDCLASS. CLASS ltc_function DEFINITION FOR TESTING INHERITING FROM lth_function RISK LEVEL HARMLESS. PUBLIC SECTION. - METHODS rfc_enabled FOR TESTING. - METHODS rfc_disabled FOR TESTING. + METHODS test FOR TESTING. PRIVATE SECTION. METHODS setup. @@ -71,16 +68,10 @@ CLASS ltc_function IMPLEMENTATION. cut = NEW #( ). ENDMETHOD. - METHOD rfc_enabled. - given_rfc_enabled( ). - when_run( ). - then_no_issue( ). - ENDMETHOD. - - METHOD rfc_disabled. - given_rfc_disabled( ). + METHOD test. + given_function_group( ). when_run( ). - then_has_issue( ). + then_finds( ). ENDMETHOD. ENDCLASS. diff --git a/src/foundation/y_code_pal_service.clas.abap b/src/foundation/y_code_pal_service.clas.abap deleted file mode 100644 index 0eebbcd4..00000000 --- a/src/foundation/y_code_pal_service.clas.abap +++ /dev/null @@ -1,259 +0,0 @@ -CLASS y_code_pal_service DEFINITION PUBLIC CREATE PUBLIC. - PUBLIC SECTION. - INTERFACES if_http_extension. - TYPES: BEGIN OF versions, - code_pal_for_abap TYPE string, - sap_basis TYPE string, - abapGit TYPE string, - END OF versions. - - PROTECTED SECTION. - METHODS raise_bad_request. - METHODS raise_method_not_allowed. - METHODS raise_internal_server_error. - METHODS raise_forbidden. - - METHODS execute_import_profile. - METHODS execute_get_versions. - METHODS execute_regression_test. - METHODS execute_unit_test. - METHODS execute_ping. - - METHODS get_basis_version RETURNING VALUE(result) TYPE string. - - METHODS convert_json_to_profile IMPORTING json TYPE string - RETURNING VALUE(result) TYPE y_if_profile_manager=>file - RAISING cx_abap_invalid_value. - - METHODS list_non_executed_checks IMPORTING checks TYPE y_if_profile_manager=>check_descriptions - findings TYPE scit_rest - RETURNING VALUE(result) TYPE y_if_profile_manager=>check_descriptions. - - METHODS write_non_executed_checks IMPORTING non_executed_checks TYPE y_if_profile_manager=>check_descriptions - RETURNING value(result) TYPE string. - - PRIVATE SECTION. - DATA request TYPE REF TO if_http_request. - DATA response TYPE REF TO if_http_response. - -ENDCLASS. - - -CLASS y_code_pal_service IMPLEMENTATION. - - METHOD if_http_extension~handle_request. - request = server->request. - response = server->response. - - CASE request->get_header_field( 'action' ). - WHEN 'import_profile'. - execute_import_profile( ). - WHEN 'get_versions'. - execute_get_versions( ). - WHEN 'regression_test'. - execute_regression_test( ). - WHEN 'unit_test'. - execute_unit_test( ). - WHEN 'ping'. - execute_ping( ). - WHEN OTHERS. - raise_bad_request( ). - RETURN. - ENDCASE. - ENDMETHOD. - - METHOD execute_import_profile. - IF request->get_method( ) <> 'POST'. - raise_method_not_allowed( ). - RETURN. - ENDIF. - - IF request->get_content_type( ) <> 'application/json'. - raise_bad_request( ). - RETURN. - ENDIF. - - DATA(json) = request->get_cdata( ). - - TRY. - DATA(profile) = convert_json_to_profile( json ). - CATCH cx_abap_invalid_value INTO DATA(profile_exception). - raise_bad_request( ). - response->set_cdata( |{ profile_exception->get_text( ) }: { profile_exception->get_longtext( ) }| ). - RETURN. - ENDTRY. - - DATA(profile_manager) = y_profile_manager=>create( ). - - TRY. - profile_manager->import_profile( profile ). - CATCH ycx_failed_to_add_a_line ycx_time_overlap INTO DATA(manager_exception). - raise_internal_server_error( ). - response->set_cdata( |{ manager_exception->get_text( ) }: { manager_exception->get_longtext( ) }| ). - RETURN. - CATCH ycx_no_delegation_rights. - raise_forbidden( ). - RETURN. - ENDTRY. - ENDMETHOD. - - METHOD execute_get_versions. - IF request->get_method( ) <> 'GET'. - raise_method_not_allowed( ). - RETURN. - ENDIF. - - DATA(structure) = VALUE versions( code_pal_for_abap = y_code_pal_version=>abap - sap_basis = get_basis_version( ) - abapGit = zif_abapgit_version=>gc_abap_version ). - - DATA(json) = /ui2/cl_json=>serialize( structure ). - - response->set_content_type( 'application/json' ). - response->set_cdata( json ). - ENDMETHOD. - - METHOD raise_bad_request. - response->set_status( code = '400' - reason = 'Bad Request' ). - ENDMETHOD. - - METHOD raise_method_not_allowed. - response->set_status( code = '405' - reason = 'Method Not Allowed' ). - ENDMETHOD. - - METHOD raise_forbidden. - response->set_status( code = '403' - reason = 'Forbidden' ). - ENDMETHOD. - - METHOD raise_internal_server_error. - response->set_status( code = '500' - reason = 'Internal Server Error' ). - ENDMETHOD. - - METHOD convert_json_to_profile. - /ui2/cl_json=>deserialize( EXPORTING json = json - CHANGING data = result ). - - IF result IS INITIAL. - RAISE EXCEPTION TYPE cx_abap_invalid_value. - ENDIF. - ENDMETHOD. - - METHOD get_basis_version. - SELECT SINGLE * FROM cvers INTO @DATA(cver) WHERE component = 'SAP_BASIS'. - result = |{ cver-release }-{ cver-extrelease }|. - ENDMETHOD. - - METHOD execute_regression_test. - IF request->get_method( ) <> 'GET'. - raise_method_not_allowed( ). - RETURN. - ENDIF. - - TRY. - y_profile_manager=>create( )->delete_profiles( ). - CATCH ycx_failed_to_remove_a_line. - raise_internal_server_error( ). - response->set_cdata( 'Profiles were not disabled' ). - RETURN. - ENDTRY. - - DATA(atc) = NEW cl_satc_api_factory( ). - - TRY. - DATA(object_set) = cl_satc_object_set_factory=>create_for_object_keys( VALUE #( ( obj_type = 'CLAS' obj_name = 'Y_DEMO_FAILURES' ) - ( obj_type = 'PROG' obj_name = 'Y_DEMO_FAILURES' ) ) ). - CATCH cx_satc_empty_object_set. - raise_internal_server_error( ). - response->set_cdata( 'Object set contains no checkable objects' ). - RETURN. - ENDTRY. - - TRY. - DATA(variant) = atc->get_repository( )->load_ci_check_variant( i_name = 'Y_CODE_PAL' ). - CATCH cx_satc_not_found. - raise_internal_server_error( ). - response->set_cdata( 'Specified Code Inspector variant was not found' ). - RETURN. - ENDTRY. - - DATA(configuration) = atc->create_run_config_with_chk_var( i_object_set = object_set - i_check_variant = variant - i_description = 'Y_CODE_PAL_SERVICE' ). - - DATA(controller) = atc->create_run_controller( configuration ). - - TRY. - controller->run( IMPORTING e_result_access = DATA(result_access) ). - CATCH cx_satc_failure. - raise_internal_server_error( ). - response->set_cdata( 'ATC check run failed (no authorization, etc.)' ). - RETURN. - ENDTRY. - - TRY. - result_access->get_findings( IMPORTING e_findings = DATA(findings) ). - CATCH cx_satc_failure. - raise_internal_server_error( ). - response->set_cdata( 'Result access failed (no authorization, etc.)' ). - RETURN. - ENDTRY. - - TRY. - DATA(checks) = y_profile_manager=>create( )->select_existing_checks( ). - CATCH ycx_entry_not_found INTO DATA(check_exception). - raise_internal_server_error( ). - response->set_cdata( |{ check_exception->get_text( ) }: { check_exception->get_longtext( ) }| ). - RETURN. - ENDTRY. - - DATA(non_executed_checks) = list_non_executed_checks( checks = checks - findings = findings ). - - IF non_executed_checks IS NOT INITIAL. - response->set_cdata( write_non_executed_checks( non_executed_checks ) ). - ELSE. - response->set_cdata( 'OK' ). - ENDIF. - - ENDMETHOD. - - METHOD list_non_executed_checks. - CONSTANTS maintain_attributes TYPE sci_errc VALUE 106. - - result = checks. - - LOOP AT findings ASSIGNING FIELD-SYMBOL() WHERE code <> maintain_attributes. - DELETE result WHERE checkid = -test. - ENDLOOP. - - " not supported - DELETE result WHERE checkid = 'Y_CHECK_PROFILE_MESSAGE' - OR checkid = 'Y_CHECK_TEST_SEAM_USAGE' - OR checkid = 'Y_CHECK_FUNCTION'. - ENDMETHOD. - - METHOD write_non_executed_checks. - LOOP AT non_executed_checks ASSIGNING FIELD-SYMBOL(). - result = COND #( WHEN result IS NOT INITIAL THEN |{ result }
| ). - result = |{ result }```{ sy-tabix }. { -checkid }: { -description }```|. - ENDLOOP. - IF result IS INITIAL. - RETURN. - ENDIF. - result = |Non-Executed Checks:
{ result }|. - ENDMETHOD. - - METHOD execute_unit_test. - raise_internal_server_error( ). - RETURN. - ENDMETHOD. - - METHOD execute_ping. - RETURN. - ENDMETHOD. - -ENDCLASS. diff --git a/src/foundation/y_code_pal_service.clas.xml b/src/foundation/y_code_pal_service.clas.xml deleted file mode 100644 index 3f0c228c..00000000 --- a/src/foundation/y_code_pal_service.clas.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - Y_CODE_PAL_SERVICE - E - Service for code pal for ABAP - 1 - X - X - X - - - - diff --git a/src/y_code_pal_version.intf.abap b/src/y_code_pal_version.intf.abap index aef3c370..e8319a2c 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. "#EC CONS_INTF - CONSTANTS abap TYPE string VALUE '1.16.2' ##NO_TEXT. + CONSTANTS abap TYPE string VALUE '1.16.3' ##NO_TEXT. ENDINTERFACE.