@abaplint/core 2.80.8 → 2.81.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +6 -6
  2. package/build/abaplint.d.ts +8 -0
  3. package/build/src/abap/2_statements/expressions/sql_arithmetics.js +2 -1
  4. package/build/src/abap/2_statements/expressions/sql_function.js +14 -3
  5. package/build/src/abap/2_statements/statements/move.js +3 -2
  6. package/build/src/abap/5_syntax/_current_scope.js +26 -0
  7. package/build/src/abap/5_syntax/_scope_type.js +1 -0
  8. package/build/src/abap/5_syntax/basic_types.js +5 -1
  9. package/build/src/abap/5_syntax/expressions/field_assignment.js +12 -6
  10. package/build/src/abap/5_syntax/spaghetti_scope.js +13 -0
  11. package/build/src/abap/5_syntax/statements/class_implementation.js +4 -2
  12. package/build/src/abap/5_syntax/statements/method_implementation.js +7 -3
  13. package/build/src/abap/5_syntax/syntax.js +6 -1
  14. package/build/src/abap/flow/flow_graph.js +7 -7
  15. package/build/src/lsp/help.js +7 -7
  16. package/build/src/registry.js +1 -1
  17. package/build/src/rules/abapdoc.js +1 -1
  18. package/build/src/rules/align_parameters.js +33 -33
  19. package/build/src/rules/ambiguous_statement.js +5 -5
  20. package/build/src/rules/avoid_use.js +6 -6
  21. package/build/src/rules/begin_end_names.js +4 -4
  22. package/build/src/rules/begin_single_include.js +12 -12
  23. package/build/src/rules/call_transaction_authority_check.js +3 -3
  24. package/build/src/rules/chain_mainly_declarations.js +4 -4
  25. package/build/src/rules/check_abstract.js +2 -2
  26. package/build/src/rules/check_comments.js +3 -3
  27. package/build/src/rules/check_include.js +3 -3
  28. package/build/src/rules/check_no_handler_pragma.js +8 -8
  29. package/build/src/rules/check_subrc.js +8 -8
  30. package/build/src/rules/commented_code.js +1 -1
  31. package/build/src/rules/constructor_visibility_public.js +4 -4
  32. package/build/src/rules/contains_tab.js +2 -2
  33. package/build/src/rules/dangerous_statement.js +1 -1
  34. package/build/src/rules/downport.js +35 -35
  35. package/build/src/rules/exit_or_check.js +3 -3
  36. package/build/src/rules/exporting.js +1 -1
  37. package/build/src/rules/forbidden_identifier.js +1 -1
  38. package/build/src/rules/forbidden_void_type.js +2 -2
  39. package/build/src/rules/functional_writing.js +17 -17
  40. package/build/src/rules/global_class.js +10 -10
  41. package/build/src/rules/identical_conditions.js +2 -2
  42. package/build/src/rules/identical_contents.js +15 -15
  43. package/build/src/rules/identical_descriptions.js +4 -4
  44. package/build/src/rules/if_in_if.js +7 -7
  45. package/build/src/rules/implement_methods.js +3 -3
  46. package/build/src/rules/in_statement_indentation.js +11 -11
  47. package/build/src/rules/index.js +2 -0
  48. package/build/src/rules/intf_referencing_clas.js +3 -3
  49. package/build/src/rules/line_break_style.js +2 -2
  50. package/build/src/rules/line_length.js +1 -1
  51. package/build/src/rules/line_only_punc.js +1 -1
  52. package/build/src/rules/local_variable_names.js +2 -2
  53. package/build/src/rules/many_parentheses.js +10 -10
  54. package/build/src/rules/max_one_method_parameter_per_line.js +7 -7
  55. package/build/src/rules/max_one_statement.js +3 -3
  56. package/build/src/rules/nesting.js +1 -1
  57. package/build/src/rules/no_chained_assignment.js +52 -0
  58. package/build/src/rules/no_public_attributes.js +1 -1
  59. package/build/src/rules/no_yoda_conditions.js +4 -4
  60. package/build/src/rules/obsolete_statement.js +36 -36
  61. package/build/src/rules/omit_parameter_name.js +3 -3
  62. package/build/src/rules/omit_receiving.js +13 -13
  63. package/build/src/rules/parser_702_chaining.js +2 -2
  64. package/build/src/rules/parser_error.js +2 -2
  65. package/build/src/rules/parser_missing_space.js +1 -1
  66. package/build/src/rules/prefer_inline.js +19 -18
  67. package/build/src/rules/prefer_is_not.js +7 -7
  68. package/build/src/rules/prefer_raise_exception_new.js +3 -3
  69. package/build/src/rules/prefer_returning_to_exporting.js +1 -1
  70. package/build/src/rules/prefer_xsdbool.js +2 -2
  71. package/build/src/rules/remove_descriptions.js +4 -4
  72. package/build/src/rules/rfc_error_handling.js +9 -9
  73. package/build/src/rules/select_add_order_by.js +5 -5
  74. package/build/src/rules/select_performance.js +2 -2
  75. package/build/src/rules/sicf_consistency.js +4 -4
  76. package/build/src/rules/space_before_dot.js +2 -2
  77. package/build/src/rules/start_at_tab.js +1 -1
  78. package/build/src/rules/sy_modification.js +2 -2
  79. package/build/src/rules/tabl_enhancement_category.js +2 -2
  80. package/build/src/rules/unnecessary_chaining.js +58 -0
  81. package/build/src/rules/unreachable_code.js +4 -0
  82. package/build/src/rules/unused_methods.js +9 -9
  83. package/build/src/rules/unused_variables.js +6 -6
  84. package/build/src/rules/use_bool_expression.js +8 -8
  85. package/build/src/rules/use_line_exists.js +6 -6
  86. package/build/src/rules/use_new.js +2 -2
  87. package/build/src/rules/when_others_last.js +6 -6
  88. package/package.json +66 -65
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NoChainedAssignment = exports.NoChainedAssignmentConf = void 0;
4
+ const Expressions = require("../abap/2_statements/expressions");
5
+ const Statements = require("../abap/2_statements/statements");
6
+ const issue_1 = require("../issue");
7
+ const _abap_rule_1 = require("./_abap_rule");
8
+ const _basic_rule_config_1 = require("./_basic_rule_config");
9
+ const _irule_1 = require("./_irule");
10
+ class NoChainedAssignmentConf extends _basic_rule_config_1.BasicRuleConfig {
11
+ }
12
+ exports.NoChainedAssignmentConf = NoChainedAssignmentConf;
13
+ class NoChainedAssignment extends _abap_rule_1.ABAPRule {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.conf = new NoChainedAssignmentConf();
17
+ }
18
+ getMetadata() {
19
+ return {
20
+ key: "no_chained_assignment",
21
+ title: "No chained assignment",
22
+ shortDescription: `Find chained assingments and reports issues`,
23
+ extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#dont-chain-assignments`,
24
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide],
25
+ badExample: `var1 = var2 = var3.`,
26
+ goodExample: `var2 = var3.
27
+ var1 = var2.`,
28
+ };
29
+ }
30
+ getConfig() {
31
+ return this.conf;
32
+ }
33
+ setConfig(conf) {
34
+ this.conf = conf;
35
+ }
36
+ runParsed(file) {
37
+ const issues = [];
38
+ for (const s of file.getStatements()) {
39
+ if (!(s.get() instanceof Statements.Move)) {
40
+ continue;
41
+ }
42
+ if (s.findDirectExpressions(Expressions.Target).length >= 2) {
43
+ const message = "No chained assignment";
44
+ const issue = issue_1.Issue.atStatement(file, s, message, this.getMetadata().key);
45
+ issues.push(issue);
46
+ }
47
+ }
48
+ return issues;
49
+ }
50
+ }
51
+ exports.NoChainedAssignment = NoChainedAssignment;
52
+ //# sourceMappingURL=no_chained_assignment.js.map
@@ -25,7 +25,7 @@ class NoPublicAttributes extends _abap_rule_1.ABAPRule {
25
25
  return {
26
26
  key: "no_public_attributes",
27
27
  title: "No public attributes",
28
- shortDescription: `Checks that classes and interfaces don't contain any public attributes.
28
+ shortDescription: `Checks that classes and interfaces don't contain any public attributes.
29
29
  Exceptions are excluded from this rule.`,
30
30
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#members-private-by-default-protected-only-if-needed`,
31
31
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
@@ -24,13 +24,13 @@ class NoYodaConditions extends _abap_rule_1.ABAPRule {
24
24
  key: "no_yoda_conditions",
25
25
  title: "No Yoda conditions",
26
26
  shortDescription: `Finds Yoda conditions and reports issues`,
27
- extendedInformation: `https://en.wikipedia.org/wiki/Yoda_conditions
28
-
27
+ extendedInformation: `https://en.wikipedia.org/wiki/Yoda_conditions
28
+
29
29
  Conditions with operators CP, NP, CS, NS, CA, NA, CO, CN are ignored`,
30
30
  tags: [_irule_1.RuleTag.SingleFile],
31
- badExample: `IF 0 <> sy-subrc.
31
+ badExample: `IF 0 <> sy-subrc.
32
32
  ENDIF.`,
33
- goodExample: `IF sy-subrc <> 0.
33
+ goodExample: `IF sy-subrc <> 0.
34
34
  ENDIF.`,
35
35
  };
36
36
  }
@@ -77,42 +77,42 @@ class ObsoleteStatement extends _abap_rule_1.ABAPRule {
77
77
  title: "Obsolete statements",
78
78
  shortDescription: `Checks for usages of certain obsolete statements`,
79
79
  tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix],
80
- extendedInformation: `
81
- https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-functional-to-procedural-language-constructs
82
-
83
- https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-obsolete-language-elements
84
-
85
- SET EXTENDED CHECK: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapset_extended_check.htm
86
-
87
- IS REQUESTED: https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenlogexp_requested.htm
88
-
89
- WITH HEADER LINE: https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapdata_header_line.htm
90
-
91
- FIELD-SYMBOLS STRUCTURE: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapfield-symbols_obsolete_typing.htm
92
-
93
- TYPE-POOLS: from 702, https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abennews-71-program_load.htm
94
-
95
- LOAD addition: from 702, https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abennews-71-program_load.htm
96
-
97
- COMMUICATION: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapcommunication.htm
98
-
99
- OCCURS: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapdata_occurs.htm
100
-
101
- PARAMETER: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abapparameter.htm
102
-
103
- RANGES: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapranges.htm
104
-
105
- PACK: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abappack.htm
106
-
107
- SELECT without INTO: https://help.sap.com/doc/abapdocu_731_index_htm/7.31/en-US/abapselect_obsolete.htm
108
- SELECT COUNT(*) is considered okay
109
-
110
- FREE MEMORY: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abapfree_mem_id_obsolete.htm
111
-
112
- SORT BY FS: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapsort_itab_obsolete.htm
113
-
114
- CALL TRANSFORMATION OBJECTS: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapcall_transformation_objects.htm
115
-
80
+ extendedInformation: `
81
+ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-functional-to-procedural-language-constructs
82
+
83
+ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-obsolete-language-elements
84
+
85
+ SET EXTENDED CHECK: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapset_extended_check.htm
86
+
87
+ IS REQUESTED: https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenlogexp_requested.htm
88
+
89
+ WITH HEADER LINE: https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapdata_header_line.htm
90
+
91
+ FIELD-SYMBOLS STRUCTURE: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapfield-symbols_obsolete_typing.htm
92
+
93
+ TYPE-POOLS: from 702, https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abennews-71-program_load.htm
94
+
95
+ LOAD addition: from 702, https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abennews-71-program_load.htm
96
+
97
+ COMMUICATION: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapcommunication.htm
98
+
99
+ OCCURS: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abapdata_occurs.htm
100
+
101
+ PARAMETER: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abapparameter.htm
102
+
103
+ RANGES: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapranges.htm
104
+
105
+ PACK: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abappack.htm
106
+
107
+ SELECT without INTO: https://help.sap.com/doc/abapdocu_731_index_htm/7.31/en-US/abapselect_obsolete.htm
108
+ SELECT COUNT(*) is considered okay
109
+
110
+ FREE MEMORY: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abapfree_mem_id_obsolete.htm
111
+
112
+ SORT BY FS: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapsort_itab_obsolete.htm
113
+
114
+ CALL TRANSFORMATION OBJECTS: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapcall_transformation_objects.htm
115
+
116
116
  POSIX REGEX: https://help.sap.com/doc/abapdocu_755_index_htm/7.55/en-US/index.htm`,
117
117
  };
118
118
  }
@@ -22,9 +22,9 @@ class OmitParameterName {
22
22
  key: "omit_parameter_name",
23
23
  title: "Omit parameter name",
24
24
  shortDescription: `Omit the parameter name in single parameter calls`,
25
- extendedInformation: `
26
- https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#omit-the-parameter-name-in-single-parameter-calls
27
-
25
+ extendedInformation: `
26
+ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#omit-the-parameter-name-in-single-parameter-calls
27
+
28
28
  EXPORTING must already be omitted for this rule to take effect, https://rules.abaplint.org/exporting/`,
29
29
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix],
30
30
  badExample: `method( param = 2 ).`,
@@ -21,20 +21,20 @@ class OmitReceiving extends _abap_rule_1.ABAPRule {
21
21
  shortDescription: `Omit RECEIVING`,
22
22
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#omit-receiving`,
23
23
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
24
- badExample: `
25
- upload_pack(
26
- EXPORTING
27
- io_client = lo_client
28
- iv_url = iv_url
29
- iv_deepen_level = iv_deepen_level
30
- it_hashes = lt_hashes
31
- RECEIVING
24
+ badExample: `
25
+ upload_pack(
26
+ EXPORTING
27
+ io_client = lo_client
28
+ iv_url = iv_url
29
+ iv_deepen_level = iv_deepen_level
30
+ it_hashes = lt_hashes
31
+ RECEIVING
32
32
  rt_objects = et_objects ).`,
33
- goodExample: `
34
- et_objects = upload_pack(
35
- io_client = lo_client
36
- iv_url = iv_url
37
- iv_deepen_level = iv_deepen_level
33
+ goodExample: `
34
+ et_objects = upload_pack(
35
+ io_client = lo_client
36
+ iv_url = iv_url
37
+ iv_deepen_level = iv_deepen_level
38
38
  it_hashes = lt_hashes ).`,
39
39
  };
40
40
  }
@@ -19,8 +19,8 @@ class Parser702Chaining extends _abap_rule_1.ABAPRule {
19
19
  return {
20
20
  key: "parser_702_chaining",
21
21
  title: "Parser Error, bad chanining on 702",
22
- shortDescription: `ABAP on 702 does not allow for method chaining with IMPORTING/EXPORTING/CHANGING keywords,
23
- this rule finds these and reports errors.
22
+ shortDescription: `ABAP on 702 does not allow for method chaining with IMPORTING/EXPORTING/CHANGING keywords,
23
+ this rule finds these and reports errors.
24
24
  Only active on target version 702 and below.`,
25
25
  tags: [_irule_1.RuleTag.Syntax, _irule_1.RuleTag.SingleFile],
26
26
  };
@@ -20,8 +20,8 @@ class ParserError extends _abap_rule_1.ABAPRule {
20
20
  return {
21
21
  key: "parser_error",
22
22
  title: "Parser error",
23
- shortDescription: `Checks for syntax not recognized by abaplint.
24
-
23
+ shortDescription: `Checks for syntax not recognized by abaplint.
24
+
25
25
  See recognized syntax at https://syntax.abaplint.org`,
26
26
  tags: [_irule_1.RuleTag.Syntax, _irule_1.RuleTag.SingleFile],
27
27
  };
@@ -21,7 +21,7 @@ class ParserMissingSpace extends _abap_rule_1.ABAPRule {
21
21
  return {
22
22
  key: "parser_missing_space",
23
23
  title: "Parser Error, missing space",
24
- shortDescription: `In special cases the ABAP language allows for not having spaces before or after string literals.
24
+ shortDescription: `In special cases the ABAP language allows for not having spaces before or after string literals.
25
25
  This rule makes sure the spaces are consistently required across the language.`,
26
26
  tags: [_irule_1.RuleTag.Syntax, _irule_1.RuleTag.Whitespace, _irule_1.RuleTag.SingleFile],
27
27
  badExample: `IF ( foo = 'bar').`,
@@ -23,25 +23,25 @@ class PreferInline {
23
23
  key: "prefer_inline",
24
24
  title: "Prefer Inline Declarations",
25
25
  shortDescription: `Prefer inline to up-front declarations.`,
26
- extendedInformation: `EXPERIMENTAL
27
-
28
- Activates if language version is v740sp02 or above.
29
-
30
- Variables must be local(METHOD or FORM).
31
-
32
- No generic or void typed variables.
33
-
34
- First position used must be a full/pure write.
35
-
36
- Move statment is not a cast(?=)
37
-
26
+ extendedInformation: `EXPERIMENTAL
27
+
28
+ Activates if language version is v740sp02 or above.
29
+
30
+ Variables must be local(METHOD or FORM).
31
+
32
+ No generic or void typed variables.
33
+
34
+ First position used must be a full/pure write.
35
+
36
+ Move statment is not a cast(?=)
37
+
38
38
  https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-inline-to-up-front-declarations`,
39
39
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Upport, _irule_1.RuleTag.Experimental, _irule_1.RuleTag.Quickfix],
40
- badExample: `DATA foo TYPE i.
41
- foo = 2.
42
- DATA percentage TYPE decfloat34.
40
+ badExample: `DATA foo TYPE i.
41
+ foo = 2.
42
+ DATA percentage TYPE decfloat34.
43
43
  percentage = ( comment_number / abs_statement_number ) * 100.`,
44
- goodExample: `DATA(foo) = 2.
44
+ goodExample: `DATA(foo) = 2.
45
45
  DATA(percentage) = CONV decfloat34( comment_number / abs_statement_number ) * 100.`,
46
46
  };
47
47
  }
@@ -74,7 +74,7 @@ DATA(percentage) = CONV decfloat34( comment_number / abs_statement_number ) * 10
74
74
  }
