From e25fb472194e5f7248f9b639e4beae3fcc427ef1 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 12 Jan 2021 09:41:32 -0300 Subject: [PATCH 01/68] Update abaplint.json --- abaplint.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/abaplint.json b/abaplint.json index 0c8cbe25..11bde8ac 100644 --- a/abaplint.json +++ b/abaplint.json @@ -135,7 +135,8 @@ "indentation": false, "inline_data_old_versions": true, "keep_single_parameter_on_one_line": false, - "keyword_case": false, + " + ": false, "line_break_multiple_parameters": false, "line_break_style": true, "line_length": false, @@ -236,6 +237,10 @@ "use_new": true, "when_others_last": true, "whitespace_end": true, - "xml_consistency": true + "xml_consistency": true, + "keyword_case": { + "ignoreExceptions": false, + "ignoreLowerClassImplmentationStatement": false + } } } From f56c4f06587f07a3a67e7b74b294364f91cce54a Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 12 Jan 2021 09:42:16 -0300 Subject: [PATCH 02/68] Update abaplint.json --- abaplint.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/abaplint.json b/abaplint.json index 11bde8ac..6f747e6a 100644 --- a/abaplint.json +++ b/abaplint.json @@ -135,8 +135,6 @@ "indentation": false, "inline_data_old_versions": true, "keep_single_parameter_on_one_line": false, - " - ": false, "line_break_multiple_parameters": false, "line_break_style": true, "line_length": false, From 5c2204adcd7baa5d1a5db2fd1a1b2acb634a1227 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 14:14:02 -0300 Subject: [PATCH 03/68] Update abaplint.json --- abaplint.json | 205 +++++++++++++++----------------------------------- 1 file changed, 60 insertions(+), 145 deletions(-) diff --git a/abaplint.json b/abaplint.json index 6f747e6a..504a5cf3 100644 --- a/abaplint.json +++ b/abaplint.json @@ -29,216 +29,131 @@ "7bit_ascii": true, "abapdoc": false, "allowed_object_naming": true, - "allowed_object_types": { - "exclude": [], - "severity": "Error", - "allowed": [] - }, - "ambiguous_statement": false, - "avoid_use": { - "exclude": [], - "severity": "Error", - "define": true, - "endselect": true, - "execSQL": true, - "kernelCall": true, - "communication": true, - "statics": true, - "systemCall": true, - "defaultKey": false, - "break": false, - "describeLines": false - }, + "allowed_object_types": false, + "ambiguous_statement": true, + "avoid_use": false, "begin_end_names": true, "begin_single_include": true, - "call_transaction_authority_check": true, - "chain_mainly_declarations": { - "exclude": [], - "severity": "Error", - "definitions": true, - "write": true, - "move": true, - "refresh": true, - "unassign": true, - "clear": true, - "hide": true, - "free": true, - "include": true, - "check": true - }, + "call_transaction_authority_check": false, + "chain_mainly_declarations": true, "check_abstract": true, "check_comments": false, - "check_ddic": true, + "check_ddic": false, "check_include": true, "check_no_handler_pragma": true, "check_subrc": false, "check_syntax": true, "check_text_elements": false, - "check_transformation_exists": true, + "check_transformation_exists": false, "class_attribute_names": false, "cloud_types": true, "colon_missing_space": true, - "commented_code": false, + "commented_code": true, "constructor_visibility_public": true, "contains_tab": false, - "cyclomatic_complexity": { - "exclude": [], - "severity": "Error", - "max": 20 - }, - "definitions_top": false, + "cyclomatic_complexity": true, + "dangerous_statement": true, + "db_operation_in_loop": false, + "definitions_top": true, "description_empty": true, - "double_space": false, + "double_space": true, "downport": true, - "empty_line_in_statement": false, + "empty_line_in_statement": true, "empty_statement": true, - "empty_structure": false, - "exit_or_check": false, - "exporting": false, - "forbidden_identifier": { - "exclude": [], - "severity": "Error", - "check": [] - }, - "forbidden_pseudo_and_pragma": { - "exclude": [], - "severity": "Error", - "pseudo": [], - "pragmas": [], - "ignoreGlobalClassDefinition": false, - "ignoreGlobalInterface": false - }, - "forbidden_void_type": { - "exclude": [], - "severity": "Error", - "check": [] - }, + "empty_structure": true, + "exit_or_check": true, + "exporting": true, + "forbidden_identifier": false, + "forbidden_pseudo_and_pragma": false, + "forbidden_void_type": false, "form_tables_obsolete": true, - "fully_type_constants": { - "exclude": [], - "severity": "Error", - "checkData": true - }, + "fully_type_constants": false, "function_module_recommendations": true, - "functional_writing": { - "exclude": [], - "severity": "Error", - "ignoreExceptions": true - }, + "functional_writing": true, "global_class": true, "identical_conditions": true, "identical_contents": true, "identical_form_names": true, + "identical_descriptions": false, "if_in_if": true, "implement_methods": true, "in_statement_indentation": false, "indentation": false, "inline_data_old_versions": true, - "keep_single_parameter_on_one_line": false, - "line_break_multiple_parameters": false, + "intf_referencing_clas": true, + "keep_single_parameter_on_one_line": true, + "line_break_multiple_parameters": true, "line_break_style": true, "line_length": false, - "line_only_punc": false, + "line_only_punc": true, "local_class_naming": false, "local_testclass_location": true, "local_variable_names": false, "main_file_contents": true, - "many_parenthesis": false, + "many_parenthesis": true, + "max_one_method_parameter_per_line": true, + "method_implemented_twice": true, "max_one_statement": true, "message_exists": true, "method_length": false, - "method_overwrites_builtin": false, + "method_overwrites_builtin": true, "method_parameter_names": false, - "mix_returning": false, + "mix_returning": true, + "modify_only_own_db_tables": false, "msag_consistency": true, - "nesting": false, + "nesting": true, "names_no_dash": true, - "newline_between_methods": { - "exclude": [], - "severity": "Error", - "count": 3, - "logic": "less" - }, + "newline_between_methods": true, "no_public_attributes": false, + "no_yoda_conditions": true, "object_naming": false, - "obsolete_statement": { - "exclude": [], - "severity": "Error", - "refresh": true, - "compute": true, - "add": false, - "subtract": false, - "multiply": true, - "move": true, - "divide": true, - "requested": true, - "occurs": true, - "setExtended": true, - "withHeaderLine": true, - "fieldSymbolStructure": true, - "typePools": true, - "load": true - }, - "omit_parameter_name": false, + "obsolete_statement": true, + "omit_parameter_name": true, "omit_receiving": true, + "parser_702_chaining": false, "parser_error": true, "parser_missing_space": true, - "prefer_inline": false, - "prefer_is_not": false, + "prefer_inline": true, + "prefer_is_not": true, + "prefer_raise_exception_new": true, "prefer_returning_to_exporting": true, "prefer_xsdbool": true, - "preferred_compare_operator": false, - "prefix_is_current_class": false, + "preferred_compare_operator": true, + "prefix_is_current_class": true, "reduce_string_templates": true, "release_idoc": true, "remove_descriptions": false, - "rfc_error_handling": false, - "selection_screen_naming": { - "exclude": [], - "severity": "Error", - "patternKind": "required", - "ignoreNames": [], - "ignorePatterns": [], - "parameter": "^P_.+$", - "selectOption": "^S_.+$" - }, - "sequential_blank": false, - "short_case": { - "exclude": [], - "severity": "Error", - "length": 1, - "allow": [] - }, + "rfc_error_handling": true, + "select_add_order_by": true, + "select_performance": true, + "selection_screen_naming": false, + "sequential_blank": true, + "short_case": true, "sicf_consistency": true, "space_before_colon": true, - "space_before_dot": { - "exclude": [], - "severity": "Error", - "ignoreGlobalDefinition": true, - "ignoreExceptions": true - }, - "sql_escape_host_variables": false, - "start_at_tab": false, + "space_before_dot": true, + "sql_escape_host_variables": true, + "start_at_tab": true, "superclass_final": true, "sy_modification": true, "tabl_enhancement_category": true, "try_without_catch": true, "type_form_parameters": true, "types_naming": false, + "uncaught_exception": true, "unknown_types": true, "unreachable_code": true, - "unused_methods": false, + "unsecure_fae": false, + "unused_methods": true, "unused_types": true, - "unused_variables": false, + "unused_variables": true, "use_bool_expression": true, - "use_line_exists": false, + "use_class_based_exceptions": true, + "use_line_exists": true, "use_new": true, "when_others_last": true, "whitespace_end": true, "xml_consistency": true, - "keyword_case": { - "ignoreExceptions": false, - "ignoreLowerClassImplmentationStatement": false - } + "keyword_case": false } } From e79df21d58b6b83617fb568eb9d27b91c2825a81 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 14:15:03 -0300 Subject: [PATCH 04/68] Update abaplint.json --- abaplint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abaplint.json b/abaplint.json index 504a5cf3..963333fb 100644 --- a/abaplint.json +++ b/abaplint.json @@ -21,7 +21,7 @@ ], "syntax": { "version": "v740sp08", - "errorNamespace": "^(Z|Y|LCL_|TY_|LIF_)", + "errorNamespace": "^(Y)", "globalConstants": ["cntb_btype_button", "scan_struc_stmnt_type", "scan_stmnt_type", "scan_struc_type", "scan_token_type"], "globalMacros": [] }, From 70ab5ca0f7b1ff93d3918c645d35fbadc5b377b5 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 15:03:21 -0300 Subject: [PATCH 05/68] disabling empty_line_in_statement --- abaplint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abaplint.json b/abaplint.json index 963333fb..681f415b 100644 --- a/abaplint.json +++ b/abaplint.json @@ -58,7 +58,7 @@ "description_empty": true, "double_space": true, "downport": true, - "empty_line_in_statement": true, + "empty_line_in_statement": false, "empty_statement": true, "empty_structure": true, "exit_or_check": true, From ae7067cb423a4a632127fb54a69afb00597711bd Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 20:08:08 +0200 Subject: [PATCH 06/68] Remove double space --- src/categories/y_category_code_pal.clas.abap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/categories/y_category_code_pal.clas.abap b/src/categories/y_category_code_pal.clas.abap index 1206d627..850b3614 100644 --- a/src/categories/y_category_code_pal.clas.abap +++ b/src/categories/y_category_code_pal.clas.abap @@ -22,7 +22,7 @@ CLASS Y_CATEGORY_CODE_PAL IMPLEMENTATION. METHOD constructor. super->constructor( ). - description = get_class_description( ). + description = get_class_description( ). category = 'CL_CI_CATEGORY_TOP'. position = '001'. ENDMETHOD. From 67eaa0a853d02ac5b11603b3821ad34ee77dcbb2 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 15:09:34 -0300 Subject: [PATCH 07/68] disabling exit_or_check --- abaplint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abaplint.json b/abaplint.json index 681f415b..0d7d617d 100644 --- a/abaplint.json +++ b/abaplint.json @@ -61,7 +61,7 @@ "empty_line_in_statement": false, "empty_statement": true, "empty_structure": true, - "exit_or_check": true, + "exit_or_check": false, "exporting": true, "forbidden_identifier": false, "forbidden_pseudo_and_pragma": false, From 52740883de499cd3eb7cf75d2c9d980ae5c15754 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 15:14:43 -0300 Subject: [PATCH 08/68] disabling line_only_punc Reporting false-positives: https://github.com/abaplint/abaplint/issues/1888 --- abaplint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abaplint.json b/abaplint.json index 0d7d617d..d32d1436 100644 --- a/abaplint.json +++ b/abaplint.json @@ -85,7 +85,7 @@ "line_break_multiple_parameters": true, "line_break_style": true, "line_length": false, - "line_only_punc": true, + "line_only_punc": false, "local_class_naming": false, "local_testclass_location": true, "local_variable_names": false, From 3aa55937dacb47a1729a6be2c6de3483801400c2 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 15:19:01 -0300 Subject: [PATCH 09/68] Update abaplint.json --- abaplint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abaplint.json b/abaplint.json index d32d1436..a0303b15 100644 --- a/abaplint.json +++ b/abaplint.json @@ -146,7 +146,7 @@ "unsecure_fae": false, "unused_methods": true, "unused_types": true, - "unused_variables": true, + "unused_variables": false, "use_bool_expression": true, "use_class_based_exceptions": true, "use_line_exists": true, From 2ce5368cfd6a2886a176cd724ec8b0f4ca324bda Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 15:26:01 -0300 Subject: [PATCH 10/68] Update abaplint.json --- abaplint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abaplint.json b/abaplint.json index a0303b15..c0cfbc3c 100644 --- a/abaplint.json +++ b/abaplint.json @@ -56,7 +56,7 @@ "db_operation_in_loop": false, "definitions_top": true, "description_empty": true, - "double_space": true, + "double_space": false, "downport": true, "empty_line_in_statement": false, "empty_statement": true, From 521b5958e040917d2185c10ed5fba489bf973d89 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 20:28:19 +0200 Subject: [PATCH 11/68] Compare operator "EQ" not preferred --- .../y_check_check_stmnt_position.clas.abap | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/checks/y_check_check_stmnt_position.clas.abap b/src/checks/y_check_check_stmnt_position.clas.abap index dc3713c7..1d9bfbbe 100644 --- a/src/checks/y_check_check_stmnt_position.clas.abap +++ b/src/checks/y_check_check_stmnt_position.clas.abap @@ -59,15 +59,15 @@ CLASS y_check_check_stmnt_position IMPLEMENTATION. METHOD is_not_relevant_token. - result = xsdbool( token EQ 'METHOD' - OR token EQ 'FORM' - OR token EQ 'FUNCTION' - OR token EQ 'MODULE' - OR token EQ 'DATA' - OR token EQ 'TYPES' - OR token EQ 'CHECK' - OR token EQ 'FIELD-SYMBOLS' - OR token EQ 'CONSTANTS' ). + result = xsdbool( token = 'METHOD' + OR token = 'FORM' + OR token = 'FUNCTION' + OR token = 'MODULE' + OR token = 'DATA' + OR token = 'TYPES' + OR token = 'CHECK' + OR token = 'FIELD-SYMBOLS' + OR token = 'CONSTANTS' ). ENDMETHOD. From 78a7828e41ddb7dfe5dd4a1f2da27cd8a5bdafbb Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 15:31:51 -0300 Subject: [PATCH 12/68] Disabling no_yoda_conditions https://github.com/abaplint/abaplint/issues/1891 --- abaplint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abaplint.json b/abaplint.json index c0cfbc3c..714e72ba 100644 --- a/abaplint.json +++ b/abaplint.json @@ -105,7 +105,7 @@ "names_no_dash": true, "newline_between_methods": true, "no_public_attributes": false, - "no_yoda_conditions": true, + "no_yoda_conditions": false, "object_naming": false, "obsolete_statement": true, "omit_parameter_name": true, From 685301cc3413e9f454cc0898d53a2bc2e51f251a Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 20:33:17 +0200 Subject: [PATCH 13/68] Method "get_first_character" not used --- src/checks/y_check_comment_position.clas.abap | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/checks/y_check_comment_position.clas.abap b/src/checks/y_check_comment_position.clas.abap index a3e57e3f..b4564d45 100644 --- a/src/checks/y_check_comment_position.clas.abap +++ b/src/checks/y_check_comment_position.clas.abap @@ -9,9 +9,6 @@ CLASS y_check_comment_position DEFINITION PUBLIC INHERITING FROM y_check_base CR METHODS has_wrong_position IMPORTING statement TYPE sstmnt RETURNING VALUE(result) TYPE abap_bool. - METHODS get_first_character IMPORTING token TYPE stokesx - RETURNING VALUE(result) TYPE char1. - METHODS is_pseudo_comment IMPORTING token TYPE stokesx RETURNING VALUE(result) TYPE abap_bool. @@ -102,15 +99,6 @@ CLASS Y_CHECK_COMMENT_POSITION IMPLEMENTATION. ENDMETHOD. - METHOD get_first_character. - TRY. - result = token-str(1). - CATCH cx_sy_range_out_of_bounds. - CLEAR result. - ENDTRY. - ENDMETHOD. - - METHOD is_pseudo_comment. TRY. result = xsdbool( token-str(4) = '"#EC' ). From 5f92bd2223ee6a83a7d97b1d411873395e7c29da Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 20:40:29 +0200 Subject: [PATCH 14/68] Compare operator "EQ" not preferred --- src/checks/y_check_comment_usage.clas.abap | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/checks/y_check_comment_usage.clas.abap b/src/checks/y_check_comment_usage.clas.abap index ab4472be..1c2876bb 100644 --- a/src/checks/y_check_comment_usage.clas.abap +++ b/src/checks/y_check_comment_usage.clas.abap @@ -62,7 +62,7 @@ CLASS y_check_comment_usage IMPLEMENTATION. RETURN. ENDIF. - IF statement-to EQ statement-from. + IF statement-to = statement-from. abs_statement_number = abs_statement_number + 1. ELSE. abs_statement_number = abs_statement_number + ( statement-to - statement-from ). @@ -70,14 +70,14 @@ CLASS y_check_comment_usage IMPLEMENTATION. LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL() FROM statement-from TO statement-to - WHERE type EQ scan_token_type-comment. + WHERE type = scan_token_type-comment. IF strlen( -str ) GE 2 AND NOT - ( -str+0(2) EQ |*"| OR - -str+0(2) EQ |"!| OR - -str+0(2) EQ |##| OR - -str+0(2) EQ |*?| OR - -str+0(2) EQ |"?| OR - ( strlen( -str ) GE 3 AND -str+0(3) EQ |"#E| ) OR + ( -str+0(2) = |*"| OR + -str+0(2) = |"!| OR + -str+0(2) = |##| OR + -str+0(2) = |*?| OR + -str+0(2) = |"?| OR + ( strlen( -str ) GE 3 AND -str+0(3) = |"#E| ) OR -str CP '"' && object_name && '*.' ). "#EC CI_MAGIC comment_number = comment_number + 1. ENDIF. @@ -119,15 +119,15 @@ CLASS y_check_comment_usage IMPLEMENTATION. METHOD is_code_disabled. - CHECK structure-stmnt_type EQ scan_struc_stmnt_type-function. + CHECK structure-stmnt_type = scan_struc_stmnt_type-function. - IF get_token_abs( statement-from ) EQ if_kaizen_keywords_c=>gc_function. + IF get_token_abs( statement-from ) = if_kaizen_keywords_c=>gc_function. is_function_module = abap_true. - ELSEIF get_token_abs( statement-from ) EQ if_kaizen_keywords_c=>gc_endfunction. + ELSEIF get_token_abs( statement-from ) = if_kaizen_keywords_c=>gc_endfunction. is_function_module = abap_false. ENDIF. - result = xsdbool( is_function_module EQ abap_false ). + result = xsdbool( is_function_module = abap_false ). ENDMETHOD. From eb5dbba521189923e01331e0ff3b289a38b6e811 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 20:42:01 +0200 Subject: [PATCH 15/68] Keep single parameter on one line --- src/checks/y_check_cyclomatic_complexity.clas.abap | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/checks/y_check_cyclomatic_complexity.clas.abap b/src/checks/y_check_cyclomatic_complexity.clas.abap index 4bf92e31..1847e6f2 100644 --- a/src/checks/y_check_cyclomatic_complexity.clas.abap +++ b/src/checks/y_check_cyclomatic_complexity.clas.abap @@ -70,9 +70,7 @@ CLASS Y_CHECK_CYCLOMATIC_COMPLEXITY IMPLEMENTATION. cyclo_comp = 0. ENDIF. - compute_cyclomatic_complexity( - CHANGING - c_cyclo_comp = cyclo_comp ). + compute_cyclomatic_complexity( CHANGING c_cyclo_comp = cyclo_comp ). IF index = structure-stmnt_to. DATA(check_configuration) = detect_check_configuration( error_count = cyclo_comp From 3d36508c72c2d2fb36dec5ff27268cecf339a1b4 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 20:43:30 +0200 Subject: [PATCH 16/68] Statement "ADD" is obsolete --- src/checks/y_check_cyclomatic_complexity.clas.abap | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/checks/y_check_cyclomatic_complexity.clas.abap b/src/checks/y_check_cyclomatic_complexity.clas.abap index 1847e6f2..e1a21298 100644 --- a/src/checks/y_check_cyclomatic_complexity.clas.abap +++ b/src/checks/y_check_cyclomatic_complexity.clas.abap @@ -29,15 +29,15 @@ CLASS Y_CHECK_CYCLOMATIC_COMPLEXITY IMPLEMENTATION. WHEN 'IF' OR 'ELSEIF' OR 'WHILE' OR 'CHECK' OR 'CATCH' OR 'CLEANUP' OR 'ASSERT' OR 'ENDAT' OR 'ENDSELECT' OR 'LOOP' OR 'ON' OR 'PROVIDE'. - ADD 1 TO c_cyclo_comp. + c_cyclo_comp = c_cyclo_comp + 1. WHEN 'WHEN'. IF get_token_rel( second_token ) <> 'OTHERS'. - ADD 1 TO c_cyclo_comp. + c_cyclo_comp = c_cyclo_comp + 1. ENDIF. WHEN 'DO'. READ TABLE ref_scan_manager->tokens INDEX statement_wa-to INTO DATA(token). IF token-str = 'TIMES'. - ADD 1 TO c_cyclo_comp. + c_cyclo_comp = c_cyclo_comp + 1. ENDIF. ENDCASE. ENDMETHOD. From 9b527a1d8da90f1b7f5809b6d41a7a139043ca0c Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 15:44:26 -0300 Subject: [PATCH 17/68] Compare operator "GE" not preferred Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> --- src/checks/y_check_comment_usage.clas.abap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/checks/y_check_comment_usage.clas.abap b/src/checks/y_check_comment_usage.clas.abap index 1c2876bb..39800873 100644 --- a/src/checks/y_check_comment_usage.clas.abap +++ b/src/checks/y_check_comment_usage.clas.abap @@ -71,7 +71,7 @@ CLASS y_check_comment_usage IMPLEMENTATION. LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL() FROM statement-from TO statement-to WHERE type = scan_token_type-comment. - IF strlen( -str ) GE 2 AND NOT + IF strlen( -str ) >= 2 AND NOT ( -str+0(2) = |*"| OR -str+0(2) = |"!| OR -str+0(2) = |##| OR From 89b2033fd36b79d2410582bb8c32dcbc3d72e6b7 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 15:45:09 -0300 Subject: [PATCH 18/68] Compare operator "GE" not preferred Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> --- src/checks/y_check_comment_usage.clas.abap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/checks/y_check_comment_usage.clas.abap b/src/checks/y_check_comment_usage.clas.abap index 39800873..4cbbfbef 100644 --- a/src/checks/y_check_comment_usage.clas.abap +++ b/src/checks/y_check_comment_usage.clas.abap @@ -77,7 +77,7 @@ CLASS y_check_comment_usage IMPLEMENTATION. -str+0(2) = |##| OR -str+0(2) = |*?| OR -str+0(2) = |"?| OR - ( strlen( -str ) GE 3 AND -str+0(3) = |"#E| ) OR + ( strlen( -str ) >= 3 AND -str+0(3) = |"#E| ) OR -str CP '"' && object_name && '*.' ). "#EC CI_MAGIC comment_number = comment_number + 1. ENDIF. From d8b87cd8d48e2e7e6e679e9639d689a96b6d3d8f Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 20:48:09 +0200 Subject: [PATCH 19/68] Compare operator "EQ" not preferred --- src/checks/y_check_cx_root_usage.clas.abap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/checks/y_check_cx_root_usage.clas.abap b/src/checks/y_check_cx_root_usage.clas.abap index 81b5cb8e..2d4bb958 100644 --- a/src/checks/y_check_cx_root_usage.clas.abap +++ b/src/checks/y_check_cx_root_usage.clas.abap @@ -48,7 +48,7 @@ CLASS y_check_cx_root_usage IMPLEMENTATION. METHOD has_cx_root. LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL() FROM statement-from TO statement-to - WHERE str EQ 'CX_ROOT'. + WHERE str = 'CX_ROOT'. result = abap_true. ENDLOOP. ENDMETHOD. From 957c86ee7d5e367f3a69d3c614e5d4c453932af4 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 20:56:02 +0200 Subject: [PATCH 20/68] Avoid use of SELECT * --- src/checks/y_check_db_access_in_ut.clas.abap | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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 5287d77b..a7e1ed68 100644 --- a/src/checks/y_check_db_access_in_ut.clas.abap +++ b/src/checks/y_check_db_access_in_ut.clas.abap @@ -117,11 +117,13 @@ CLASS Y_CHECK_DB_ACCESS_IN_UT IMPLEMENTATION. METHOD is_persistent_object. DATA(upper_name) = to_upper( obj_name ). - SELECT * FROM tadir - WHERE obj_name = @upper_name - AND object = @keys-table - AND delflag = @space - INTO TABLE @DATA(tmp). + + SELECT SINGLE obj_name + FROM tadir + WHERE obj_name = @upper_name + AND object = @keys-table + AND delflag = @space + INTO @DATA(tmp). result = xsdbool( sy-subrc = 0 ). ENDMETHOD. From 10d3fe44c5cbf2c55d79446bd531833630c3b986 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 20:59:53 +0200 Subject: [PATCH 21/68] Uncaught exception cx_sy_itab_line_not_found --- src/checks/y_check_db_access_in_ut.clas.abap | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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 a7e1ed68..97558065 100644 --- a/src/checks/y_check_db_access_in_ut.clas.abap +++ b/src/checks/y_check_db_access_in_ut.clas.abap @@ -54,6 +54,7 @@ CLASS y_check_db_access_in_ut DEFINITION PUBLIC INHERITING FROM y_check_base CRE METHODS add_line_to_defined_classes IMPORTING statement TYPE sstmnt structure TYPE sstruc. + METHODS check_class IMPORTING index TYPE i statement TYPE sstmnt structure TYPE sstruc. @@ -147,7 +148,11 @@ CLASS Y_CHECK_DB_ACCESS_IN_UT IMPLEMENTATION. METHOD add_line_to_defined_classes. - DATA(class_config) = VALUE properties( name = get_class_name( structure ) ). + TRY. + DATA(class_config) = VALUE properties( name = get_class_name( structure ) ). + CATCH cx_sy_itab_line_not_found. + RETURN. + ENDTRY. IF line_exists( defined_classes[ name = class_config-name ] ). RETURN. @@ -162,7 +167,12 @@ CLASS Y_CHECK_DB_ACCESS_IN_UT IMPLEMENTATION. METHOD check_class. - DATA(class_name) = get_class_name( structure ). + TRY. + DATA(class_name) = get_class_name( structure ). + CATCH cx_sy_itab_line_not_found. + RETURN. + ENDTRY. + IF NOT line_exists( defined_classes[ name = class_name ] ). RETURN. ENDIF. From ff7dad8ad716ba50a55e790cc43b8df71526ae45 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:04:20 +0200 Subject: [PATCH 22/68] Compare operator "EQ", "LT, "GT" not preferred --- src/checks/y_check_empty_catches.clas.abap | 8 ++++---- src/checks/y_check_empty_if_branches.clas.abap | 14 +++++++------- src/checks/y_check_empty_procedures.clas.abap | 2 +- src/checks/y_check_equals_sign_chaining.clas.abap | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/checks/y_check_empty_catches.clas.abap b/src/checks/y_check_empty_catches.clas.abap index 33694ed9..a07e59bb 100644 --- a/src/checks/y_check_empty_catches.clas.abap +++ b/src/checks/y_check_empty_catches.clas.abap @@ -31,7 +31,7 @@ CLASS Y_CHECK_EMPTY_CATCHES IMPLEMENTATION. METHOD get_next_token_from_index. LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL() - FROM index WHERE type EQ 'I'. + FROM index WHERE type ='I'. IF result IS INITIAL. result = . EXIT. @@ -41,9 +41,9 @@ CLASS Y_CHECK_EMPTY_CATCHES IMPLEMENTATION. METHOD inspect_tokens. - CHECK get_next_token_from_index( statement-from )-str EQ 'CATCH' AND - ( get_next_token_from_index( statement-to + 1 )-str EQ 'ENDTRY' OR - get_next_token_from_index( statement-to + 1 )-str EQ 'ENDCATCH' ). + CHECK get_next_token_from_index( statement-from )-str ='CATCH' AND + ( get_next_token_from_index( statement-to + 1 )-str ='ENDTRY' OR + get_next_token_from_index( statement-to + 1 )-str ='ENDCATCH' ). DATA(check_configuration) = detect_check_configuration( statement ). diff --git a/src/checks/y_check_empty_if_branches.clas.abap b/src/checks/y_check_empty_if_branches.clas.abap index 43f38de5..fe2fe16b 100644 --- a/src/checks/y_check_empty_if_branches.clas.abap +++ b/src/checks/y_check_empty_if_branches.clas.abap @@ -94,7 +94,7 @@ CLASS y_check_empty_if_branches IMPLEMENTATION. METHOD get_first_token_from_index. LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL() FROM index - WHERE type EQ 'I'. + WHERE type = 'I'. IF result IS INITIAL. result = . EXIT. @@ -116,22 +116,22 @@ CLASS y_check_empty_if_branches IMPLEMENTATION. METHOD is_statement_type_excluded. - result = xsdbool( statement-type EQ scan_stmnt_type-empty OR - statement-type EQ scan_stmnt_type-comment OR - statement-type EQ scan_stmnt_type-comment_in_stmnt OR - statement-type EQ scan_stmnt_type-pragma ). + result = xsdbool( statement-type = scan_stmnt_type-empty OR + statement-type = scan_stmnt_type-comment OR + statement-type = scan_stmnt_type-comment_in_stmnt OR + statement-type = scan_stmnt_type-pragma ). ENDMETHOD. METHOD set_found_statement_to_false. - IF branch_counter LT first_if. + IF branch_counter < first_if. found_statement = abap_false. ENDIF. ENDMETHOD. METHOD set_found_statement_to_true. - IF branch_counter GT first_if. + IF branch_counter > first_if. found_statement = abap_true. ENDIF. ENDMETHOD. diff --git a/src/checks/y_check_empty_procedures.clas.abap b/src/checks/y_check_empty_procedures.clas.abap index f05a9800..7d617a64 100644 --- a/src/checks/y_check_empty_procedures.clas.abap +++ b/src/checks/y_check_empty_procedures.clas.abap @@ -37,7 +37,7 @@ CLASS y_check_empty_procedures IMPLEMENTATION. METHOD get_next_token_from_index. LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL() - FROM index WHERE type EQ 'I'. + FROM index WHERE type = 'I'. IF result IS INITIAL. result = . EXIT. diff --git a/src/checks/y_check_equals_sign_chaining.clas.abap b/src/checks/y_check_equals_sign_chaining.clas.abap index bcd06ece..ea137ae7 100644 --- a/src/checks/y_check_equals_sign_chaining.clas.abap +++ b/src/checks/y_check_equals_sign_chaining.clas.abap @@ -33,8 +33,8 @@ CLASS y_check_equals_sign_chaining IMPLEMENTATION. METHOD inspect_tokens. - CHECK get_second_token( statement ) EQ '='. - CHECK get_fourth_token( statement ) EQ '='. + CHECK get_second_token( statement ) = '='. + CHECK get_fourth_token( statement ) = '='. DATA(check_configuration) = detect_check_configuration( statement ). From 74bf8bfd3cc648f9ba536ee9c358ffaeade5025f Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:06:14 +0200 Subject: [PATCH 23/68] Reorder definitions to top of routine --- src/checks/y_check_external_call_in_ut.clas.abap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/checks/y_check_external_call_in_ut.clas.abap b/src/checks/y_check_external_call_in_ut.clas.abap index f32545cc..7e8bd4f7 100644 --- a/src/checks/y_check_external_call_in_ut.clas.abap +++ b/src/checks/y_check_external_call_in_ut.clas.abap @@ -54,6 +54,8 @@ CLASS y_check_external_call_in_ut IMPLEMENTATION. METHOD inspect_tokens. + DATA has_redirection TYPE abap_bool VALUE abap_false. + DATA(token1) = get_token_abs( statement-from ). DATA(token2) = get_token_abs( statement-from + 1 ). DATA(token3) = get_token_abs( statement-from + 2 ). @@ -62,8 +64,6 @@ CLASS y_check_external_call_in_ut IMPLEMENTATION. DATA(token6) = get_token_abs( statement-from + 5 ). DATA(token4to6) = |{ token4 } { token5 } { token6 }|. - DATA has_redirection TYPE abap_bool VALUE abap_false. - CASE token1. WHEN 'SUBMIT'. has_redirection = abap_true. From b70c04a33c5814f17e6b2aefdb3db2206eeaae31 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:10:09 +0200 Subject: [PATCH 24/68] Too many parenthesis, simple --- src/checks/y_check_external_call_in_ut.clas.abap | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/checks/y_check_external_call_in_ut.clas.abap b/src/checks/y_check_external_call_in_ut.clas.abap index 7e8bd4f7..36dd874a 100644 --- a/src/checks/y_check_external_call_in_ut.clas.abap +++ b/src/checks/y_check_external_call_in_ut.clas.abap @@ -68,13 +68,13 @@ CLASS y_check_external_call_in_ut IMPLEMENTATION. WHEN 'SUBMIT'. has_redirection = abap_true. WHEN 'CALL'. - IF ( token2 = 'FUNCTION' ) AND - ( ( token4 = 'DESTINATION' ) OR - ( ( token4to6 = 'STARTING NEW TASK' ) ) OR - ( ( token4to6 = 'IN UPDATE TASK' ) ) ). + IF token2 = 'FUNCTION' + AND ( token4 = 'DESTINATION' + OR token4to6 = 'STARTING NEW TASK' + OR token4to6 = 'IN UPDATE TASK' ). has_redirection = abap_true. - ELSEIF ( token2 = 'METHOD' ) AND - ( token3 CS 'CL_GUI_' ). + ELSEIF token2 = 'METHOD' + AND token3 CS 'CL_GUI_'. has_redirection = abap_true. ENDIF. WHEN OTHERS. From 278db7b79cd5a9f7b7fde973e78f297e7336ccd3 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:12:03 +0200 Subject: [PATCH 25/68] Prefer Inline Declarations, CHECK_CONFIGURATION --- src/checks/y_check_external_call_in_ut.clas.abap | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/checks/y_check_external_call_in_ut.clas.abap b/src/checks/y_check_external_call_in_ut.clas.abap index 36dd874a..da6c59b4 100644 --- a/src/checks/y_check_external_call_in_ut.clas.abap +++ b/src/checks/y_check_external_call_in_ut.clas.abap @@ -17,20 +17,17 @@ CLASS y_check_external_call_in_ut IMPLEMENTATION. METHOD check_if_error. - DATA check_configuration TYPE y_if_clean_code_manager=>check_configuration. - DATA(key_word) = get_token_abs( statement-from ). - - check_configuration = detect_check_configuration( statement ). + 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 - parameter_01 = |{ key_word }| ). + raise_error( statement_level = statement-level + statement_index = index + statement_from = statement-from + error_priority = check_configuration-prio + parameter_01 = get_token_abs( statement-from ) ). ENDMETHOD. From 199ed5a08983718894f1d31cde77e827bc9bb5fc Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:14:24 +0200 Subject: [PATCH 26/68] Missing space between string or character literal --- src/checks/y_check_empty_catches.clas.abap | 6 +- .../y_check_prefer_line_exists.clas.abap | 61 ++++++++++++ ...k_prefer_line_exists.clas.testclasses.abap | 99 +++++++++++++++++++ .../y_check_prefer_line_exists.clas.xml | 17 ++++ 4 files changed, 180 insertions(+), 3 deletions(-) create mode 100644 src/checks/y_check_prefer_line_exists.clas.abap create mode 100644 src/checks/y_check_prefer_line_exists.clas.testclasses.abap create mode 100644 src/checks/y_check_prefer_line_exists.clas.xml diff --git a/src/checks/y_check_empty_catches.clas.abap b/src/checks/y_check_empty_catches.clas.abap index a07e59bb..3abb6964 100644 --- a/src/checks/y_check_empty_catches.clas.abap +++ b/src/checks/y_check_empty_catches.clas.abap @@ -41,9 +41,9 @@ CLASS Y_CHECK_EMPTY_CATCHES IMPLEMENTATION. METHOD inspect_tokens. - CHECK get_next_token_from_index( statement-from )-str ='CATCH' AND - ( get_next_token_from_index( statement-to + 1 )-str ='ENDTRY' OR - get_next_token_from_index( statement-to + 1 )-str ='ENDCATCH' ). + CHECK get_next_token_from_index( statement-from )-str = 'CATCH' + AND ( get_next_token_from_index( statement-to + 1 )-str = 'ENDTRY' + OR get_next_token_from_index( statement-to + 1 )-str = 'ENDCATCH' ). DATA(check_configuration) = detect_check_configuration( statement ). diff --git a/src/checks/y_check_prefer_line_exists.clas.abap b/src/checks/y_check_prefer_line_exists.clas.abap new file mode 100644 index 00000000..2707ac77 --- /dev/null +++ b/src/checks/y_check_prefer_line_exists.clas.abap @@ -0,0 +1,61 @@ +CLASS y_check_prefer_line_exists DEFINITION PUBLIC INHERITING FROM y_check_base CREATE PUBLIC. + PUBLIC SECTION. + METHODS constructor. + + PROTECTED SECTION. + METHODS inspect_tokens REDEFINITION. + + METHODS get_statement_inline IMPORTING statement TYPE sstmnt + RETURNING VALUE(result) TYPE string. + +ENDCLASS. + + + +CLASS y_check_prefer_line_exists IMPLEMENTATION. + + + METHOD constructor. + super->constructor( ). + + 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!' ). + ENDMETHOD. + + + METHOD inspect_tokens. + CHECK get_token_abs( statement-from ) = 'READ' + OR get_token_abs( statement-from ) = 'LOOP'. + + DATA(inline) = get_statement_inline( statement ). + + IF inline NP '*TRANSPORTING NO FIELDS*'. + RETURN. + ENDIF. + + DATA(configuration) = detect_check_configuration( statement ). + + IF configuration IS INITIAL. + RETURN. + ENDIF. + + raise_error( statement_level = statement-level + statement_index = index + statement_from = statement-from + error_priority = configuration-prio ). + ENDMETHOD. + + + METHOD get_statement_inline. + LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL() + FROM statement-from TO statement-to. + result = |{ result } { -str }|. + ENDLOOP. + ENDMETHOD. + +ENDCLASS. diff --git a/src/checks/y_check_prefer_line_exists.clas.testclasses.abap b/src/checks/y_check_prefer_line_exists.clas.testclasses.abap new file mode 100644 index 00000000..df9bc01b --- /dev/null +++ b/src/checks/y_check_prefer_line_exists.clas.testclasses.abap @@ -0,0 +1,99 @@ +*"* use this source file for your ABAP unit test classes +CLASS ltc_read_table 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_read_table IMPLEMENTATION. + + METHOD get_cut. + result ?= NEW y_check_prefer_line_exists( ). + ENDMETHOD. + + METHOD get_code_with_issue. + result = VALUE #( + ( 'REPORT y_example. ' ) + + ( ' START-OF-SELECTION. ' ) + ( ' DATA tadir TYPE TABLE OF tadir. ' ) + ( ' DATA exists TYPE abap_bool. ' ) + + ( | READ TABLE tadir TRANSPORTING NO FIELDS WITH KEY object = 'y_check_prefer_line_exists'. | ) + + ( ' IF sy-subrc = 0. ' ) + ( ' exists = abap_true. ' ) + ( ' ENDIF. ' ) + ). + ENDMETHOD. + + METHOD get_code_without_issue. + result = VALUE #( + ( 'REPORT y_example. ' ) + + ( ' START-OF-SELECTION. ' ) + ( ' DATA tadir TYPE TABLE OF tadir. ' ) + ( | DATA(exists) = xsdbool( line_exists( tadir[ object = 'y_check_prefer_line_exists' ] ) ). | ) + ( | DATA(index) = line_index( tadir[ object = 'y_check_prefer_line_exists' ] ). | ) + ). + ENDMETHOD. + + METHOD get_code_with_exemption. + result = VALUE #( + ( 'REPORT y_example. ' ) + + ( ' START-OF-SELECTION. ' ) + ( ' DATA tadir TYPE TABLE OF tadir. ' ) + ( ' DATA exists TYPE abap_bool. ' ) + + ( | READ TABLE tadir TRANSPORTING NO FIELDS WITH KEY object = 'y_check_prefer_line_exists'. "#EC PREF_LINE_EX | ) + + ( ' IF sy-subrc = 0. ' ) + ( ' exists = abap_true. ' ) + ( ' ENDIF. ' ) + ). + ENDMETHOD. + +ENDCLASS. + + + +CLASS ltc_loop_at DEFINITION INHERITING FROM ltc_read_table FOR TESTING RISK LEVEL HARMLESS DURATION SHORT. + PROTECTED SECTION. + METHODS get_code_with_issue REDEFINITION. + METHODS get_code_with_exemption REDEFINITION. +ENDCLASS. + +CLASS ltc_loop_at IMPLEMENTATION. + + METHOD get_code_with_issue. + result = VALUE #( + ( 'REPORT y_example. ' ) + + ( ' START-OF-SELECTION. ' ) + ( ' DATA tadir TYPE TABLE OF tadir. ' ) + ( ' DATA exists TYPE abap_bool. ' ) + + ( | LOOP AT tadir TRANSPORTING NO FIELDS WHERE object = 'y_check_prefer_line_exists'. | ) + ( ' exists = abap_true. ' ) + ( ' ENDLOOP. ' ) + ). + ENDMETHOD. + + METHOD get_code_with_exemption. + result = VALUE #( + ( 'REPORT y_example. ' ) + + ( ' START-OF-SELECTION. ' ) + ( ' DATA tadir TYPE TABLE OF tadir. ' ) + ( ' DATA exists TYPE abap_bool. ' ) + + ( | LOOP AT tadir TRANSPORTING NO FIELDS WHERE object = 'y_check_prefer_line_exists'. "#EC PREF_LINE_EX | ) + ( ' exists = abap_true. ' ) + ( ' ENDLOOP. ' ) + ). + ENDMETHOD. + +ENDCLASS. diff --git a/src/checks/y_check_prefer_line_exists.clas.xml b/src/checks/y_check_prefer_line_exists.clas.xml new file mode 100644 index 00000000..86b7a26d --- /dev/null +++ b/src/checks/y_check_prefer_line_exists.clas.xml @@ -0,0 +1,17 @@ + + + + + + Y_CHECK_PREFER_LINE_EXISTS + E + Prefer LINE_EXISTS or LINE_INDEX to READ TABLE or LOOP AT + 1 + X + X + X + X + + + + From 7e681ec7386b79f068343ff386fc0ffa64a8b781 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:16:18 +0200 Subject: [PATCH 27/68] wrongly commited object --- .../y_check_prefer_line_exists.clas.abap | 61 ------------ ...k_prefer_line_exists.clas.testclasses.abap | 99 ------------------- .../y_check_prefer_line_exists.clas.xml | 17 ---- 3 files changed, 177 deletions(-) delete mode 100644 src/checks/y_check_prefer_line_exists.clas.abap delete mode 100644 src/checks/y_check_prefer_line_exists.clas.testclasses.abap delete mode 100644 src/checks/y_check_prefer_line_exists.clas.xml diff --git a/src/checks/y_check_prefer_line_exists.clas.abap b/src/checks/y_check_prefer_line_exists.clas.abap deleted file mode 100644 index 2707ac77..00000000 --- a/src/checks/y_check_prefer_line_exists.clas.abap +++ /dev/null @@ -1,61 +0,0 @@ -CLASS y_check_prefer_line_exists DEFINITION PUBLIC INHERITING FROM y_check_base CREATE PUBLIC. - PUBLIC SECTION. - METHODS constructor. - - PROTECTED SECTION. - METHODS inspect_tokens REDEFINITION. - - METHODS get_statement_inline IMPORTING statement TYPE sstmnt - RETURNING VALUE(result) TYPE string. - -ENDCLASS. - - - -CLASS y_check_prefer_line_exists IMPLEMENTATION. - - - METHOD constructor. - super->constructor( ). - - 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!' ). - ENDMETHOD. - - - METHOD inspect_tokens. - CHECK get_token_abs( statement-from ) = 'READ' - OR get_token_abs( statement-from ) = 'LOOP'. - - DATA(inline) = get_statement_inline( statement ). - - IF inline NP '*TRANSPORTING NO FIELDS*'. - RETURN. - ENDIF. - - DATA(configuration) = detect_check_configuration( statement ). - - IF configuration IS INITIAL. - RETURN. - ENDIF. - - raise_error( statement_level = statement-level - statement_index = index - statement_from = statement-from - error_priority = configuration-prio ). - ENDMETHOD. - - - METHOD get_statement_inline. - LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL() - FROM statement-from TO statement-to. - result = |{ result } { -str }|. - ENDLOOP. - ENDMETHOD. - -ENDCLASS. diff --git a/src/checks/y_check_prefer_line_exists.clas.testclasses.abap b/src/checks/y_check_prefer_line_exists.clas.testclasses.abap deleted file mode 100644 index df9bc01b..00000000 --- a/src/checks/y_check_prefer_line_exists.clas.testclasses.abap +++ /dev/null @@ -1,99 +0,0 @@ -*"* use this source file for your ABAP unit test classes -CLASS ltc_read_table 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_read_table IMPLEMENTATION. - - METHOD get_cut. - result ?= NEW y_check_prefer_line_exists( ). - ENDMETHOD. - - METHOD get_code_with_issue. - result = VALUE #( - ( 'REPORT y_example. ' ) - - ( ' START-OF-SELECTION. ' ) - ( ' DATA tadir TYPE TABLE OF tadir. ' ) - ( ' DATA exists TYPE abap_bool. ' ) - - ( | READ TABLE tadir TRANSPORTING NO FIELDS WITH KEY object = 'y_check_prefer_line_exists'. | ) - - ( ' IF sy-subrc = 0. ' ) - ( ' exists = abap_true. ' ) - ( ' ENDIF. ' ) - ). - ENDMETHOD. - - METHOD get_code_without_issue. - result = VALUE #( - ( 'REPORT y_example. ' ) - - ( ' START-OF-SELECTION. ' ) - ( ' DATA tadir TYPE TABLE OF tadir. ' ) - ( | DATA(exists) = xsdbool( line_exists( tadir[ object = 'y_check_prefer_line_exists' ] ) ). | ) - ( | DATA(index) = line_index( tadir[ object = 'y_check_prefer_line_exists' ] ). | ) - ). - ENDMETHOD. - - METHOD get_code_with_exemption. - result = VALUE #( - ( 'REPORT y_example. ' ) - - ( ' START-OF-SELECTION. ' ) - ( ' DATA tadir TYPE TABLE OF tadir. ' ) - ( ' DATA exists TYPE abap_bool. ' ) - - ( | READ TABLE tadir TRANSPORTING NO FIELDS WITH KEY object = 'y_check_prefer_line_exists'. "#EC PREF_LINE_EX | ) - - ( ' IF sy-subrc = 0. ' ) - ( ' exists = abap_true. ' ) - ( ' ENDIF. ' ) - ). - ENDMETHOD. - -ENDCLASS. - - - -CLASS ltc_loop_at DEFINITION INHERITING FROM ltc_read_table FOR TESTING RISK LEVEL HARMLESS DURATION SHORT. - PROTECTED SECTION. - METHODS get_code_with_issue REDEFINITION. - METHODS get_code_with_exemption REDEFINITION. -ENDCLASS. - -CLASS ltc_loop_at IMPLEMENTATION. - - METHOD get_code_with_issue. - result = VALUE #( - ( 'REPORT y_example. ' ) - - ( ' START-OF-SELECTION. ' ) - ( ' DATA tadir TYPE TABLE OF tadir. ' ) - ( ' DATA exists TYPE abap_bool. ' ) - - ( | LOOP AT tadir TRANSPORTING NO FIELDS WHERE object = 'y_check_prefer_line_exists'. | ) - ( ' exists = abap_true. ' ) - ( ' ENDLOOP. ' ) - ). - ENDMETHOD. - - METHOD get_code_with_exemption. - result = VALUE #( - ( 'REPORT y_example. ' ) - - ( ' START-OF-SELECTION. ' ) - ( ' DATA tadir TYPE TABLE OF tadir. ' ) - ( ' DATA exists TYPE abap_bool. ' ) - - ( | LOOP AT tadir TRANSPORTING NO FIELDS WHERE object = 'y_check_prefer_line_exists'. "#EC PREF_LINE_EX | ) - ( ' exists = abap_true. ' ) - ( ' ENDLOOP. ' ) - ). - ENDMETHOD. - -ENDCLASS. diff --git a/src/checks/y_check_prefer_line_exists.clas.xml b/src/checks/y_check_prefer_line_exists.clas.xml deleted file mode 100644 index 86b7a26d..00000000 --- a/src/checks/y_check_prefer_line_exists.clas.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - Y_CHECK_PREFER_LINE_EXISTS - E - Prefer LINE_EXISTS or LINE_INDEX to READ TABLE or LOOP AT - 1 - X - X - X - X - - - - From 17ec8ec372f735f855dd1f63ce2d9904e90d047b Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:21:53 +0200 Subject: [PATCH 28/68] Some fixes Compare operator "EQ" not preferred Prefer Inline Declarations, FM_NAME Reorder definitions to top of routine --- src/checks/y_check_function.clas.abap | 5 ++--- src/checks/y_check_function.clas.locals_imp.abap | 14 +++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/checks/y_check_function.clas.abap b/src/checks/y_check_function.clas.abap index eb1d9792..e0908de2 100644 --- a/src/checks/y_check_function.clas.abap +++ b/src/checks/y_check_function.clas.abap @@ -41,10 +41,9 @@ CLASS Y_CHECK_FUNCTION IMPLEMENTATION. CHECK get_token_abs( statement-from ) = 'FUNCTION'. - DATA fm_name TYPE c LENGTH 30. - fm_name = get_token_abs( statement-from + 1 ). + DATA(fm_name) = get_token_abs( statement-from + 1 ). - IF db_reader->is_fm_rfc_enabled( fm_name ) EQ abap_false. + IF db_reader->is_fm_rfc_enabled( CONV #( fm_name ) ) = abap_false. DATA(check_configuration) = detect_check_configuration( statement ). diff --git a/src/checks/y_check_function.clas.locals_imp.abap b/src/checks/y_check_function.clas.locals_imp.abap index e93b11a9..a50df312 100644 --- a/src/checks/y_check_function.clas.locals_imp.abap +++ b/src/checks/y_check_function.clas.locals_imp.abap @@ -1,9 +1,13 @@ CLASS lcl_db_reader IMPLEMENTATION. + METHOD lif_db_reader~is_fm_rfc_enabled. - SELECT SINGLE fmode FROM tfdir - WHERE funcname = @function - AND fmode EQ 'R' - INTO @DATA(mode). - result = xsdbool( sy-subrc EQ 0 ). + SELECT SINGLE fmode + FROM tfdir + WHERE funcname = @function + AND fmode = 'R' + INTO @DATA(mode). + + result = xsdbool( sy-subrc = 0 ). ENDMETHOD. + ENDCLASS. From b2981058058491b6992b53e597a4604a2eb497d3 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:24:08 +0200 Subject: [PATCH 29/68] Statement "ADD" is obsolete --- src/checks/y_check_is_interface_in_class.clas.abap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0c3ba1b1..8a165633 100644 --- a/src/checks/y_check_is_interface_in_class.clas.abap +++ b/src/checks/y_check_is_interface_in_class.clas.abap @@ -66,7 +66,7 @@ CLASS Y_CHECK_IS_INTERFACE_IN_CLASS IMPLEMENTATION. AND get_second_token( statement ) <> 'FOR' AND get_third_token( statement ) <> 'TESTING'. - ADD 1 TO public_method_counter. + public_method_counter = public_method_counter + 1. ENDMETHOD. From 73956d4ebfe8710e9c4188fd955b6fc944418eb6 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:24:34 +0200 Subject: [PATCH 30/68] Compare operator "EQ" not preferred --- src/checks/y_check_magic_number.clas.abap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/checks/y_check_magic_number.clas.abap b/src/checks/y_check_magic_number.clas.abap index 5b0420b1..9783861f 100644 --- a/src/checks/y_check_magic_number.clas.abap +++ b/src/checks/y_check_magic_number.clas.abap @@ -39,13 +39,13 @@ CLASS Y_CHECK_MAGIC_NUMBER IMPLEMENTATION. METHOD is_exception. - IF token EQ 'ENDCASE' AND has_case_with_subrc EQ abap_true. + IF token = 'ENDCASE' AND has_case_with_subrc = abap_true. has_case_with_subrc = abap_false. ENDIF. - IF token EQ 'SY-SUBRC' OR has_case_with_subrc EQ abap_true. + IF token = 'SY-SUBRC' OR has_case_with_subrc = abap_true. result = abap_true. - ELSEIF token EQ 'CASE' AND get_token_rel( second_token ) = 'SY-SUBRC'. + ELSEIF token = 'CASE' AND get_token_rel( second_token ) = 'SY-SUBRC'. has_case_with_subrc = abap_true. ENDIF. ENDMETHOD. @@ -93,7 +93,7 @@ CLASS Y_CHECK_MAGIC_NUMBER IMPLEMENTATION. ENDIF. FIND REGEX `^(?!'?[01]'?$)'?\d+'?$` IN token_string. - IF sy-subrc EQ 0. + IF sy-subrc = 0. magic_number = token_string. result = abap_true. ENDIF. From bd3ebdcf8a3c928429804e286b38273180f3eff2 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:27:23 +0200 Subject: [PATCH 31/68] Some fixes Compare operator "EQ" not preferred Statement "ADD" is obsolete Statement "SUBTRACT" is obsolete Line break multiple parameters --- .../y_check_max_nesting_depth.clas.abap | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/checks/y_check_max_nesting_depth.clas.abap b/src/checks/y_check_max_nesting_depth.clas.abap index 5df7b45b..d045c83f 100644 --- a/src/checks/y_check_max_nesting_depth.clas.abap +++ b/src/checks/y_check_max_nesting_depth.clas.abap @@ -25,14 +25,26 @@ CLASS y_check_max_nesting_depth IMPLEMENTATION. METHOD compute_nesting_level. CASE token_str. - WHEN 'IF' OR 'WHILE' OR 'LOOP' OR - 'DO' OR 'PROVIDE' OR 'TRY' OR 'CASE'. - ADD 1 TO curr_nesting. - WHEN 'ENDIF' OR 'ENDWHILE' OR 'ENDLOOP' OR - 'ENDDO' OR 'ENDPROVIDE' OR 'ENDTRY' OR 'ENDCASE'. - max_nesting = nmax( val1 = max_nesting val2 = curr_nesting ). - SUBTRACT 1 FROM curr_nesting. - WHEN 'ENDAT' OR 'ENDSELECT'. + WHEN 'IF' + OR 'WHILE' + OR 'LOOP' + OR 'DO' + OR 'PROVIDE' + OR 'TRY' + OR 'CASE'. + curr_nesting = curr_nesting + 1. + WHEN 'ENDIF' + OR 'ENDWHILE' + OR 'ENDLOOP' + OR 'ENDDO' + OR 'ENDPROVIDE' + OR 'ENDTRY' + OR 'ENDCASE'. + max_nesting = nmax( val1 = max_nesting + val2 = curr_nesting ). + curr_nesting = curr_nesting - 1. + WHEN 'ENDAT' + OR 'ENDSELECT'. IF curr_nesting >= max_nesting. max_nesting = curr_nesting + 1. ENDIF. From edc0575180ae54f1619a90794fba596f966ea997 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:30:22 +0200 Subject: [PATCH 32/68] Some fixes Compare operator "EQ" not preferred Method "check_token_content" not used Statement "ADD" is obsolete --- .../y_check_method_output_param.clas.abap | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/checks/y_check_method_output_param.clas.abap b/src/checks/y_check_method_output_param.clas.abap index f9247080..fca429ec 100644 --- a/src/checks/y_check_method_output_param.clas.abap +++ b/src/checks/y_check_method_output_param.clas.abap @@ -12,7 +12,6 @@ CLASS y_check_method_output_param DEFINITION PUBLIC INHERITING FROM y_check_bas DATA has_returning_parameter TYPE abap_bool. DATA has_pseudo_comment TYPE abap_bool. - METHODS check_token_content IMPORTING token TYPE stokesx. METHODS has_error RETURNING VALUE(result) TYPE abap_bool. ENDCLASS. @@ -25,13 +24,13 @@ CLASS Y_CHECK_METHOD_OUTPUT_PARAM IMPLEMENTATION. METHOD has_error. DATA(sum) = 0. IF has_exporting_parameter = abap_true. - ADD 1 TO sum. + sum = sum + 1. ENDIF. IF has_changing_parameter = abap_true. - ADD 1 TO sum. + sum = sum + 1. ENDIF. IF has_returning_parameter = abap_true. - ADD 1 TO sum. + sum = sum + 1. ENDIF. IF sum > 1. result = abap_true. @@ -39,19 +38,6 @@ CLASS Y_CHECK_METHOD_OUTPUT_PARAM IMPLEMENTATION. ENDMETHOD. - METHOD check_token_content. - IF token-str EQ 'EXPORTING'. - has_exporting_parameter = abap_true. - ENDIF. - IF token-str EQ 'CHANGING'. - has_changing_parameter = abap_true. - ENDIF. - IF token-str EQ 'RETURNING'. - has_returning_parameter = abap_true. - ENDIF. - ENDMETHOD. - - METHOD constructor. super->constructor( ). From c72be2321e767d68effd784bb3e44ff615de96a5 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:33:58 +0200 Subject: [PATCH 33/68] Some fixes Line break multiple parameters Compare operator "GE" not preferred Compare operator "EQ" not preferred --- src/checks/y_check_method_return_bool.clas.abap | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/checks/y_check_method_return_bool.clas.abap b/src/checks/y_check_method_return_bool.clas.abap index 1dacd995..4d6f838d 100644 --- a/src/checks/y_check_method_return_bool.clas.abap +++ b/src/checks/y_check_method_return_bool.clas.abap @@ -59,15 +59,18 @@ CLASS Y_CHECK_METHOD_RETURN_BOOL IMPLEMENTATION. method_name = get_token_abs( stmnt_index + 1 ). LOOP AT good_method_names_beginning ASSIGNING FIELD-SYMBOL(). - IF strlen( method_name ) GE strlen( ) - AND substring( val = method_name len = strlen( ) ) EQ . + DATA(prefix) = substring( val = method_name + len = strlen( ) ). + + IF strlen( method_name ) >= strlen( ) + AND prefix = . result = abap_true. RETURN. ENDIF. ENDLOOP. LOOP AT good_method_names_containing ASSIGNING FIELD-SYMBOL(). - IF strlen( method_name ) GE strlen( ) + IF strlen( method_name ) >= strlen( ) AND method_name CS . result = abap_true. RETURN. @@ -84,8 +87,8 @@ CLASS Y_CHECK_METHOD_RETURN_BOOL IMPLEMENTATION. LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL() FROM statement-from TO statement-to. - IF -str EQ 'ABAP_BOOL' - AND get_token_abs( token_index - 3 ) EQ 'RETURNING'. "#EC CI_MAGIC + IF -str = 'ABAP_BOOL' + AND get_token_abs( token_index - 3 ) = 'RETURNING'. "#EC CI_MAGIC has_found_bool = abap_true. ENDIF. token_index = token_index + 1. From 657c6756d1e80dba9713426b552c14024472c6df Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:37:07 +0200 Subject: [PATCH 34/68] ops, fixing bug --- src/checks/y_check_method_return_bool.clas.abap | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/checks/y_check_method_return_bool.clas.abap b/src/checks/y_check_method_return_bool.clas.abap index 4d6f838d..18fe583a 100644 --- a/src/checks/y_check_method_return_bool.clas.abap +++ b/src/checks/y_check_method_return_bool.clas.abap @@ -59,13 +59,14 @@ CLASS Y_CHECK_METHOD_RETURN_BOOL IMPLEMENTATION. method_name = get_token_abs( stmnt_index + 1 ). LOOP AT good_method_names_beginning ASSIGNING FIELD-SYMBOL(). - DATA(prefix) = substring( val = method_name - len = strlen( ) ). - - IF strlen( method_name ) >= strlen( ) - AND prefix = . - result = abap_true. - RETURN. + IF strlen( method_name ) >= strlen( ). + DATA(prefix) = substring( val = method_name + len = strlen( ) ). + + IF prefix = . + result = abap_true. + RETURN. + ENDIF. ENDIF. ENDLOOP. From 2b38ee1e59a2e1097a22f5e9d8c979d64c0a4f4d Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:37:48 +0200 Subject: [PATCH 35/68] Compare operator "EQ" not preferred --- src/checks/y_check_non_class_exception.clas.abap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/checks/y_check_non_class_exception.clas.abap b/src/checks/y_check_non_class_exception.clas.abap index 2c5e42ca..422ca134 100644 --- a/src/checks/y_check_non_class_exception.clas.abap +++ b/src/checks/y_check_non_class_exception.clas.abap @@ -61,7 +61,7 @@ CLASS Y_CHECK_NON_CLASS_EXCEPTION IMPLEMENTATION. LOOP AT ref_scan_manager->tokens TRANSPORTING NO FIELDS FROM statement-from TO statement-to - WHERE str = 'RAISING' AND type EQ 'I'. + WHERE str = 'RAISING' AND type = 'I'. checkif_error( index = index statement = statement ). From 06a5aedc86fe7bd10c75183b8c4f04cb75ec3ca1 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:39:23 +0200 Subject: [PATCH 36/68] Statement "ADD" is obsolete --- src/checks/y_check_num_exec_statements.clas.abap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/checks/y_check_num_exec_statements.clas.abap b/src/checks/y_check_num_exec_statements.clas.abap index 04612c0a..8573a831 100644 --- a/src/checks/y_check_num_exec_statements.clas.abap +++ b/src/checks/y_check_num_exec_statements.clas.abap @@ -48,7 +48,7 @@ CLASS Y_CHECK_NUM_EXEC_STATEMENTS IMPLEMENTATION. RETURN. ENDIF. IF token_wa-type <> scan_token_type-comment AND token_wa-type <> scan_token_type-pragma. - ADD 1 TO no_exec_statements. + no_exec_statements = no_exec_statements + 1. ENDIF. ENDMETHOD. From b636618b43b150c69377dc8ed4f132e355800851 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:42:08 +0200 Subject: [PATCH 37/68] Some fixes Statement "ADD" is obsolete Statement "SUBTRACT" is obsolete Too many parenthesis, complex --- src/checks/y_check_num_public_attributes.clas.abap | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/checks/y_check_num_public_attributes.clas.abap b/src/checks/y_check_num_public_attributes.clas.abap index cf29fd1f..7be75f4b 100644 --- a/src/checks/y_check_num_public_attributes.clas.abap +++ b/src/checks/y_check_num_public_attributes.clas.abap @@ -62,10 +62,12 @@ CLASS y_check_num_public_attributes IMPLEMENTATION. METHOD checkif_attribute_in_structure. - IF ( second_token = 'BEGIN' AND third_token = 'OF' ). - ADD 1 TO structure_depth. - ELSEIF ( second_token = 'END' AND third_token = 'OF' ). - SUBTRACT 1 FROM structure_depth. + IF second_token = 'BEGIN' + AND third_token = 'OF'. + structure_depth = structure_depth + 1. + ELSEIF second_token = 'END' + AND third_token = 'OF'. + structure_depth = structure_depth - 1. ENDIF. ENDMETHOD. @@ -78,7 +80,7 @@ CLASS y_check_num_public_attributes IMPLEMENTATION. CHECK last_token <> 'READ-ONLY'. - ADD 1 TO public_attribute_counter. + public_attribute_counter = public_attribute_counter + 1. ENDMETHOD. From dcc6714cf6fbafb003b28c8b6b091507f49c33cb Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:45:16 +0200 Subject: [PATCH 38/68] Some fixes Omit default parameter name "FIRST_TOKEN" Statement "SUBTRACT" is obsolete Statement "ADD" is obsolete --- src/checks/y_check_number_attributes.clas.abap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/checks/y_check_number_attributes.clas.abap b/src/checks/y_check_number_attributes.clas.abap index ac7dadcf..f0c3ca81 100644 --- a/src/checks/y_check_number_attributes.clas.abap +++ b/src/checks/y_check_number_attributes.clas.abap @@ -52,7 +52,7 @@ CLASS y_check_number_attributes IMPLEMENTATION. METHOD inspect_tokens. - checkif_attribute_found( first_token = get_token_abs( statement-from ) ). + checkif_attribute_found( get_token_abs( statement-from ) ). checkif_attribute_in_structure( second_token = get_token_abs( statement-from + 1 ) third_token = get_token_abs( statement-from + 2 ) ). @@ -63,7 +63,7 @@ CLASS y_check_number_attributes IMPLEMENTATION. CASE first_token. WHEN 'DATA' OR 'CLASS-DATA'. IF structure_depth <= structure_depth_threshold. - ADD 1 TO attribute_counter. + attribute_counter = attribute_counter + 1. ENDIF. ENDCASE. ENDMETHOD. @@ -71,9 +71,9 @@ CLASS y_check_number_attributes IMPLEMENTATION. METHOD checkif_attribute_in_structure. IF ( second_token = 'BEGIN' AND third_token = 'OF' ). - ADD 1 TO structure_depth. + structure_depth = structure_depth + 1. ELSEIF ( second_token = 'END' AND third_token = 'OF' ). - SUBTRACT 1 FROM structure_depth. + structure_depth = structure_depth - 1. ENDIF. ENDMETHOD. From 27bdd752366e6330695ce67f7f70256d07264f02 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Tue, 6 Apr 2021 21:59:50 +0200 Subject: [PATCH 39/68] several fixes --- .../y_check_number_attributes.clas.abap | 6 ++- src/checks/y_check_number_events.clas.abap | 2 +- src/checks/y_check_number_methods.clas.abap | 2 +- .../y_check_pseudo_comment_usage.clas.abap | 24 ++++++----- src/checks/y_check_receiving_usage.clas.abap | 10 ++--- src/checks/y_check_test_seam_usage.clas.abap | 10 ++--- src/foundation/y_check_base.clas.abap | 43 ++++++++----------- .../y_ci_check_registration.prog.abap | 16 +++---- 8 files changed, 55 insertions(+), 58 deletions(-) diff --git a/src/checks/y_check_number_attributes.clas.abap b/src/checks/y_check_number_attributes.clas.abap index f0c3ca81..cd3c6fa4 100644 --- a/src/checks/y_check_number_attributes.clas.abap +++ b/src/checks/y_check_number_attributes.clas.abap @@ -70,9 +70,11 @@ CLASS y_check_number_attributes IMPLEMENTATION. METHOD checkif_attribute_in_structure. - IF ( second_token = 'BEGIN' AND third_token = 'OF' ). + IF second_token = 'BEGIN' + AND third_token = 'OF'. structure_depth = structure_depth + 1. - ELSEIF ( second_token = 'END' AND third_token = 'OF' ). + ELSEIF second_token = 'END' + AND third_token = 'OF'. structure_depth = structure_depth - 1. ENDIF. ENDMETHOD. diff --git a/src/checks/y_check_number_events.clas.abap b/src/checks/y_check_number_events.clas.abap index f49cf36d..b1bac668 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. METHOD inspect_tokens. CASE get_token_abs( statement-from ). WHEN 'EVENTS' OR 'CLASS-EVENTS'. - ADD 1 TO event_counter. + event_counter = event_counter + 1. ENDCASE. ENDMETHOD. diff --git a/src/checks/y_check_number_methods.clas.abap b/src/checks/y_check_number_methods.clas.abap index e8d8eca3..141181b3 100644 --- a/src/checks/y_check_number_methods.clas.abap +++ b/src/checks/y_check_number_methods.clas.abap @@ -47,7 +47,7 @@ CLASS Y_CHECK_NUMBER_METHODS IMPLEMENTATION. METHOD inspect_tokens. CASE get_token_abs( statement-from ). WHEN 'METHODS' OR 'CLASS-METHODS'. - ADD 1 TO method_counter. + method_counter = method_counter + 1. ENDCASE. ENDMETHOD. diff --git a/src/checks/y_check_pseudo_comment_usage.clas.abap b/src/checks/y_check_pseudo_comment_usage.clas.abap index b645a7ea..54b9aa82 100644 --- a/src/checks/y_check_pseudo_comment_usage.clas.abap +++ b/src/checks/y_check_pseudo_comment_usage.clas.abap @@ -72,7 +72,7 @@ CLASS y_check_pseudo_comment_usage IMPLEMENTATION. LOOP AT class_names ASSIGNING FIELD-SYMBOL(). TRY. IF token-str CS call_get_pseudo_comment( ). - ADD 1 TO pseudo_comment_counter. + pseudo_comment_counter = pseudo_comment_counter + 1. ENDIF. CATCH cx_sy_create_object_error. CONTINUE. @@ -93,8 +93,8 @@ CLASS y_check_pseudo_comment_usage IMPLEMENTATION. METHOD inspect_tokens. LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL() FROM statement-from TO statement-to - WHERE type EQ 'C' - OR type EQ 'P'. + WHERE type = 'C' + OR type = 'P'. count_cc_pseudo_comments( ). ENDLOOP. ENDMETHOD. @@ -118,17 +118,21 @@ CLASS y_check_pseudo_comment_usage IMPLEMENTATION. METHOD select_object_list. - SELECT SINGLE devclass FROM tadir - WHERE obj_name EQ @myname - INTO @DATA(packagename). + SELECT SINGLE devclass + FROM tadir + WHERE obj_name = @myname + INTO @DATA(packagename). + IF sy-subrc <> 0. RAISE EXCEPTION TYPE cx_failed. ENDIF. - SELECT obj_name FROM tadir - WHERE devclass EQ @packagename AND - obj_name NE @check_base_name - INTO TABLE @result. + SELECT obj_name + FROM tadir + WHERE devclass = @packagename + AND obj_name <> @check_base_name + INTO TABLE @result. + IF sy-subrc <> 0. RAISE EXCEPTION TYPE cx_failed. ENDIF. diff --git a/src/checks/y_check_receiving_usage.clas.abap b/src/checks/y_check_receiving_usage.clas.abap index 2cde6c6c..9d7a7b30 100644 --- a/src/checks/y_check_receiving_usage.clas.abap +++ b/src/checks/y_check_receiving_usage.clas.abap @@ -25,7 +25,7 @@ CLASS Y_CHECK_RECEIVING_USAGE IMPLEMENTATION. METHOD inspect_tokens. CHECK get_token_abs( statement-from ) CP '*(*'. - CHECK get_token_abs( statement-from ) NE 'BADI'. + CHECK get_token_abs( statement-from ) <> 'BADI'. DATA(has_receiving) = abap_false. DATA(has_classic_exception) = abap_false. @@ -35,12 +35,12 @@ CLASS Y_CHECK_RECEIVING_USAGE IMPLEMENTATION. LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL() FROM statement-from TO statement-to. IF has_receiving = abap_false. - has_receiving = xsdbool( -str EQ 'RECEIVING' AND - get_token_abs( statement-from + token_index + 1 ) NE '=' ). + has_receiving = xsdbool( -str = 'RECEIVING' AND + get_token_abs( statement-from + token_index + 1 ) <> '=' ). ENDIF. IF has_classic_exception = abap_false. - has_classic_exception = xsdbool( -str EQ 'EXCEPTIONS' AND - get_token_abs( statement-from + token_index + 1 ) NE '=' ). + has_classic_exception = xsdbool( -str = 'EXCEPTIONS' AND + get_token_abs( statement-from + token_index + 1 ) <> '=' ). ENDIF. token_index = token_index + 1. diff --git a/src/checks/y_check_test_seam_usage.clas.abap b/src/checks/y_check_test_seam_usage.clas.abap index aef9e4b1..2bbae65c 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. METHOD inspect_tokens. - CHECK get_token_abs( statement-from ) EQ 'TEST-SEAM'. + CHECK get_token_abs( statement-from ) = 'TEST-SEAM'. DATA(check_configuration) = detect_check_configuration( statement ). @@ -33,9 +33,9 @@ CLASS Y_CHECK_TEST_SEAM_USAGE IMPLEMENTATION. RETURN. ENDIF. - raise_error( statement_level = statement-level - statement_index = index - statement_from = statement-from - error_priority = check_configuration-prio ). + raise_error( statement_level = statement-level + statement_index = index + statement_from = statement-from + error_priority = check_configuration-prio ). ENDMETHOD. ENDCLASS. diff --git a/src/foundation/y_check_base.clas.abap b/src/foundation/y_check_base.clas.abap index 3b0f3e3b..279fc36d 100644 --- a/src/foundation/y_check_base.clas.abap +++ b/src/foundation/y_check_base.clas.abap @@ -333,11 +333,11 @@ CLASS y_check_base IMPLEMENTATION. DO. READ TABLE tokens INDEX p_n ASSIGNING FIELD-SYMBOL(). - IF sy-subrc EQ 0 AND -row <> 0. + IF sy-subrc = 0 AND -row <> 0. p_result = -col. RETURN. ENDIF. - SUBTRACT 1 FROM p_n. + p_n = p_n - 1. ENDDO. ENDMETHOD. @@ -353,27 +353,22 @@ CLASS y_check_base IMPLEMENTATION. DO. READ TABLE tokens INDEX index ASSIGNING FIELD-SYMBOL(). - IF sy-subrc EQ 0 AND -row <> 0. + IF sy-subrc = 0 AND -row <> 0. p_result = -col. RETURN. ENDIF. - SUBTRACT 1 FROM index. + index = index - 1. ENDDO. ENDMETHOD. METHOD get_include. - DATA l_levels_wa LIKE LINE OF ref_scan->levels. - DATA l_level TYPE i. + DATA(l_level) = COND #( WHEN p_level IS SUPPLIED THEN p_level + ELSE statement_wa-level ). - IF p_level IS SUPPLIED. - l_level = p_level. - ELSE. - l_level = statement_wa-level. - ENDIF. DO. - READ TABLE ref_scan_manager->levels INDEX l_level INTO l_levels_wa. - IF sy-subrc NE 0. + READ TABLE ref_scan_manager->levels INDEX l_level INTO DATA(l_levels_wa). + IF sy-subrc <> 0. RETURN. ENDIF. IF l_levels_wa-type = 'P'. @@ -393,11 +388,11 @@ CLASS y_check_base IMPLEMENTATION. DO. READ TABLE tokens INDEX p_n ASSIGNING FIELD-SYMBOL(). - IF sy-subrc EQ 0 AND -row <> 0. + IF sy-subrc = 0 AND -row <> 0. p_result = -row. RETURN. ENDIF. - SUBTRACT 1 FROM p_n. + p_n = p_n - 1. ENDDO. ENDMETHOD. @@ -410,12 +405,12 @@ CLASS y_check_base IMPLEMENTATION. DO. READ TABLE tokens INDEX p_n ASSIGNING FIELD-SYMBOL(). - IF sy-subrc EQ 0 AND -row <> 0. + IF sy-subrc = 0 AND -row <> 0. p_column = -col. p_line = -row. RETURN. ENDIF. - SUBTRACT 1 FROM p_n. + p_n = p_n - 1. ENDDO. ENDMETHOD. @@ -430,12 +425,12 @@ CLASS y_check_base IMPLEMENTATION. DO. READ TABLE tokens INDEX p_n ASSIGNING FIELD-SYMBOL(). - IF sy-subrc EQ 0 AND -row <> 0. + IF sy-subrc = 0 AND -row <> 0. p_column = -col. p_line = -row. RETURN. ENDIF. - SUBTRACT 1 FROM p_n. + p_n = p_n - 1. ENDDO. ENDMETHOD. @@ -451,18 +446,18 @@ CLASS y_check_base IMPLEMENTATION. DO. READ TABLE tokens INDEX index ASSIGNING FIELD-SYMBOL(). - IF sy-subrc EQ 0 AND -row <> 0. + IF sy-subrc = 0 AND -row <> 0. p_result = -row. RETURN. ENDIF. - SUBTRACT 1 FROM index. + index = index - 1. ENDDO. ENDMETHOD. METHOD get_token_abs. READ TABLE ref_scan_manager->tokens INDEX p_n INTO token_wa. - IF sy-subrc EQ 0. + IF sy-subrc = 0. p_result = token_wa-str. ENDIF. ENDMETHOD. @@ -655,7 +650,7 @@ CLASS y_check_base IMPLEMENTATION. suppress = settings-pseudo_comment position = statement_index ) ). - IF cl_abap_typedescr=>describe_by_object_ref( ref_scan_manager )->get_relative_name( ) EQ 'Y_REF_SCAN_MANAGER'. + IF cl_abap_typedescr=>describe_by_object_ref( ref_scan_manager )->get_relative_name( ) = 'Y_REF_SCAN_MANAGER'. inform( p_sub_obj_type = object_type p_sub_obj_name = get_include( p_level = statement_level ) p_position = statement_index @@ -697,7 +692,7 @@ CLASS y_check_base IMPLEMENTATION. check_start_conditions( ). profile_configurations = clean_code_manager->read_check_customizing( myname ). CATCH ycx_no_check_customizing. - IF profile_configurations IS INITIAL AND attributes_ok = abap_false. + IF profile_configurations IS INITIAL AND attributes_ok = abap_false. FREE ref_scan_manager. RETURN. ELSEIF attributes_ok = abap_true. diff --git a/src/foundation/y_ci_check_registration.prog.abap b/src/foundation/y_ci_check_registration.prog.abap index b097c24e..06c991a8 100644 --- a/src/foundation/y_ci_check_registration.prog.abap +++ b/src/foundation/y_ci_check_registration.prog.abap @@ -67,9 +67,9 @@ CLASS lcl_check_registration IMPLEMENTATION. 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 + WHERE obj_name = @reference-check_base + AND object = @reference-class + AND delflag = @abap_false INTO @DATA(packagename). IF sy-subrc <> 0. RAISE EXCEPTION TYPE cx_failed. @@ -78,9 +78,9 @@ CLASS lcl_check_registration IMPLEMENTATION. 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 + WHERE devclass = @packagename + AND object = @reference-class + AND delflag = @abap_false INTO TABLE @result. IF sy-subrc <> 0. RAISE EXCEPTION TYPE cx_failed. @@ -142,10 +142,6 @@ CLASS lcl_util IMPLEMENTATION. 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 }|. From 6484bbc1163b9d274729473f34589cada39cbb08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eugen=20G=C3=BCnther?= <64586309+eugen-guenther-sap@users.noreply.github.com> Date: Wed, 7 Apr 2021 09:52:15 +0200 Subject: [PATCH 40/68] Update y_check_unit_test_assert.clas.abap --- src/checks/y_check_unit_test_assert.clas.abap | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/checks/y_check_unit_test_assert.clas.abap b/src/checks/y_check_unit_test_assert.clas.abap index 8c48c9bd..4a7146dc 100644 --- a/src/checks/y_check_unit_test_assert.clas.abap +++ b/src/checks/y_check_unit_test_assert.clas.abap @@ -49,11 +49,10 @@ CLASS y_check_unit_test_assert IMPLEMENTATION. RETURN. ENDIF. - IF act-str <> exp-str. - IF is_variable( act ) = abap_true - OR is_variable( exp ) = abap_true. + IF act-str <> exp-str + AND ( is_variable( act ) = abap_true + OR is_variable( exp ) = abap_true ). RETURN. - ENDIF. ENDIF. DATA(check_configuration) = detect_check_configuration( statement ). From 69500cb188f4fc68660add3ebec5363bb47a7406 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Wed, 7 Apr 2021 11:14:26 -0300 Subject: [PATCH 41/68] Update abaplint.json --- abaplint.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/abaplint.json b/abaplint.json index 714e72ba..be29060a 100644 --- a/abaplint.json +++ b/abaplint.json @@ -80,7 +80,9 @@ "in_statement_indentation": false, "indentation": false, "inline_data_old_versions": true, - "intf_referencing_clas": true, + "intf_referencing_clas": { + "severity": "Warning" + }, "keep_single_parameter_on_one_line": true, "line_break_multiple_parameters": true, "line_break_style": true, From 5ed7524902c06a3e81f642631d707ae473160b25 Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Wed, 7 Apr 2021 11:16:49 -0300 Subject: [PATCH 42/68] Update abaplint.json --- abaplint.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/abaplint.json b/abaplint.json index be29060a..8921b1a6 100644 --- a/abaplint.json +++ b/abaplint.json @@ -126,7 +126,9 @@ "release_idoc": true, "remove_descriptions": false, "rfc_error_handling": true, - "select_add_order_by": true, + "select_add_order_by": { + "severity": "Warning" + }, "select_performance": true, "selection_screen_naming": false, "sequential_blank": true, From 25afef96287ff5c1fd62edc42b5455d17838095c Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Wed, 7 Apr 2021 11:19:54 -0300 Subject: [PATCH 43/68] Update abaplint.json --- abaplint.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/abaplint.json b/abaplint.json index 8921b1a6..363f2567 100644 --- a/abaplint.json +++ b/abaplint.json @@ -115,7 +115,9 @@ "parser_702_chaining": false, "parser_error": true, "parser_missing_space": true, - "prefer_inline": true, + "prefer_inline": { + "severity": "Warning" + }, "prefer_is_not": true, "prefer_raise_exception_new": true, "prefer_returning_to_exporting": true, From 72a662c3e30c403d87a9c026ac17d27c73665e5b Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Wed, 7 Apr 2021 16:21:50 +0200 Subject: [PATCH 44/68] Several fixes --- .../y_check_number_interfaces.clas.abap | 2 +- src/checks/y_check_unit_test_assert.clas.abap | 7 ++- src/foundation/y_check_base.clas.abap | 11 ++-- .../y_ci_check_registration.prog.abap | 14 +++-- src/foundation/y_clean_code_manager.clas.abap | 16 +++-- src/foundation/y_exemption_general.clas.abap | 10 +++- src/foundation/y_exemption_of_class.clas.abap | 60 +------------------ .../y_exemption_of_function_group.clas.abap | 27 ++++++--- .../y_exemption_of_program.clas.abap | 14 +++-- .../y_object_creation_date.clas.abap | 9 ++- .../y_pseudo_comment_detector.clas.abap | 6 +- src/foundation/y_test_code_detector.clas.abap | 8 +-- 12 files changed, 79 insertions(+), 105 deletions(-) diff --git a/src/checks/y_check_number_interfaces.clas.abap b/src/checks/y_check_number_interfaces.clas.abap index adc4ea60..eb15e635 100644 --- a/src/checks/y_check_number_interfaces.clas.abap +++ b/src/checks/y_check_number_interfaces.clas.abap @@ -45,7 +45,7 @@ CLASS y_check_number_interfaces IMPLEMENTATION. METHOD inspect_tokens. IF get_token_abs( statement-from ) = 'INTERFACES'. - ADD 1 TO interface_counter. + interface_counter = interface_counter + 1. ENDIF. ENDMETHOD. diff --git a/src/checks/y_check_unit_test_assert.clas.abap b/src/checks/y_check_unit_test_assert.clas.abap index 4a7146dc..8c48c9bd 100644 --- a/src/checks/y_check_unit_test_assert.clas.abap +++ b/src/checks/y_check_unit_test_assert.clas.abap @@ -49,10 +49,11 @@ CLASS y_check_unit_test_assert IMPLEMENTATION. RETURN. ENDIF. - IF act-str <> exp-str - AND ( is_variable( act ) = abap_true - OR is_variable( exp ) = abap_true ). + IF act-str <> exp-str. + IF is_variable( act ) = abap_true + OR is_variable( exp ) = abap_true. RETURN. + ENDIF. ENDIF. DATA(check_configuration) = detect_check_configuration( statement ). diff --git a/src/foundation/y_check_base.clas.abap b/src/foundation/y_check_base.clas.abap index 279fc36d..d8b96154 100644 --- a/src/foundation/y_check_base.clas.abap +++ b/src/foundation/y_check_base.clas.abap @@ -290,8 +290,7 @@ CLASS y_check_base IMPLEMENTATION. METHOD get_attributes. - DATA check_configuration TYPE y_if_clean_code_manager=>check_configuration. - READ TABLE check_configurations INTO check_configuration INDEX 1. + READ TABLE check_configurations INTO DATA(check_configuration) INDEX 1. IF sy-subrc <> 0. check_configuration-apply_on_productive_code = settings-apply_on_productive_code. check_configuration-apply_on_testcode = settings-apply_on_test_code. @@ -464,9 +463,7 @@ CLASS y_check_base IMPLEMENTATION. METHOD get_token_rel. - DATA l_index TYPE i. - - l_index = statement_wa-from + p_n - 1. + DATA(l_index) = statement_wa-from + p_n - 1. IF l_index > statement_wa-to. RETURN. ENDIF. @@ -675,6 +672,8 @@ CLASS y_check_base IMPLEMENTATION. METHOD run. + DATA profile_configurations TYPE y_if_clean_code_manager=>check_configurations. + instantiate_objects( ). IF attributes_maintained = abap_false AND has_attributes = abap_true. @@ -686,8 +685,6 @@ CLASS y_check_base IMPLEMENTATION. RETURN. ENDIF. - DATA profile_configurations TYPE y_if_clean_code_manager=>check_configurations. - TRY. check_start_conditions( ). profile_configurations = clean_code_manager->read_check_customizing( myname ). diff --git a/src/foundation/y_ci_check_registration.prog.abap b/src/foundation/y_ci_check_registration.prog.abap index 06c991a8..d112f962 100644 --- a/src/foundation/y_ci_check_registration.prog.abap +++ b/src/foundation/y_ci_check_registration.prog.abap @@ -59,8 +59,8 @@ CLASS lcl_check_registration IMPLEMENTATION. ENDMETHOD. METHOD is_check_compatible. - IF name NE get_category_name( ). - DATA code_pal_check TYPE REF TO y_check_base. "#EC DECL_IN_IF + DATA code_pal_check TYPE REF TO y_check_base. + IF name <> get_category_name( ). CREATE OBJECT code_pal_check TYPE (name). ENDIF. ENDMETHOD. @@ -93,7 +93,7 @@ CLASS lcl_check_registration IMPLEMENTATION. METHOD activate_check. is_check_compatible( name ). - INSERT scitests FROM name. + INSERT scitests FROM @name. IF sy-subrc <> 0. RAISE EXCEPTION TYPE cx_failed. ENDIF. @@ -102,7 +102,7 @@ CLASS lcl_check_registration IMPLEMENTATION. METHOD deactivate_check. is_check_compatible( name ). - DELETE FROM scitests WHERE name = name. + DELETE FROM scitests WHERE name = @name. IF sy-subrc <> 0. RAISE EXCEPTION TYPE cx_failed. ENDIF. @@ -140,7 +140,8 @@ CLASS lcl_util IMPLEMENTATION. TRY. lcl_check_registration=>activate_check( ). count_successes = count_successes + 1. - CATCH cx_failed. + CATCH cx_failed + cx_sy_create_object_error. count_errors = count_errors + 1. ENDTRY. ENDLOOP. @@ -155,7 +156,8 @@ CLASS lcl_util IMPLEMENTATION. TRY. lcl_check_registration=>deactivate_check( ). count_successes = count_successes + 1. - CATCH cx_failed. + CATCH cx_failed + cx_sy_create_object_error. count_faults = count_faults + 1. ENDTRY. ENDLOOP. diff --git a/src/foundation/y_clean_code_manager.clas.abap b/src/foundation/y_clean_code_manager.clas.abap index 2cda64ef..6c735437 100644 --- a/src/foundation/y_clean_code_manager.clas.abap +++ b/src/foundation/y_clean_code_manager.clas.abap @@ -50,12 +50,18 @@ CLASS y_clean_code_manager IMPLEMENTATION. FIND FIRST OCCURRENCE OF `Y_CLEAN_CODE_REPORTING` IN TABLE callstack. IF sy-subrc = 0. - SELECT SINGLE obj_name FROM tadir INTO obj_name - WHERE pgmid = 'R3TR' AND - object = 'TABL' AND - obj_name = profile_db. + SELECT SINGLE obj_name + FROM tadir + INTO @obj_name + WHERE pgmid = 'R3TR' + AND object = 'TABL' + AND obj_name = @profile_db. + IF sy-subrc = 0. - SELECT profile FROM (profile_db) INTO TABLE result. + SELECT profile + FROM (profile_db) + INTO TABLE @result. + IF sy-subrc = 0. RETURN. ENDIF. diff --git a/src/foundation/y_exemption_general.clas.abap b/src/foundation/y_exemption_general.clas.abap index 0f737f35..09867dce 100644 --- a/src/foundation/y_exemption_general.clas.abap +++ b/src/foundation/y_exemption_general.clas.abap @@ -19,8 +19,14 @@ CLASS y_exemption_general IMPLEMENTATION. METHOD y_if_exemption~is_object_exempted. - result = xsdbool( ( is_object_existing( object_type = object_type object_name = object_name ) = abap_true ) OR - ( is_tadir_generated( object_type = object_type object_name = object_name ) = abap_true ) ). + DATA(object_exists) = is_object_existing( object_type = object_type + object_name = object_name ). + + DATA(tadir_generated) = is_tadir_generated( object_type = object_type + object_name = object_name ). + + result = xsdbool( object_exists = abap_true + OR tadir_generated = abap_true ). ENDMETHOD. diff --git a/src/foundation/y_exemption_of_class.clas.abap b/src/foundation/y_exemption_of_class.clas.abap index 8765fd6a..c313c8a4 100644 --- a/src/foundation/y_exemption_of_class.clas.abap +++ b/src/foundation/y_exemption_of_class.clas.abap @@ -10,14 +10,12 @@ CLASS y_exemption_of_class DEFINITION PUBLIC CREATE PUBLIC. CLASS-METHODS is_odata_generate RETURNING VALUE(result) TYPE abap_bool. CLASS-METHODS is_ecatt_odata_test_generate RETURNING VALUE(result) TYPE abap_bool. CLASS-METHODS is_fin_infotype_generate RETURNING VALUE(result) TYPE abap_bool. - CLASS-METHODS is_amdp_class RETURNING VALUE(result) TYPE abap_bool. CLASS-METHODS is_extensibility_generate RETURNING VALUE(result) TYPE abap_bool. CLASS-METHODS is_shma_generate RETURNING VALUE(result) TYPE abap_bool. CLASS-METHODS is_proxy_generate RETURNING VALUE(result) TYPE abap_bool. CLASS-METHODS is_sadl_generate RETURNING VALUE(result) TYPE abap_bool. CLASS-METHODS is_exit_class RETURNING VALUE(result) TYPE abap_bool. CLASS-METHODS is_exception_class RETURNING VALUE(result) TYPE abap_bool. - CLASS-METHODS is_xlca_generate RETURNING VALUE(result) TYPE abap_bool. CLASS-METHODS is_bcp_application RETURNING VALUE(result) TYPE abap_bool. ENDCLASS. @@ -51,34 +49,6 @@ CLASS y_exemption_of_class IMPLEMENTATION. ENDMETHOD. - METHOD is_amdp_class. - DATA: lt_interfaces TYPE seor_implementing_keys. - DATA: lv_seoclskey TYPE seoclskey. - - lv_seoclskey = class_header_data-clsname. - - CALL FUNCTION 'SEO_CLASS_ALL_IMPLEMENTG_GET' - EXPORTING - clskey = lv_seoclskey - IMPORTING - set = lt_interfaces - EXCEPTIONS - not_existing = 1 - is_interface = 2 - model_only = 3 - OTHERS = 4. - IF sy-subrc <> 0. - RETURN. - ENDIF. - - LOOP AT lt_interfaces TRANSPORTING NO FIELDS - WHERE refclsname = 'IF_AMDP_MARKER_HDB'. - result = abap_true. - RETURN. - ENDLOOP. - ENDMETHOD. - - METHOD is_bcp_application. DATA it_bsp_classes TYPE STANDARD TABLE OF seoclsname. @@ -94,7 +64,7 @@ CLASS y_exemption_of_class IMPLEMENTATION. SELECT SINGLE refclsname FROM seometarel WHERE clsname = @class_header_data-clsname AND refclsname IS NOT NULL INTO @DATA(inherited_by). - IF sy-subrc NE 0. + IF sy-subrc <> 0. RETURN. ENDIF. @@ -247,32 +217,4 @@ CLASS y_exemption_of_class IMPLEMENTATION. ENDMETHOD. - METHOD is_xlca_generate. - DATA: lt_interfaces TYPE seor_implementing_keys. - DATA: lv_seoclskey TYPE seoclskey. - - lv_seoclskey = class_header_data-clsname. - - CALL FUNCTION 'SEO_CLASS_ALL_IMPLEMENTG_GET' - EXPORTING - clskey = lv_seoclskey - IMPORTING - set = lt_interfaces - EXCEPTIONS - not_existing = 1 - is_interface = 2 - model_only = 3 - OTHERS = 4. - IF sy-subrc <> 0. - RETURN. - ENDIF. - - LOOP AT lt_interfaces TRANSPORTING NO FIELDS - WHERE refclsname = 'IF_CTS_TABLE_CONVERSION'. - result = abap_true. - RETURN. - ENDLOOP. - ENDMETHOD. - - ENDCLASS. diff --git a/src/foundation/y_exemption_of_function_group.clas.abap b/src/foundation/y_exemption_of_function_group.clas.abap index 43f274d6..fd4e3d0b 100644 --- a/src/foundation/y_exemption_of_function_group.clas.abap +++ b/src/foundation/y_exemption_of_function_group.clas.abap @@ -35,21 +35,32 @@ CLASS y_exemption_of_function_group IMPLEMENTATION. IF name(1) = '/'. FIND FIRST OCCURRENCE OF '/' IN name+1 MATCH OFFSET DATA(l_offset). l_offset = l_offset + 2. - fugr_name = insert( val = name sub = 'SAPL' off = l_offset ). + fugr_name = insert( val = name + sub = 'SAPL' + off = l_offset ). ELSE. fugr_name = 'SAPL' && name. ENDIF. - SELECT SINGLE COUNT(*) FROM tfdir INTO fugr_func_viewframe - WHERE pname = fugr_name AND ( funcname LIKE 'VIEWFRAME%' OR funcname LIKE 'VIEWPROC%' OR funcname LIKE 'TABLEPROC%' OR funcname LIKE 'TABLEFRAME%' ). "#EC CI_BYPASS "#EC CI_GENBUFF + SELECT SINGLE COUNT(*) + FROM tfdir + INTO @fugr_func_viewframe + WHERE pname = @fugr_name + AND ( funcname LIKE 'VIEWFRAME%' + OR funcname LIKE 'VIEWPROC%' + OR funcname LIKE 'TABLEPROC%' + OR funcname LIKE 'TABLEFRAME%' ). "#EC CI_BYPASS "#EC CI_GENBUFF IF fugr_func_viewframe = 0 OR sy-subrc = 4. RETURN. ENDIF. - SELECT SINGLE COUNT(*) FROM tfdir INTO fugr_func - WHERE pname = fugr_name. "#EC CI_BYPASS. "#EC CI_GENBUFF - IF ( fugr_func = fugr_func_viewframe ). + SELECT SINGLE COUNT(*) + FROM tfdir + INTO @fugr_func + WHERE pname = @fugr_name. "#EC CI_BYPASS. "#EC CI_GENBUFF + + IF fugr_func = fugr_func_viewframe. result = abap_true. ENDIF. ENDMETHOD. @@ -60,7 +71,9 @@ CLASS y_exemption_of_function_group IMPLEMENTATION. FIND FIRST OCCURRENCE OF '/' IN name+1 MATCH OFFSET DATA(l_offset). l_offset = l_offset + 2. - DATA(fugr_name) = insert( val = name sub = 'SAPL' off = l_offset ). + DATA(fugr_name) = insert( val = name + sub = 'SAPL' + off = l_offset ). SELECT SINGLE funcname FROM tfdir INTO @DATA(rai_fugr_func) WHERE pname = @fugr_name diff --git a/src/foundation/y_exemption_of_program.clas.abap b/src/foundation/y_exemption_of_program.clas.abap index 593b952b..f6fb121b 100644 --- a/src/foundation/y_exemption_of_program.clas.abap +++ b/src/foundation/y_exemption_of_program.clas.abap @@ -43,12 +43,14 @@ CLASS y_exemption_of_program IMPLEMENTATION. METHOD is_enterprise_search_generate. - SELECT * FROM trdir INTO TABLE @DATA(genprog) - WHERE name LIKE '%\_001' ESCAPE '\' - AND ( secu = 'ESH' OR name LIKE 'ESHS%' ) - AND ( subc = 'S' OR subc = '1' ) "include programs ('I') are not supported - AND name = @name. - IF sy-subrc EQ 0. + SELECT SINGLE name FROM trdir + INTO @DATA(tmp) + WHERE name LIKE '%\_001' ESCAPE '\' + AND ( secu = 'ESH' OR name LIKE 'ESHS%' ) + AND ( subc = 'S' OR subc = '1' ) "include programs ('I') are not supported + AND name = @name. + + IF sy-subrc = 0. result = abap_true. ENDIF. ENDMETHOD. diff --git a/src/foundation/y_object_creation_date.clas.abap b/src/foundation/y_object_creation_date.clas.abap index 88e4c128..754d9d88 100644 --- a/src/foundation/y_object_creation_date.clas.abap +++ b/src/foundation/y_object_creation_date.clas.abap @@ -86,7 +86,10 @@ CLASS y_object_creation_date IMPLEMENTATION. DELETE buffer FROM 1 TO max_entries / 2. ENDIF. - APPEND get_db_tadir_data( object_type = object_type object_name = object_name ) TO created_on_dates. + DATA(taidr) = get_db_tadir_data( object_type = object_type + object_name = object_name ). + + APPEND taidr TO created_on_dates. DATA(repo_access) = COND #( WHEN object_type = 'FUGR' THEN convert_fugr_for_db_access( object_name ) WHEN object_type = 'CLAS' THEN convert_class_for_repos_access( object_name ) @@ -178,7 +181,7 @@ CLASS y_object_creation_date IMPLEMENTATION. DATA(search_pattern) = convert_fugr_for_db_access( fugr_name ). SELECT funcname INTO TABLE @DATA(functions) FROM tfdir WHERE pname = @search_pattern. "#EC CI_GENBUFF - IF sy-subrc NE 0. + IF sy-subrc <> 0. RETURN. ENDIF. @@ -193,7 +196,7 @@ CLASS y_object_creation_date IMPLEMENTATION. objtype = 'FUNC' AND objname IN @function_search_table AND datum IS NOT NULL AND "only in HRI - datum NE '00000000' + datum <> '00000000' INTO @result. ENDMETHOD. diff --git a/src/foundation/y_pseudo_comment_detector.clas.abap b/src/foundation/y_pseudo_comment_detector.clas.abap index 31ad1b55..f65fbe8f 100644 --- a/src/foundation/y_pseudo_comment_detector.clas.abap +++ b/src/foundation/y_pseudo_comment_detector.clas.abap @@ -135,10 +135,12 @@ CLASS y_pseudo_comment_detector IMPLEMENTATION. RETURN. ENDIF. - result = has_comment( ref_scan_manager = ref_scan_manager position = position ). + result = has_comment( ref_scan_manager = ref_scan_manager + position = position ). IF result <> cl_ci_test_root=>c_pc_exceptn_exists. - result = has_inline_comment( ref_scan_manager = ref_scan_manager position = position ). + result = has_inline_comment( ref_scan_manager = ref_scan_manager + position = position ). ENDIF. ENDMETHOD. diff --git a/src/foundation/y_test_code_detector.clas.abap b/src/foundation/y_test_code_detector.clas.abap index ee11cc3f..083c875e 100644 --- a/src/foundation/y_test_code_detector.clas.abap +++ b/src/foundation/y_test_code_detector.clas.abap @@ -41,7 +41,7 @@ CLASS Y_TEST_CODE_DETECTOR IMPLEMENTATION. ENDIF. LOOP AT ref_scan_manager->structures ASSIGNING FIELD-SYMBOL() - WHERE stmnt_type EQ scan_struc_stmnt_type-class_definition. + WHERE stmnt_type = scan_struc_stmnt_type-class_definition. process_statements( ). ENDLOOP. @@ -62,7 +62,7 @@ CLASS Y_TEST_CODE_DETECTOR IMPLEMENTATION. IF keyword( ) = 'CLASS'. DATA(class) = get_token_rel( 2 ). "#EC DECL_IN_IF READ TABLE test_codes TRANSPORTING NO FIELDS WITH KEY class = class. - IF sy-subrc EQ 0. + IF sy-subrc = 0. result = abap_true. ENDIF. ENDIF. @@ -107,7 +107,7 @@ CLASS Y_TEST_CODE_DETECTOR IMPLEMENTATION. METHOD try_testclass. - IF token-str EQ 'TESTING' AND + IF token-str = 'TESTING' AND keyword( ) = 'CLASS'. test_code-class = get_token_rel( 2 ). result = abap_true. @@ -167,7 +167,7 @@ CLASS Y_TEST_CODE_DETECTOR IMPLEMENTATION. result = abap_true. EXIT. ENDIF. - IF low_level_structure-back EQ 0. + IF low_level_structure-back = 0. EXIT. ENDIF. ENDDO. From f529f29ca8069cfe24d479d41f17ed59a86959fc Mon Sep 17 00:00:00 2001 From: Lucas Borin <5233413+lucasborin@users.noreply.github.com> Date: Wed, 7 Apr 2021 16:44:08 +0200 Subject: [PATCH 45/68] several fixes --- src/checks/y_check_unit_test_assert.clas.abap | 8 ++-- src/foundation/y_test_code_detector.clas.abap | 7 +--- ...y_test_code_detector.clas.testclasses.abap | 14 +++---- src/profiles/y_alv_events.clas.abap | 4 +- src/profiles/y_alv_tree_control.clas.abap | 21 ++++++---- src/profiles/y_if_list.intf.abap | 2 +- src/profiles/y_list.clas.abap | 6 +-- src/profiles/y_list.clas.testclasses.abap | 18 ++++---- .../y_profile_admin_classes.prog.abap | 42 +++++++++---------- 9 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/checks/y_check_unit_test_assert.clas.abap b/src/checks/y_check_unit_test_assert.clas.abap index 8c48c9bd..cd6b6134 100644 --- a/src/checks/y_check_unit_test_assert.clas.abap +++ b/src/checks/y_check_unit_test_assert.clas.abap @@ -49,11 +49,9 @@ CLASS y_check_unit_test_assert IMPLEMENTATION. RETURN. ENDIF. - IF act-str <> exp-str. - IF is_variable( act ) = abap_true - OR is_variable( exp ) = abap_true. - RETURN. - ENDIF. + IF act-str <> exp-str + AND ( is_variable( act ) = abap_true OR is_variable( exp ) = abap_true ). + RETURN. ENDIF. DATA(check_configuration) = detect_check_configuration( statement ). diff --git a/src/foundation/y_test_code_detector.clas.abap b/src/foundation/y_test_code_detector.clas.abap index 083c875e..fdde4887 100644 --- a/src/foundation/y_test_code_detector.clas.abap +++ b/src/foundation/y_test_code_detector.clas.abap @@ -61,10 +61,7 @@ CLASS Y_TEST_CODE_DETECTOR IMPLEMENTATION. METHOD is_test_class. IF keyword( ) = 'CLASS'. DATA(class) = get_token_rel( 2 ). "#EC DECL_IN_IF - READ TABLE test_codes TRANSPORTING NO FIELDS WITH KEY class = class. - IF sy-subrc = 0. - result = abap_true. - ENDIF. + result = xsdbool( line_exists( test_codes[ class = class ] ) ). ENDIF. ENDMETHOD. @@ -158,7 +155,7 @@ CLASS Y_TEST_CODE_DETECTOR IMPLEMENTATION. DO. DATA(low_level_structure) = high_level_structure. "#EC DECL_IN_IF READ TABLE ref_scan_manager->structures INTO high_level_structure INDEX low_level_structure-back. - IF sy-subrc NE 0. + IF sy-subrc <> 0. EXIT. ENDIF. diff --git a/src/foundation/y_test_code_detector.clas.testclasses.abap b/src/foundation/y_test_code_detector.clas.testclasses.abap index 5a3f47e5..06776146 100644 --- a/src/foundation/y_test_code_detector.clas.testclasses.abap +++ b/src/foundation/y_test_code_detector.clas.testclasses.abap @@ -76,7 +76,7 @@ CLASS ltc_test_code_detector IMPLEMENTATION. ref_scan_manager_double->set_data_without_test( ). LOOP AT ref_scan_manager_double->y_if_scan_manager~structures ASSIGNING FIELD-SYMBOL() - FROM 2 WHERE stmnt_type EQ scan_struc_stmnt_type-class_definition. + FROM 2 WHERE stmnt_type = scan_struc_stmnt_type-class_definition. cl_abap_unit_assert=>assert_equals( act = cut->y_if_testcode_detector~is_testcode( ) @@ -89,7 +89,7 @@ CLASS ltc_test_code_detector IMPLEMENTATION. ref_scan_manager_double->set_data_with_test( ). LOOP AT ref_scan_manager_double->y_if_scan_manager~structures ASSIGNING FIELD-SYMBOL() - FROM 2 WHERE stmnt_type EQ scan_struc_stmnt_type-class_definition. + FROM 2 WHERE stmnt_type = scan_struc_stmnt_type-class_definition. cl_abap_unit_assert=>assert_equals( act = cut->y_if_testcode_detector~is_testcode( ) @@ -102,7 +102,7 @@ CLASS ltc_test_code_detector IMPLEMENTATION. ref_scan_manager_double->set_data_without_test( ). LOOP AT ref_scan_manager_double->y_if_scan_manager~structures ASSIGNING FIELD-SYMBOL() - FROM 2 WHERE stmnt_type EQ scan_struc_stmnt_type-method. + FROM 2 WHERE stmnt_type = scan_struc_stmnt_type-method. cl_abap_unit_assert=>assert_equals( act = cut->y_if_testcode_detector~is_testcode( ) @@ -115,7 +115,7 @@ CLASS ltc_test_code_detector IMPLEMENTATION. ref_scan_manager_double->set_data_with_test( ). LOOP AT ref_scan_manager_double->y_if_scan_manager~structures ASSIGNING FIELD-SYMBOL() - FROM 2 WHERE stmnt_type EQ scan_struc_stmnt_type-method. + FROM 2 WHERE stmnt_type = scan_struc_stmnt_type-method. cl_abap_unit_assert=>assert_equals( act = cut->y_if_testcode_detector~is_testcode( ) @@ -128,7 +128,7 @@ CLASS ltc_test_code_detector IMPLEMENTATION. ref_scan_manager_double->set_data_with_test( ). LOOP AT ref_scan_manager_double->y_if_scan_manager~structures ASSIGNING FIELD-SYMBOL() - FROM 2 WHERE stmnt_type EQ scan_struc_stmnt_type-class_definition. + FROM 2 WHERE stmnt_type = scan_struc_stmnt_type-class_definition. cl_abap_unit_assert=>assert_equals( act = cut->y_if_testcode_detector~is_testcode( ) @@ -141,7 +141,7 @@ CLASS ltc_test_code_detector IMPLEMENTATION. ref_scan_manager_double->set_data_without_test( ). LOOP AT ref_scan_manager_double->y_if_scan_manager~structures ASSIGNING FIELD-SYMBOL() - FROM 2 WHERE stmnt_type EQ scan_struc_stmnt_type-class_definition. + FROM 2 WHERE stmnt_type = scan_struc_stmnt_type-class_definition. cl_abap_unit_assert=>assert_equals( act = cut->y_if_testcode_detector~is_testcode( ) @@ -154,7 +154,7 @@ CLASS ltc_test_code_detector IMPLEMENTATION. ref_scan_manager_double->set_data_with_test( ). LOOP AT ref_scan_manager_double->y_if_scan_manager~structures ASSIGNING FIELD-SYMBOL() - FROM 2 WHERE stmnt_type EQ scan_struc_stmnt_type-class_definition. + FROM 2 WHERE stmnt_type = scan_struc_stmnt_type-class_definition. cl_abap_unit_assert=>assert_equals( act = cut->y_if_testcode_detector~is_testcode( ) diff --git a/src/profiles/y_alv_events.clas.abap b/src/profiles/y_alv_events.clas.abap index c97f3eef..35651613 100644 --- a/src/profiles/y_alv_events.clas.abap +++ b/src/profiles/y_alv_events.clas.abap @@ -15,10 +15,10 @@ CLASS y_alv_events IMPLEMENTATION. METHOD y_if_alv_events~get_events. - IF mode EQ y_if_alv_events~mode_double_click. + IF mode = y_if_alv_events~mode_double_click. result = VALUE y_if_alv_events=>simple_events( ( eventid = cl_gui_column_tree=>eventid_node_double_click appl_event = abap_true ) ). - ELSEIF mode EQ y_if_alv_events~mode_selection_changed. + ELSEIF mode = y_if_alv_events~mode_selection_changed. result = VALUE y_if_alv_events=>simple_events( ( eventid = cl_gui_column_tree=>eventid_selection_changed appl_event = abap_true ) ). ENDIF. diff --git a/src/profiles/y_alv_tree_control.clas.abap b/src/profiles/y_alv_tree_control.clas.abap index c8872987..c98d8373 100644 --- a/src/profiles/y_alv_tree_control.clas.abap +++ b/src/profiles/y_alv_tree_control.clas.abap @@ -55,7 +55,7 @@ CLASS Y_ALV_TREE_CONTROL IMPLEMENTATION. METHOD autosize_all_fields. DATA filler TYPE i VALUE 7. LOOP AT fieldcats ASSIGNING FIELD-SYMBOL(). - IF -dd_outlen GE strlen( -coltext ). + IF -dd_outlen >= strlen( -coltext ). -outputlen = -dd_outlen + filler. ELSE. -outputlen = strlen( -coltext ) + filler. @@ -130,7 +130,7 @@ CLASS Y_ALV_TREE_CONTROL IMPLEMENTATION. METHOD y_if_alv_tree_control~get_selected_index. DATA index_table TYPE lvc_t_indx. CHECK y_if_alv_tree_control~list_control( )->get_line_at( 1 ) IS NOT INITIAL. - IF sy-subrc EQ 0. + IF sy-subrc = 0. alv_tree->get_selected_nodes( CHANGING ct_index_outtab = index_table ). TRY. result = index_table[ 1 ]. @@ -142,9 +142,12 @@ CLASS Y_ALV_TREE_CONTROL IMPLEMENTATION. METHOD y_if_alv_tree_control~set_selected_index. - CHECK y_if_alv_tree_control~list_control( )->get_line_at( 1 ) IS NOT INITIAL. DATA index_table TYPE lvc_t_indx. + + CHECK y_if_alv_tree_control~list_control( )->get_line_at( 1 ) IS NOT INITIAL. + APPEND index TO index_table. + alv_tree->set_selected_nodes( EXPORTING it_index_outtab = index_table @@ -196,7 +199,7 @@ CLASS Y_ALV_TREE_CONTROL IMPLEMENTATION. METHOD y_if_alv_tree_control~set_field_header_text. - LOOP AT fieldcats ASSIGNING FIELD-SYMBOL() WHERE fieldname EQ to_upper( fieldname ). + LOOP AT fieldcats ASSIGNING FIELD-SYMBOL() WHERE fieldname = to_upper( fieldname ). -coltext = header_text. ENDLOOP. UNASSIGN . @@ -204,8 +207,8 @@ CLASS Y_ALV_TREE_CONTROL IMPLEMENTATION. METHOD y_if_alv_tree_control~set_field_visibility. - LOOP AT fieldcats ASSIGNING FIELD-SYMBOL() WHERE fieldname EQ to_upper( fieldname ). - -no_out = xsdbool( is_visible EQ abap_false ). + LOOP AT fieldcats ASSIGNING FIELD-SYMBOL() WHERE fieldname = to_upper( fieldname ). + -no_out = xsdbool( is_visible = abap_false ). ENDLOOP. UNASSIGN . ENDMETHOD. @@ -213,7 +216,7 @@ CLASS Y_ALV_TREE_CONTROL IMPLEMENTATION. METHOD y_if_alv_tree_control~toolbar_control. alv_tree->get_toolbar_object( IMPORTING er_toolbar = result EXCEPTIONS OTHERS = 4 ). - IF sy-subrc NE 0. + IF sy-subrc <> 0. RAISE EXCEPTION TYPE cx_failed. ENDIF. ENDMETHOD. @@ -229,7 +232,7 @@ CLASS Y_ALV_TREE_CONTROL IMPLEMENTATION. y_if_alv_tree_control~toolbar_control( )->set_button_state( EXPORTING enabled = abap_true fcode =