diff --git a/README.md b/README.md index ba6c1986..c892b80a 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,32 @@ # code pal for ABAP -[![abap package version](https://img.shields.io/endpoint?url=https://shield.abap.space/version-shield-json/github/SAP/code-pal-for-abap/src/y_code_pal_version.intf.abap/abap&label=version)](https://github.com/SAP/code-pal-for-abap/blob/master/changelog.txt) +[![abap package version](https://img.shields.io/endpoint?url=https://shield.abap.space/version-shield-json/github/SAP/code-pal-for-abap/src/y_code_pal_version.intf.abap/abap&label=version)](changelog.txt) [![license](https://img.shields.io/github/license/SAP/code-pal-for-abap)](LICENSE) -This tool supports you in writing a clean ABAP code. Clean Code allows you to read your code like well-written prose, it is easily understandable, maintainable, and extensible. In addition, you can write high quality and reliable Unit Tests without hurdles and thereby reduce the total cost of ownership of the software. +Based on the [Clean ABAP](https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md) style guide, this tool contains a set of checks to guarantee the [Clean ABAP](https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md) adherence. +Together, we both support you in writing a clean ABAP code. -Furthermore... It's **free** and **open-source**! +❣️ It's **free** and **open-source**. -It is licensed under the Apache License, Version 2.0 - see [LICENSE](LICENSE). - -## News - -**:warning: Migration Required :warning:** - -From version `v1.01.0` to `v1.02.0` the folder logic was changed, and the abapGit is not able to perform this migration automatically. Therefore, please, follow the step-by-step described in [How To Migrate](pages/how-to-migrate.md)! +## Features -Check the [change log](changelog.txt) for further information. +- Supported by Code Inspector (`SCI` / `SCII`) and ABAP Test Cockpit (ATC) (`SE80` / Eclipse); +- Ignores automatically generated code; +- Supports exemptions; +- Provides a new user-friendly way to create variants ([Profile Management](pages/how-to-configure.md)); +- Allows configuration based on: + - Threshold; + - Severity / Priority; + - Validity for productive code, test code, or both; + - Validity for objects created since a specific date; + - Validity period; + - Allow / Deny exemption. + +⚠️ Tool is not RFC-Enabled ([#268](https://github.com/SAP/code-pal-for-abap/issues/268)). -## Features +⚠️ Severities set to `Notification` / `Priority 3` by default ([#368](https://github.com/SAP/code-pal-for-abap/issues/368)). -- Checks are ready-to-use; -- Checks can be executed via SUT, SCI, SCII (Code-Inspector) and via ATC (e.g. directly in SE80, Eclipse...); -- Automatic exclusion of code which shall not be checked (e.g. generated code); -- The scope is customizable (filter option on object creation date); -- Thresholds are customizable; -- Message severity is customizable (error, warning, or notification); -- Checking may be activated in productive-code and/or test-code (customizable); -- Findings can be suppressed via Code-Inspector Pragmas; -- Usage of a "Profile Management Tool" (Optional). - -The Profile Management Tool, which is an alternative of working with SCI based variant(s), offers among others: -- An user friendly UI; -- A user-based or group-based execution of Checks; -- Creation, assignment and unassignment of Profiles (unassigning a profile will only delete it if no checks are registered to this profile); -- Import/Export a profile among systems (download/upload function – UI button or API Post Service); -- Single-Click registration of all code pal checks at once to a profile (UI button); -- Multiple execution of several profiles at the same time (the sharpest/strongest and time valid configuration/threshold will be taken); -- Delegation principle to facilitate team work (all delegates, for instance: team members, can work with the same profile); - -:warning: The checks are not RFC-Enabled due to local dependencies. - -## List of Checks +## Set of Checks - [Check Documentation](docs/check_documentation.md) @@ -56,11 +42,14 @@ The Profile Management Tool, which is an alternative of working with SCI based v - **[Execute](pages/how-to-execute.md)** - **[Contribute](pages/how-to-contribute.md)** -## Further Reading +## Recommended Readings -- [ABAP Styleguides on Clean Code](https://github.com/SAP/styleguides/blob/master/clean-abap/CleanABAP.md) -- [Writing Testable Code for ABAP](https://open.sap.com/courses/wtc1/items/2gzG0sRlN1yjkTUREB02L9) -- [ABAP Development for S/4HANA](https://open.sap.com/courses/a4h1) +- [Clean ABAP](https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md) - [ABAP 7.40 Quick Reference](https://blogs.sap.com/2015/10/25/abap-740-quick-reference/) - [ABAP Built-in Functions](https://blogs.sap.com/2015/11/30/reminder-abap-built-in-functions/) - [ABAP - Release-Specific Changes](https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abennews.htm) + +## Recommended Courses + +- [Writing Testable Code for ABAP](https://open.sap.com/courses/wtc1/items/2gzG0sRlN1yjkTUREB02L9) +- [ABAP Development for S/4HANA](https://open.sap.com/courses/a4h1) diff --git a/changelog.txt b/changelog.txt index f4f3850f..52dc1087 100644 --- a/changelog.txt +++ b/changelog.txt @@ -14,6 +14,7 @@ Whenever you upgrade code pal for ABAP, it is highly recommended to execute the 2021-04-** v.1.14.0 ------------------ +! Notification as Default Severity (#368) + Prefer LINE_EXISTS or LINE_INDEX to READ TABLE or LOOP AT (#355) + Additional option to disable exceptions/pragmas (#329) * Diffs for TABL (#359) diff --git a/pages/how-to-configure.md b/pages/how-to-configure.md index 9b186db7..b13f74f0 100644 --- a/pages/how-to-configure.md +++ b/pages/how-to-configure.md @@ -4,75 +4,81 @@ ## How to Configure -**The default customizing (initial values) is not an SAP delivered standard value.** +⚠️This documentation describes how to configure using the `Profile Management Tool` feature only. -The tool is 100% compatible with the SAP CI Framework (Code Inspector). That is, SAP Transactions: SCI and SCII. By means of these transactions, it is possible to create/run/save an inspection using our delivered CHECKS (the checks can be found under the "CODE PAL FOR ABAP" category). -It is also possible to create a CI-Variant and run the selected CHECKS using this variant at any time. This CI-Variant can be also used in SUT (ABAP CHECK REPORT), ATC or even using SAP-Workbench ABAP Editors (e.g.: SE80) or ADT (e.g.: Eclipse) with ATC/CI Integration directly (the CI-Variant will be asked). +💡Alternatively, you can use the SAP Code Inspector variants in the `SCI` transaction. -In summary, it is possible to use our tool directly in SCI/SCII, via ATC Integration, via API Call, via SUT, via CI-Variant or via Profile(s). -But keep in mind, one has to choose betweeen using CI-Variants (Code Inspector Variants) or Using Profile/s (via Transaction: Y_CODE_PAL_PROFILE, delivered along with the toolkit). Both features cannot be used in paralell in the same system for the same user. For more details on using CI-Variant/s and Profile/s, please check the section: [How to Execute](https://github.com/SAP/code-pal-for-abap/blob/master/pages/how-to-execute.md). +Table of Contents: -Furtheremore, every single CHECK can be configurable independenlty. +- [How to Configure](#how-to-configure) + - [Profiles](#1-profiles) + - [Delegates](#2-delegates) + - [Checks](#3-checks) +- [Further Features](#further-features) + - [Import / Export Profile](#import--export-profile) + - [Import via API](#import-via-api) + - [Add / Remove All Checks](#add--remove-all-checks) + - [Add Missing Checks](#add-missing-checks) -By the Check configuration: You can, +💡 The transaction `Y_CODE_PAL_PROFILE` provides access to the `Profile Management Tool`. -* Define check's validity period; -* Restrict to objects created since a specific date; -* 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 allows exemption via pseudo comments (if applicable). +### Profiles -Check behavior: +> Profiles are similar to Code Inspector Variants. -* If using a CI-Variant, just one variant can be executed per time. -* If using a profile, first, at least one profile should be assigned to your user. Then, all checks assigned to this profle will be executed. But if so, the usage of a CI-variant is no longer possible. The profile overrules a CI-variant! In order to use again a CI-variant, one has to unassign the profile(s) of his/her user; -* If multiple profiles are assigned to your user, all checks assigned to all profiles will be executed and the "strongest" or "sharpest" thresholds will be taken; -* If have no profile assigned to your user, the execution of the checks have to be made live in SCI/SCII or by means of a CI-Variant. +Behavior: -Profile behavior: +- (❗) If you assign a Profile to your user, **it overwrites the Code Inspector variant** (❗); +- If you assign multiple Profiles to your user, the tool will combine them in runtime; +- You can assign someone else Profile to your user; +- The Profile is deleted once it has no check and assigned to nobody. -* If you unassign a profile from your user, it will not delete it from the database. It means, you can reassign it to your user, and all the checks with respective customization will return; -* If you assign the `Y_CHECK_PROFILE_MESSAGE` check to the profile, you will receive an info message every time you execute the global check variant. It means, not all the checks from the variant were executed, but so the ones related to the active profile. +To create or assign it, click on the `+` button, and inform the Profile name: -Threshold behavior: - -* If you have multiple profiles, and the same check assigned to two or more profiles, it will use the check with the strongest threshold. - -### 1. Create or Assign a Profile +![create a profile](imgs/create-profile.png) -Start transaction `Y_CODE_PAL_PROFILE`, click on the `+` button, and inform the profile name. +### Delegates -![create a profile](imgs/create-profile.png) +> Delegates are the Profile owners who are allowed to configure it; +> Multiple delegates are allowed. -You can assign an already existing profile to your user. It is useful for working on a team based on the same checks. +Behavior: -### 2. Assign Delegates +- If you aren't a Delegate, you won't be able to add / change / remove a Delegate or Check. -Delegates are users which can maintain the checks. As you are creating a new check, you will be added automatically. In case you want to add someone else as an owner, click on the `+` button and inform his/her user name. +To add someone else, click on the `+` button and inform his / her user name: ![assign delegate](imgs/assign-delegate.png) -### 3. Assign Checks +### Checks -Click on the `+` button and assign the checks. +> Checks are the rules based on the [Clean ABAP](https://github.com/SAP/styleguides/blob/master/clean-abap/CleanABAP.md) style guide. -![assign check](imgs/assign-check.png) +Behavior: + +- You can define a Check threshold (if applicable); +- You can define a Check severity / priority (error / priority 1, warning / priority 2, or notification / priority 3) +- You can define a Check filter on productive code, test code, or both (if applicable); +- You can define a Check filter on object creation date; +- You can define a Check validity period; +- You can define if a Check can/cannot be exempt via pseudo-comments (if applicable). +- If you have multiple Profiles assigned to your user, the check with the"strongest" or "sharpest" thresholds will be taken; + +To assign them to your Profile, click on the `+` button: -If you want, you can change the default configuration: +![assign check](imgs/assign-check.png) ![customize check](imgs/customize-check.png) -If you do not understand the check meaning, you can check its documentation: +💡 You can use the documentation button to navigate to the Check documentation: ![check documentation](imgs/check-documentation.png) -## How to export and import customization +## Further Features -You can export and import profiles, with respective delegates and checks, using a `JSON` file. +### Import / Export Profile -It is useful when you work with multiple systems, and you want to sync the profiles between them. +You can import and export a Profile with its Delegates and Checks using a `JSON` file, here: ![import and export feature](imgs/import-export-feature.png) @@ -80,10 +86,22 @@ It is useful when you work with multiple systems, and you want to sync the profi 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 header `Content-Type` as `application/json` and `action` as `import_profile`. +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: + +![add all and remove all](imgs/) -The API returns an `HTTP 400 - Bad Request` if the file format is not valid, or if the request has a wrong `Content-Type`. +### Add Missing Checks -The API returns an `HTTP 403 - Forbidden` if the profile already exists in the system and the authentication user is not listed as a delegate. +You can add all the missing checks, comparing your Profile and the available Checks, here: -The API returns an `HTTP 500 - Internal Server Error` if the functionality is not working as expected. +![missing checks](imgs/) diff --git a/src/checks/y_check_branch_coverage.clas.abap b/src/checks/y_check_branch_coverage.clas.abap index 4b883170..f1d551c1 100644 --- a/src/checks/y_check_branch_coverage.clas.abap +++ b/src/checks/y_check_branch_coverage.clas.abap @@ -15,9 +15,8 @@ CLASS y_check_branch_coverage IMPLEMENTATION. METHOD constructor. super->constructor( ). - version = '0001'. + version = version + 1. - settings-prio = c_note. settings-threshold = 70. settings-is_threshold_reversed = abap_true. settings-disable_on_prodcode_selection = abap_true. diff --git a/src/checks/y_check_chain_decl_usage.clas.abap b/src/checks/y_check_chain_decl_usage.clas.abap index 62da2178..3dccb262 100644 --- a/src/checks/y_check_chain_decl_usage.clas.abap +++ b/src/checks/y_check_chain_decl_usage.clas.abap @@ -23,7 +23,6 @@ CLASS Y_CHECK_CHAIN_DECL_USAGE IMPLEMENTATION. settings-pseudo_comment = '"#EC CHAIN_DECL_USAG' ##NO_TEXT. settings-disable_threshold_selection = abap_true. settings-threshold = 0. - settings-prio = c_warning. settings-documentation = |{ c_docs_path-checks }chain-declaration-usage.md|. set_check_message( 'Do not chain up-front declarations!' ). diff --git a/src/checks/y_check_comment_usage.clas.abap b/src/checks/y_check_comment_usage.clas.abap index 7e50b05f..b5e0a23a 100644 --- a/src/checks/y_check_comment_usage.clas.abap +++ b/src/checks/y_check_comment_usage.clas.abap @@ -29,7 +29,6 @@ CLASS y_check_comment_usage IMPLEMENTATION. METHOD constructor. super->constructor( ). - settings-prio = c_note. settings-threshold = 10. settings-documentation = |{ c_docs_path-checks }comment-usage.md|. settings-ignore_pseudo_comments = abap_true. diff --git a/src/checks/y_check_empty_catches.clas.abap b/src/checks/y_check_empty_catches.clas.abap index 6d42844b..a64f5507 100644 --- a/src/checks/y_check_empty_catches.clas.abap +++ b/src/checks/y_check_empty_catches.clas.abap @@ -22,7 +22,6 @@ CLASS Y_CHECK_EMPTY_CATCHES IMPLEMENTATION. settings-pseudo_comment = '"#EC EMPTY_CATCH' ##NO_TEXT. settings-disable_threshold_selection = abap_true. settings-threshold = 0. - settings-prio = c_warning. settings-documentation = |{ c_docs_path-checks }empty-catch.md|. set_check_message( 'Empty catch should be removed!' ). diff --git a/src/checks/y_check_empty_procedures.clas.abap b/src/checks/y_check_empty_procedures.clas.abap index 7d617a64..ad422602 100644 --- a/src/checks/y_check_empty_procedures.clas.abap +++ b/src/checks/y_check_empty_procedures.clas.abap @@ -28,7 +28,6 @@ CLASS y_check_empty_procedures IMPLEMENTATION. settings-pseudo_comment = '"#EC EMPTY_PROCEDURE' ##NO_TEXT. settings-disable_threshold_selection = abap_true. settings-threshold = 0. - settings-prio = c_warning. settings-documentation = |{ c_docs_path-checks }empty-procedure.md|. set_check_message( 'Empty Procedure should be removed!' ). 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 8a165633..4d871f3f 100644 --- a/src/checks/y_check_is_interface_in_class.clas.abap +++ b/src/checks/y_check_is_interface_in_class.clas.abap @@ -36,7 +36,6 @@ CLASS Y_CHECK_IS_INTERFACE_IN_CLASS IMPLEMENTATION. settings-pseudo_comment = '"#EC INTF_IN_CLASS' ##NO_TEXT. settings-disable_threshold_selection = abap_true. settings-threshold = 1. - settings-prio = c_warning. settings-apply_on_test_code = abap_false. settings-documentation = |{ c_docs_path-checks }interface-in-class.md|. diff --git a/src/checks/y_check_method_return_bool.clas.abap b/src/checks/y_check_method_return_bool.clas.abap index 18fe583a..17b38224 100644 --- a/src/checks/y_check_method_return_bool.clas.abap +++ b/src/checks/y_check_method_return_bool.clas.abap @@ -26,7 +26,6 @@ CLASS Y_CHECK_METHOD_RETURN_BOOL IMPLEMENTATION. settings-pseudo_comment = '"#EC METH_RET_BOOL' ##NO_TEXT. settings-disable_threshold_selection = abap_true. settings-threshold = 0. - settings-prio = c_warning. settings-documentation = |{ c_docs_path-checks }method-return-bool.md|. relevant_statement_types = VALUE #( ( scan_struc_stmnt_type-class_definition ) diff --git a/src/checks/y_check_prefer_line_exists.clas.abap b/src/checks/y_check_prefer_line_exists.clas.abap index ccdaf278..f26c6310 100644 --- a/src/checks/y_check_prefer_line_exists.clas.abap +++ b/src/checks/y_check_prefer_line_exists.clas.abap @@ -21,7 +21,6 @@ CLASS y_check_prefer_line_exists IMPLEMENTATION. settings-pseudo_comment = '"#EC PREF_LINE_EX' ##NO_TEXT. settings-disable_threshold_selection = abap_true. settings-threshold = 0. - settings-prio = c_warning. settings-documentation = |{ c_docs_path-checks }prefer-line-exists.md|. set_check_message( 'Prefer LINE_EXISTS or LINE_INDEX to READ TABLE or LOOP AT!' ). diff --git a/src/checks/y_check_prefer_new_to_crt_obj.clas.abap b/src/checks/y_check_prefer_new_to_crt_obj.clas.abap index e30d43b2..f84f7ed4 100644 --- a/src/checks/y_check_prefer_new_to_crt_obj.clas.abap +++ b/src/checks/y_check_prefer_new_to_crt_obj.clas.abap @@ -18,7 +18,6 @@ CLASS y_check_prefer_new_to_crt_obj IMPLEMENTATION. settings-pseudo_comment = '"#EC PREF_NEW' ##NO_TEXT. settings-disable_threshold_selection = abap_true. settings-threshold = 0. - settings-prio = c_warning. settings-documentation = |{ c_docs_path-checks }prefer-new-to-create-object.md|. set_check_message( 'Prefer NEW to CREATE OBJECT!' ). diff --git a/src/checks/y_check_procedure_coverage.clas.abap b/src/checks/y_check_procedure_coverage.clas.abap index 5a86d525..d7178ae4 100644 --- a/src/checks/y_check_procedure_coverage.clas.abap +++ b/src/checks/y_check_procedure_coverage.clas.abap @@ -15,9 +15,8 @@ CLASS y_check_procedure_coverage IMPLEMENTATION. METHOD constructor. super->constructor( ). - version = '0001'. + version = version + 1. - settings-prio = c_note. settings-threshold = 30. settings-is_threshold_reversed = abap_true. settings-disable_on_prodcode_selection = abap_true. diff --git a/src/checks/y_check_profile_message.clas.abap b/src/checks/y_check_profile_message.clas.abap index 3cb4bb27..c87cdcc6 100644 --- a/src/checks/y_check_profile_message.clas.abap +++ b/src/checks/y_check_profile_message.clas.abap @@ -31,7 +31,6 @@ CLASS y_check_profile_message IMPLEMENTATION. 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.' ). ENDMETHOD. diff --git a/src/checks/y_check_pseudo_comment_usage.clas.abap b/src/checks/y_check_pseudo_comment_usage.clas.abap index 99809613..849e0700 100644 --- a/src/checks/y_check_pseudo_comment_usage.clas.abap +++ b/src/checks/y_check_pseudo_comment_usage.clas.abap @@ -53,7 +53,6 @@ CLASS y_check_pseudo_comment_usage IMPLEMENTATION. 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 ( scan_struc_stmnt_type-class_definition ) diff --git a/src/checks/y_check_returning_name.clas.abap b/src/checks/y_check_returning_name.clas.abap index ed9089aa..1b99092c 100644 --- a/src/checks/y_check_returning_name.clas.abap +++ b/src/checks/y_check_returning_name.clas.abap @@ -20,10 +20,9 @@ CLASS y_check_returning_name IMPLEMENTATION. settings-pseudo_comment = '"#EC RET_NAME' ##NO_TEXT. settings-disable_threshold_selection = abap_true. settings-threshold = 0. - settings-prio = c_warning. settings-documentation = |{ c_docs_path-checks }returning-name.md|. - version = '001'. + version = version + 1. relevant_statement_types = VALUE #( ( scan_struc_stmnt_type-class_definition ) ). relevant_structure_types = VALUE #( ). diff --git a/src/checks/y_check_scope_of_variable.clas.abap b/src/checks/y_check_scope_of_variable.clas.abap index 2b509635..ae0bef25 100644 --- a/src/checks/y_check_scope_of_variable.clas.abap +++ b/src/checks/y_check_scope_of_variable.clas.abap @@ -28,7 +28,6 @@ CLASS y_check_scope_of_variable IMPLEMENTATION. settings-pseudo_comment = '"#EC SCOPE_OF_VAR' ##NO_TEXT. settings-disable_threshold_selection = abap_true. settings-threshold = 0. - settings-prio = c_warning. settings-documentation = |{ c_docs_path-checks }scope-of-variable.md|. set_check_message( 'Variable in use out of its scope!' ). diff --git a/src/checks/y_check_statement_coverage.clas.abap b/src/checks/y_check_statement_coverage.clas.abap index 0f6337e6..c004fd09 100644 --- a/src/checks/y_check_statement_coverage.clas.abap +++ b/src/checks/y_check_statement_coverage.clas.abap @@ -15,9 +15,8 @@ CLASS y_check_statement_coverage IMPLEMENTATION. METHOD constructor. super->constructor( ). - version = '0001'. + version = version + 1. - settings-prio = c_note. settings-threshold = 60. settings-is_threshold_reversed = abap_true. settings-disable_on_prodcode_selection = abap_true. diff --git a/src/foundation/y_check_base.clas.abap b/src/foundation/y_check_base.clas.abap index 08c29768..3307562f 100644 --- a/src/foundation/y_check_base.clas.abap +++ b/src/foundation/y_check_base.clas.abap @@ -178,7 +178,7 @@ CLASS Y_CHECK_BASE IMPLEMENTATION. has_documentation = abap_true. settings-object_created_on = '20190101'. - settings-prio = c_error. + settings-prio = c_note. settings-threshold = 5. settings-apply_on_productive_code = abap_true. settings-apply_on_test_code = abap_true.