75
75
  ///////////////////////////
76
76
  analyzeScope(node, obj) {
77
- var _a;
77
+ var _a, _b;
78
78
  const ret = [];
79
79
  const vars = node.getData().vars;
80
80
  for (const name in vars) {
@@ -113,7 +113,8 @@ DATA(percentage) = CONV decfloat34( comment_number / abs_statement_number ) * 10
113
113
  || statementType instanceof Statements.Catch
114
114
  || statementType instanceof Statements.ReadTable
115
115
  || statementType instanceof Statements.Loop)
116
- || ((_a = writeStatement === null || writeStatement === void 0 ? void 0 : writeStatement.concatTokens()) === null || _a === void 0 ? void 0 : _a.includes("?="))) {
116
+ || ((_a = writeStatement === null || writeStatement === void 0 ? void 0 : writeStatement.concatTokens()) === null || _a === void 0 ? void 0 : _a.includes("?="))
117
+ || ((_b = writeStatement === null || writeStatement === void 0 ? void 0 : writeStatement.concatTokens()) === null || _b === void 0 ? void 0 : _b.includes(" #("))) {
117
118
  continue;
118
119
  }
119
120
  const statement = edit_helper_1.EditHelper.findStatement(identifier.getToken(), file);
@@ -21,16 +21,16 @@ class PreferIsNot extends _abap_rule_1.ABAPRule {
21
21
  key: "prefer_is_not",
22
22
  title: "Prefer IS NOT to NOT IS",
23
23
  shortDescription: `Prefer IS NOT to NOT IS`,
24
- extendedInformation: `
25
- https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-is-not-to-not-is
26
-
24
+ extendedInformation: `
25
+ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-is-not-to-not-is
26
+
27
27
  "if not is_valid( )." examples are skipped`,
28
28
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
29
- goodExample: `IF variable IS NOT INITIAL.
30
- IF variable NP 'TODO*'.
29
+ goodExample: `IF variable IS NOT INITIAL.
30
+ IF variable NP 'TODO*'.
31
31
  IF variable <> 42.`,
32
- badExample: `IF NOT variable IS INITIAL.
33
- IF NOT variable CP 'TODO*'.
32
+ badExample: `IF NOT variable IS INITIAL.
33
+ IF NOT variable CP 'TODO*'.
34
34
  IF NOT variable = 42.`,
35
35
  };
36
36
  }
@@ -20,12 +20,12 @@ class PreferRaiseExceptionNew extends _abap_rule_1.ABAPRule {
20
20
  key: "prefer_raise_exception_new",
21
21
  title: "Prefer RAISE EXCEPTION NEW to RAISE EXCEPTION TYPE",
22
22
  shortDescription: `Prefer RAISE EXCEPTION NEW to RAISE EXCEPTION TYPE`,
23
- extendedInformation: `
23
+ extendedInformation: `
24
24
  https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-raise-exception-new-to-raise-exception-type`,
25
25
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
26
26
  goodExample: `RAISE EXCEPTION NEW cx_generation_error( previous = exception ).`,
27
- badExample: `RAISE EXCEPTION TYPE cx_generation_error
28
- EXPORTING
27
+ badExample: `RAISE EXCEPTION TYPE cx_generation_error
28
+ EXPORTING
29
29
  previous = exception.`,
30
30
  };
31
31
  }
@@ -20,7 +20,7 @@ class PreferReturningToExporting extends _abap_rule_1.ABAPRule {
20
20
  key: "prefer_returning_to_exporting",
21
21
  title: "Prefer RETURNING to EXPORTING",
22
22
  shortDescription: `Prefer RETURNING to EXPORTING. Generic types cannot be RETURNING.`,
23
- extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-returning-to-exporting
23
+ extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-returning-to-exporting
24
24
  https://docs.abapopenchecks.org/checks/44/`,
25
25
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
26
26
  };
