-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* regression feature (#245) * Update changelog.txt * fixing typo (#247) * Update changelog.txt * Update changelog.txt * Split 'Check LOOP' check (#246) * solves #223 * Update check_documentation.md * Create check-in-loop.md * Update check-in-loop.md * Update check-in-loop.md * Update check-statement-position.md * Update check-in-loop.md Co-authored-by: estevao-schultz-neto-SAP <63100656+estevao-schultz-neto-SAP@users.noreply.github.com> * Update changelog.txt * Coverage Thresholds (#249) * solves #243 * versioning check * fixing version * Update changelog.txt * Update check_documentation.md * Create deprecated-classes.md * Update check_documentation.md * Delete deprecated-classes.md * Deprecated Classes (#248) * new check #236 * Update check_documentation.md * Create deprecated-classes.md * Update check_documentation.md * Update y_demo_failures.clas.abap * Update changelog.txt * fixing dump (c_info > c_note) * new version * solves #252 * solves #198 Co-authored-by: estevao-schultz-neto-SAP <63100656+estevao-schultz-neto-SAP@users.noreply.github.com>
- Loading branch information
1 parent
1f246aa
commit 87806be
Showing
27 changed files
with
1,474 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# code pal for ABAP | ||
|
||
[code pal for ABAP](../../README.md) > [Documentation](../check_documentation.md) > [CHECK in LOOP](check-in-loop.md) | ||
|
||
## CHECK in LOOP | ||
|
||
### What is the Intent of the Check? | ||
It verifies whether the `CHECK` statement is found inside of a `LOOP` statement. A CHECK within a LOOP, ends the current iteration and proceeds to the next one. This behaviour might lead to confusion: Does it end the method processing or does it exit the loop? | ||
|
||
### How to solve the issue? | ||
Prefer using `CONTINUE` within an IF-Statement instead (since the keyword `CONTINUE` can only be used in loops, the intention is clear to everyone reading the code). | ||
Keep also in mind, the other Keywords like `EXIT` and `RETURN` are also more explicit. | ||
|
||
### What to do in case of exception? | ||
In special cases you can suppress this finding by using the pseudo comment `"#EC CHECK_IN_LOOP`. | ||
|
||
```abap | ||
LOOP AT tadir ASSIGNING FIELD-SYMBOL(<tadir>). | ||
CHECK <tadir>-delflag = abap_true. "#EC CHECK_IN_LOOP | ||
ENDLOOP. | ||
``` | ||
|
||
### Example | ||
Before the check: | ||
```abap | ||
LOOP AT tadir ASSIGNING FIELD-SYMBOL(<tadir>). | ||
CHECK <tadir>-delflag = abap_true. | ||
ENDLOOP. | ||
``` | ||
|
||
After the check: | ||
```abap | ||
LOOP AT tadir ASSIGNING FIELD-SYMBOL(<tadir>). | ||
IF <tadir>-delflag = abap_false. | ||
CONTINUE. | ||
ENDIF. | ||
ENDLOOP. | ||
``` | ||
|
||
### Further Readings & Knowledge | ||
- [Avoid CHECK in other positions (Clean ABAP)](https://github.com/SAP/styleguides/blob/master/clean-abap/CleanABAP.md#avoid-check-in-other-positions) | ||
- [Exiting Loops -> Check](https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapcheck_loop.htm) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# code pal for ABAP | ||
|
||
[code pal for ABAP](../../README.md) > [Documentation](../check_documentation.md) > [Deprecated Classes](deprecated-classes.md) | ||
|
||
## Deprecated Classes | ||
|
||
### What is the Intent of the Check? | ||
|
||
It points out deprecated classes which should be replaced by newer objects. | ||
|
||
You can check the list of supported objects in the `constructor` of the `y_check_deprecated_classes` class. | ||
|
||
### How does the check work? | ||
|
||
This check searches for the usage of deprecated classes. | ||
|
||
### How to solve the issue? | ||
|
||
Use the newer objects instead. | ||
|
||
### What to do in case of exception? | ||
|
||
You can suppress Code Inspector findings generated by this check using the pseudo comment `"#EC DEPRECATED_CLAS`. | ||
The pseudo comment must be placed right after the statement. | ||
|
||
Before the check: | ||
```abap | ||
DATA aunit TYPE REF TO cl_aunit_assert. | ||
``` | ||
|
||
After the check: | ||
```abap | ||
DATA aunit TYPE REF TO cl_abap_unit_assert. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
CLASS y_check_check_in_loop DEFINITION PUBLIC INHERITING FROM y_check_base CREATE PUBLIC . | ||
PUBLIC SECTION. | ||
METHODS constructor . | ||
|
||
PROTECTED SECTION. | ||
METHODS execute_check REDEFINITION. | ||
METHODS inspect_tokens REDEFINITION. | ||
|
||
PRIVATE SECTION. | ||
METHODS get_back_statement IMPORTING structure TYPE sstruc | ||
RETURNING VALUE(result) TYPE sstmnt. | ||
|
||
ENDCLASS. | ||
|
||
|
||
|
||
CLASS y_check_check_in_loop IMPLEMENTATION. | ||
|
||
|
||
METHOD constructor. | ||
super->constructor( ). | ||
|
||
settings-pseudo_comment = '"#EC CHECK_IN_LOOP' ##NO_TEXT. | ||
settings-disable_threshold_selection = abap_true. | ||
settings-threshold = 0. | ||
settings-documentation = |{ c_docs_path-checks }check-in-loop.md|. | ||
|
||
set_check_message( 'Use an IF statement in combination with CONTINUE instead CHECK!' ). | ||
ENDMETHOD. | ||
|
||
|
||
METHOD execute_check. | ||
LOOP AT ref_scan_manager->get_structures( ) ASSIGNING FIELD-SYMBOL(<structure>) | ||
WHERE stmnt_type EQ scan_struc_stmnt_type-check. | ||
|
||
is_testcode = test_code_detector->is_testcode( <structure> ). | ||
|
||
TRY. | ||
DATA(check_configuration) = check_configurations[ apply_on_testcode = abap_true ]. | ||
CATCH cx_sy_itab_line_not_found. | ||
IF is_testcode EQ abap_true. | ||
CONTINUE. | ||
ENDIF. | ||
ENDTRY. | ||
|
||
DATA(index) = <structure>-stmnt_from. | ||
|
||
LOOP AT ref_scan_manager->get_statements( ) ASSIGNING FIELD-SYMBOL(<statement>) | ||
FROM <structure>-stmnt_from TO <structure>-stmnt_to. | ||
|
||
inspect_tokens( index = index | ||
structure = <structure> | ||
statement = <statement> ). | ||
index = index + 1. | ||
ENDLOOP. | ||
ENDLOOP. | ||
ENDMETHOD. | ||
|
||
|
||
METHOD inspect_tokens. | ||
CHECK get_token_abs( statement-from ) = 'CHECK'. | ||
CHECK get_token_abs( get_back_statement( structure )-from ) = 'LOOP'. | ||
|
||
DATA(check_configuration) = detect_check_configuration( statement ). | ||
|
||
IF check_configuration IS INITIAL. | ||
RETURN. | ||
ENDIF. | ||
|
||
raise_error( statement_level = statement-level | ||
statement_index = index | ||
statement_from = statement-from | ||
error_priority = check_configuration-prio ). | ||
ENDMETHOD. | ||
|
||
|
||
METHOD get_back_statement. | ||
DATA(structures) = ref_scan_manager->get_structures( ). | ||
DATA(statements) = ref_scan_manager->get_statements( ). | ||
|
||
TRY. | ||
DATA(back_structure) = structures[ structure-back ]. | ||
result = statements[ back_structure-stmnt_from ]. | ||
CATCH cx_sy_itab_line_not_found. | ||
CLEAR result. | ||
ENDTRY. | ||
ENDMETHOD. | ||
|
||
|
||
ENDCLASS. |
Oops, something went wrong.