@@ -21,8 +21,8 @@ class PreferXsdbool extends _abap_rule_1.ABAPRule {
21
21
  key: "prefer_xsdbool",
22
22
  title: "Prefer xsdbool over boolc",
23
23
  shortDescription: `Prefer xsdbool over boolc`,
24
- extendedInformation: `Activates if language version is v740sp08 or above.
25
-
24
+ extendedInformation: `Activates if language version is v740sp08 or above.
25
+
26
26
  https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-xsdbool-to-set-boolean-variables`,
27
27
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Upport, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
28
28
  badExample: `DATA(sdf) = boolc( 1 = 2 ).`,
@@ -26,10 +26,10 @@ class RemoveDescriptions {
26
26
  return {
27
27
  key: "remove_descriptions",
28
28
  title: "Remove descriptions",
29
- shortDescription: `Ensures you have no descriptions in metadata of methods, parameters, etc.
30
-
31
- Class descriptions are required, see rule description_empty.
32
-
29
+ shortDescription: `Ensures you have no descriptions in metadata of methods, parameters, etc.
30
+
31
+ Class descriptions are required, see rule description_empty.
32
+
33
33
  Consider using ABAP Doc for documentation.`,
34
34
  tags: [],
35
35
  };
@@ -22,16 +22,16 @@ class RFCErrorHandling extends _abap_rule_1.ABAPRule {
22
22
  tags: [_irule_1.RuleTag.SingleFile],
23
23
  shortDescription: `Checks that exceptions 'system_failure' and 'communication_failure' are handled in RFC calls`,
24
24
  extendedInformation: `https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenrfc_exception.htm`,
25
- badExample: `
26
- CALL FUNCTION 'ZRFC'
25
+ badExample: `
26
+ CALL FUNCTION 'ZRFC'
27
27
  DESTINATION lv_rfc.`,
28
- goodExample: `
29
- CALL FUNCTION 'ZRFC'
30
- DESTINATION lv_rfc
31
- EXCEPTIONS
32
- system_failure = 1 MESSAGE msg
33
- communication_failure = 2 MESSAGE msg
34
- resource_failure = 3
28
+ goodExample: `
29
+ CALL FUNCTION 'ZRFC'
30
+ DESTINATION lv_rfc
31
+ EXCEPTIONS
32
+ system_failure = 1 MESSAGE msg
33
+ communication_failure = 2 MESSAGE msg
34
+ resource_failure = 3
35
35
  OTHERS = 4.`,
36
36
  };
37
37
  }
@@ -21,11 +21,11 @@ class SelectAddOrderBy {
21
21
  key: "select_add_order_by",
22
22
  title: "SELECT add ORDER BY",
23
23
  shortDescription: `SELECTs add ORDER BY clause`,
24
- extendedInformation: `
25
- This will make sure that the SELECT statement returns results in the same sequence on different databases
26
-
27
- add ORDER BY PRIMARY KEY if in doubt
28
-
24
+ extendedInformation: `
25
+ This will make sure that the SELECT statement returns results in the same sequence on different databases
26
+
27
+ add ORDER BY PRIMARY KEY if in doubt
28
+
29
29
  If the target is a sorted/hashed table, no issue is reported`,
30
30
  tags: [_irule_1.RuleTag.SingleFile],
31
31
  };
@@ -32,8 +32,8 @@ class SelectPerformance {
32
32
  key: "select_performance",
33
33
  title: "SELECT performance",
34
34
  shortDescription: `Various checks regarding SELECT performance.`,
35
- extendedInformation: `ENDSELECT: not reported when the corresponding SELECT has PACKAGE SIZE
36
-
35
+ extendedInformation: `ENDSELECT: not reported when the corresponding SELECT has PACKAGE SIZE
36
+
37
37
  SELECT *: not reported if using INTO/APPENDING CORRESPONDING FIELDS OF`,
38
38
  tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Performance],
39
39
  };
@@ -16,10 +16,10 @@ class SICFConsistency {
16
16
  return {
17
17
  key: "sicf_consistency",
18
18
  title: "SICF consistency",
19
- shortDescription: `Checks the validity of ICF services:
20
-
21
- * Class defined in handler must exist
22
- * Class must not have any syntax errors
19
+ shortDescription: `Checks the validity of ICF services:
20
+
21
+ * Class defined in handler must exist
22
+ * Class must not have any syntax errors
23
23
  * Class must implement interface IF_HTTP_EXTENSION`,
24
24
  };
25
25
  }
@@ -29,8 +29,8 @@ class SpaceBeforeDot extends _abap_rule_1.ABAPRule {
29
29
  key: "space_before_dot",
30
30
  title: "Space before dot",
31
31
  shortDescription: `Checks for extra spaces before dots at the ends of statements`,
32
- extendedInformation: `
33
- https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#be-consistent
32
+ extendedInformation: `
33
+ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#be-consistent
34
34
  https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#condense-your-code`,
35
35
  tags: [_irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
36
36
  badExample: `WRITE bar .`,
@@ -20,7 +20,7 @@ class StartAtTab extends _abap_rule_1.ABAPRule {
20
20
  key: "start_at_tab",
21
21
  title: "Start at tab",
22
22
  shortDescription: `Checks that statements start at tabstops.`,
23
- extendedInformation: `Reports max 100 issues per file
23
+ extendedInformation: `Reports max 100 issues per file
24
24
  https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#indent-and-snap-to-tab`,
25
25
  tags: [_irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
26
26
  badExample: ` WRITE a.`,
@@ -21,8 +21,8 @@ class SyModification extends _abap_rule_1.ABAPRule {
21
21
  shortDescription: `Finds modification of sy fields`,
22
22
  extendedInformation: `https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abensystem_fields.htm`,
23
23
  tags: [_irule_1.RuleTag.SingleFile],
24
- badExample: `
25
- sy-uname = 2.
24
+ badExample: `
25
+ sy-uname = 2.
26
26
  sy = sy.`,
27
27
  };
28
28
  }
@@ -17,8 +17,8 @@ class TABLEnhancementCategory {
17
17
  key: "tabl_enhancement_category",
18
18
  title: "TABL enhancement category must be set",
19
19
  shortDescription: `Checks that tables do not have the enhancement category 'not classified'.`,
20
- extendedInformation: `SAP note 3063227 changes the default to 'Cannot be enhanced'.
21
-
20
+ extendedInformation: `SAP note 3063227 changes the default to 'Cannot be enhanced'.
21
+
22
22
  You may use standard report RS_DDIC_CLASSIFICATION_FINAL for adjustment.`,
23
23
  tags: [],
24
24
  };
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnnecessaryChaining = exports.UnnecessaryChainingConf = void 0;
4
+ const issue_1 = require("../issue");
5
+ const _abap_rule_1 = require("./_abap_rule");
6
+ const _basic_rule_config_1 = require("./_basic_rule_config");
7
+ const _irule_1 = require("./_irule");
8
+ class UnnecessaryChainingConf extends _basic_rule_config_1.BasicRuleConfig {
9
+ }
10
+ exports.UnnecessaryChainingConf = UnnecessaryChainingConf;
11
+ class UnnecessaryChaining extends _abap_rule_1.ABAPRule {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.conf = new UnnecessaryChainingConf();
15
+ }
16
+ getMetadata() {
17
+ return {
18
+ key: "unnecessary_chaining",
19
+ title: "Unnecessary Chaining",
20
+ shortDescription: `Find unnecessary chaining, all statements are checked`,
21
+ extendedInformation: ``,
22
+ tags: [_irule_1.RuleTag.SingleFile],
23
+ badExample: `WRITE: bar.`,
24
+ goodExample: `WRITE bar.`,
25
+ };
26
+ }
27
+ getConfig() {
28
+ return this.conf;
29
+ }
30
+ setConfig(conf) {
31
+ this.conf = conf;
32
+ }
33
+ runParsed(file) {
34
+ var _a, _b;
35
+ const issues = [];
36
+ const statements = file.getStatements();
37
+ for (let i = 0; i < statements.length; i++) {
38
+ const colon = statements[i].getColon();
39
+ if (colon === undefined) {
40
+ continue;
41
+ }
42
+ const next = (_a = statements[i + 1]) === null || _a === void 0 ? void 0 : _a.getColon();
43
+ const prev = (_b = statements[i - 1]) === null || _b === void 0 ? void 0 : _b.getColon();
44
+ if (next !== undefined && colon.getStart().equals(next.getStart())) {
45
+ continue;
46
+ }
47
+ else if (prev !== undefined && colon.getStart().equals(prev.getStart())) {
48
+ continue;
49
+ }
50
+ const message = "Unnecessary chaining";
51
+ const issue = issue_1.Issue.atStatement(file, statements[i], message, this.getMetadata().key);
52
+ issues.push(issue);
53
+ }
54
+ return issues;
55
+ }
56
+ }
57
+ exports.UnnecessaryChaining = UnnecessaryChaining;
58
+ //# sourceMappingURL=unnecessary_chaining.js.map
@@ -67,6 +67,10 @@ class UnreachableCode extends _abap_rule_1.ABAPRule {
67
67
  return true;
68
68
  }
69
69
  else if (s instanceof Statements.Leave && n.findFirstExpression(Expressions.AndReturn) === undefined) {
70
+ const concat = n.concatTokens();
71
+ if (concat.includes(" TO LIST-PROCESSING")) {
72
+ return false;
73
+ }
70
74
  return true;
71
75
  }
72
76
  else if (s instanceof Statements.Return
@@ -55,15 +55,15 @@ class UnusedMethods {
55
55
  key: "unused_methods",
56
56
  title: "Unused methods",
57
57
  shortDescription: `Checks for unused methods`,
58
- extendedInformation: `Checks private and protected methods.
59
-
60
- Skips:
61
- * methods FOR TESTING
62
- * methods SETUP + TEARDOWN + CLASS_SETUP + CLASS_TEARDOWN in testclasses
63
- * class_constructor + constructor methods
64
- * event handlers
65
- * methods that are redefined
66
- * INCLUDEs
58
+ extendedInformation: `Checks private and protected methods.
59
+
60
+ Skips:
61
+ * methods FOR TESTING
62
+ * methods SETUP + TEARDOWN + CLASS_SETUP + CLASS_TEARDOWN in testclasses
63
+ * class_constructor + constructor methods
64
+ * event handlers
65
+ * methods that are redefined
66
+ * INCLUDEs
67
67
  `,
68
68
  tags: [],
69
69
  pragma: "##CALLED",
@@ -64,12 +64,12 @@ class UnusedVariables {
64
64
  key: "unused_variables",
65
65
  title: "Unused variables",
66
66
  shortDescription: `Checks for unused variables and constants`,
67
- extendedInformation: `WARNING: slow
68
-
69
- Experimental, might give false positives. Skips event parameters.
70
-
71
- Note that this currently does not work if the source code uses macros.
72
-
67
+ extendedInformation: `WARNING: slow
68
+
69
+ Experimental, might give false positives. Skips event parameters.
70
+
71
+ Note that this currently does not work if the source code uses macros.
72
+
73
73
  Unused variables are not reported if the object contains syntax errors. Errors found in INCLUDES are reported for the main program.`,
74
74
  tags: [_irule_1.RuleTag.Quickfix],
75
75
  pragma: "##NEEDED",