@abaplint/core 2.80.7 → 2.80.8

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 (76) hide show
  1. package/README.md +6 -6
  2. package/build/src/abap/5_syntax/statements/get_cursor.js +14 -0
  3. package/build/src/abap/5_syntax/syntax.js +2 -0
  4. package/build/src/abap/flow/flow_graph.js +7 -7
  5. package/build/src/lsp/help.js +7 -7
  6. package/build/src/lsp/references.js +6 -5
  7. package/build/src/registry.js +1 -1
  8. package/build/src/rules/abapdoc.js +1 -1
  9. package/build/src/rules/align_parameters.js +33 -33
  10. package/build/src/rules/ambiguous_statement.js +5 -5
  11. package/build/src/rules/avoid_use.js +6 -6
  12. package/build/src/rules/begin_end_names.js +4 -4
  13. package/build/src/rules/begin_single_include.js +12 -12
  14. package/build/src/rules/call_transaction_authority_check.js +3 -3
  15. package/build/src/rules/chain_mainly_declarations.js +4 -4
  16. package/build/src/rules/check_abstract.js +2 -2
  17. package/build/src/rules/check_comments.js +3 -3
  18. package/build/src/rules/check_include.js +3 -3
  19. package/build/src/rules/check_no_handler_pragma.js +8 -8
  20. package/build/src/rules/check_subrc.js +8 -8
  21. package/build/src/rules/commented_code.js +1 -1
  22. package/build/src/rules/constructor_visibility_public.js +4 -4
  23. package/build/src/rules/contains_tab.js +2 -2
  24. package/build/src/rules/dangerous_statement.js +1 -1
  25. package/build/src/rules/downport.js +35 -35
  26. package/build/src/rules/exit_or_check.js +3 -3
  27. package/build/src/rules/exporting.js +1 -1
  28. package/build/src/rules/forbidden_identifier.js +1 -1
  29. package/build/src/rules/forbidden_void_type.js +2 -2
  30. package/build/src/rules/functional_writing.js +17 -17
  31. package/build/src/rules/global_class.js +10 -10
  32. package/build/src/rules/identical_conditions.js +2 -2
  33. package/build/src/rules/identical_contents.js +15 -15
  34. package/build/src/rules/identical_descriptions.js +4 -4
  35. package/build/src/rules/if_in_if.js +7 -7
  36. package/build/src/rules/implement_methods.js +3 -3
  37. package/build/src/rules/in_statement_indentation.js +11 -11
  38. package/build/src/rules/intf_referencing_clas.js +3 -3
  39. package/build/src/rules/line_break_style.js +2 -2
  40. package/build/src/rules/line_length.js +1 -1
  41. package/build/src/rules/line_only_punc.js +1 -1
  42. package/build/src/rules/local_variable_names.js +2 -2
  43. package/build/src/rules/many_parentheses.js +10 -10
  44. package/build/src/rules/max_one_method_parameter_per_line.js +7 -7
  45. package/build/src/rules/max_one_statement.js +3 -3
  46. package/build/src/rules/nesting.js +1 -1
  47. package/build/src/rules/no_public_attributes.js +1 -1
  48. package/build/src/rules/no_yoda_conditions.js +4 -4
  49. package/build/src/rules/obsolete_statement.js +36 -36
  50. package/build/src/rules/omit_parameter_name.js +3 -3
  51. package/build/src/rules/omit_receiving.js +13 -13
  52. package/build/src/rules/parser_702_chaining.js +2 -2
  53. package/build/src/rules/parser_error.js +2 -2
  54. package/build/src/rules/parser_missing_space.js +1 -1
  55. package/build/src/rules/prefer_inline.js +16 -16
  56. package/build/src/rules/prefer_is_not.js +7 -7
  57. package/build/src/rules/prefer_raise_exception_new.js +3 -3
  58. package/build/src/rules/prefer_returning_to_exporting.js +1 -1
  59. package/build/src/rules/prefer_xsdbool.js +2 -2
  60. package/build/src/rules/remove_descriptions.js +4 -4
  61. package/build/src/rules/rfc_error_handling.js +9 -9
  62. package/build/src/rules/select_add_order_by.js +5 -5
  63. package/build/src/rules/select_performance.js +2 -2
  64. package/build/src/rules/sicf_consistency.js +4 -4
  65. package/build/src/rules/space_before_dot.js +2 -2
  66. package/build/src/rules/start_at_tab.js +1 -1
  67. package/build/src/rules/sy_modification.js +2 -2
  68. package/build/src/rules/tabl_enhancement_category.js +2 -2
  69. package/build/src/rules/unused_methods.js +9 -9
  70. package/build/src/rules/unused_types.js +23 -18
  71. package/build/src/rules/unused_variables.js +111 -64
  72. package/build/src/rules/use_bool_expression.js +8 -8
  73. package/build/src/rules/use_line_exists.js +6 -6
  74. package/build/src/rules/use_new.js +2 -2
  75. package/build/src/rules/when_others_last.js +6 -6
  76. package/package.json +65 -76
@@ -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
  };
@@ -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",
@@ -36,23 +36,25 @@ class WorkArea {
36
36
  return this.workarea.length;
37
37
  }
38
38
  }
39
- function removeDuplicates(list) {
40
- const deduplicated = [];
41
- for (const result of list) {
42
- let cont = false;
43
- for (const d of deduplicated) {
44
- if (result.getStart().equals(d.getStart())) {
45
- cont = true;
46
- break;
47
- }
48
- }
49
- if (cont === true) {
50
- continue;
51
- }
52
- deduplicated.push(result);
53
- }
54
- return deduplicated;
39
+ /*
40
+ function removeDuplicates(list: readonly TypedIdentifier[]): readonly TypedIdentifier[] {
41
+ const deduplicated: TypedIdentifier[] = [];
42
+ for (const result of list) {
43
+ let cont = false;
44
+ for (const d of deduplicated) {
45
+ if (result.getStart().equals(d.getStart())) {
46
+ cont = true;
47
+ break;
48
+ }
49
+ }
50
+ if (cont === true) {
51
+ continue;
52
+ }
53
+ deduplicated.push(result);
54
+ }
55
+ return deduplicated;
55
56
  }
57
+ */
56
58
  class UnusedTypesConf extends _basic_rule_config_1.BasicRuleConfig {
57
59
  constructor() {
58
60
  super(...arguments);
@@ -103,7 +105,10 @@ class UnusedTypes {
103
105
  return []; // exit early if all types are used in the current object
104
106
  }
105
107
  for (const o of this.reg.getObjects()) {
106
- if (o instanceof _abap_object_1.ABAPObject) {
108
+ if (o === obj) {
109
+ continue;
110
+ }
111
+ else if (o instanceof _abap_object_1.ABAPObject) {
107
112
  if (this.reg.isDependency(o)) {
108
113
  continue; // do not search in dependencies
109
114
  }
@@ -116,7 +121,7 @@ class UnusedTypes {
116
121
  }
117
122
  // what is left is unused
118
123
  const ret = [];
119
- for (const t of removeDuplicates(this.workarea.get())) {
124
+ for (const t of this.workarea.get()) {
120
125
  const message = "Type \"" + t.getName() + "\" not used";
121
126
  const file = obj.getABAPFileByName(t.getFilename());
122
127
  if (file === undefined) {
@@ -8,10 +8,10 @@ const syntax_1 = require("../abap/5_syntax/syntax");
8
8
  const _abap_object_1 = require("../objects/_abap_object");
9
9
  const _scope_type_1 = require("../abap/5_syntax/_scope_type");
10
10
  const objects_1 = require("../objects");
11
- const references_1 = require("../lsp/references");
12
11
  const edit_helper_1 = require("../edit_helper");
13
12
  const Statements = require("../abap/2_statements/statements");
14
13
  const _statement_1 = require("../abap/2_statements/statements/_statement");
14
+ const _reference_1 = require("../abap/5_syntax/_reference");
15
15
  class UnusedVariablesConf extends _basic_rule_config_1.BasicRuleConfig {
16
16
  constructor() {
17
17
  super(...arguments);
@@ -22,6 +22,39 @@ class UnusedVariablesConf extends _basic_rule_config_1.BasicRuleConfig {
22
22
  }
23
23
  }
24
24
  exports.UnusedVariablesConf = UnusedVariablesConf;
25
+ class WorkArea {
26
+ constructor() {
27
+ this.workarea = [];
28
+ }
29
+ push(id, count = 1) {
30
+ for (const w of this.workarea) {
31
+ if (id.equals(w.id)) {
32
+ return;
33
+ }
34
+ }
35
+ this.workarea.push({ id, count });
36
+ }
37
+ removeIfExists(id) {
38
+ if (id === undefined) {
39
+ return;
40
+ }
41
+ for (let i = 0; i < this.workarea.length; i++) {
42
+ if (id.equals(this.workarea[i].id)) {
43
+ this.workarea[i].count--;
44
+ if (this.workarea[i].count === 0) {
45
+ this.workarea.splice(i, 1);
46
+ }
47
+ return;
48
+ }
49
+ }
50
+ }
51
+ get() {
52
+ return this.workarea;
53
+ }
54
+ count() {
55
+ return this.workarea.length;
56
+ }
57
+ }
25
58
  class UnusedVariables {
26
59
  constructor() {
27
60
  this.conf = new UnusedVariablesConf();
@@ -31,13 +64,13 @@ class UnusedVariables {
31
64
  key: "unused_variables",
32
65
  title: "Unused variables",
33
66
  shortDescription: `Checks for unused variables and constants`,
34
- extendedInformation: `WARNING: slow
35
-
36
- Experimental, might give false positives. Skips event parameters.
37
-
38
- Note that this currently does not work if the source code uses macros.
39
-
40
- Unused variables are not reported if the object contains syntax errors.`,
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
+ Unused variables are not reported if the object contains syntax errors. Errors found in INCLUDES are reported for the main program.`,
41
74
  tags: [_irule_1.RuleTag.Quickfix],
42
75
  pragma: "##NEEDED",
43
76
  pseudoComment: "EC NEEDED",
@@ -68,67 +101,91 @@ class UnusedVariables {
68
101
  if (syntax.issues.length > 0) {
69
102
  return [];
70
103
  }
71
- const results = this.traverse(syntax.spaghetti.getTop(), obj);
72
- // remove duplicates, quick and dirty
73
- const deduplicated = [];
74
- for (const result of results) {
75
- let cont = false;
76
- for (const d of deduplicated) {
77
- if (result.getStart().equals(d.getStart())) {
78
- cont = true;
79
- break;
80
- }
81
- }
82
- if (cont === true) {
104
+ this.workarea = new WorkArea();
105
+ const top = syntax.spaghetti.getTop();
106
+ this.buildWorkarea(top, obj);
107
+ if (this.workarea.count() === 0) {
108
+ return this.buildIssues(obj); // exit early if all types are used
109
+ }
110
+ this.findUses(top, obj);
111
+ for (const o of this.reg.getObjects()) {
112
+ if (o === obj) {
83
113
  continue;
84
114
  }
85
- deduplicated.push(result);
115
+ else if (o instanceof _abap_object_1.ABAPObject) {
116
+ if (this.reg.isDependency(o)) {
117
+ continue; // do not search in dependencies
118
+ }
119
+ const syntax = new syntax_1.SyntaxLogic(this.reg, o).run();
120
+ this.findUses(syntax.spaghetti.getTop(), o);
121
+ if (this.workarea.count() === 0) {
122
+ return this.buildIssues(obj); // exit early if all types are used
123
+ }
124
+ }
86
125
  }
87
- return deduplicated;
126
+ return this.buildIssues(obj);
88
127
  }
89
- traverse(node, obj) {
90
- const ret = [];
91
- if (node.getIdentifier().stype === _scope_type_1.ScopeType.OpenSQL) {
92
- return [];
93
- }
94
- if (node.getIdentifier().stype !== _scope_type_1.ScopeType.BuiltIn) {
95
- ret.push(...this.checkNode(node, obj));
128
+ findUses(node, obj) {
129
+ for (const r of node.getData().references) {
130
+ if (r.referenceType === _reference_1.ReferenceType.DataReadReference
131
+ || r.referenceType === _reference_1.ReferenceType.DataWriteReference
132
+ || r.referenceType === _reference_1.ReferenceType.TypeReference) {
133
+ this.workarea.removeIfExists(r.resolved);
134
+ }
96
135
  }
97
136
  for (const c of node.getChildren()) {
98
- ret.push(...this.traverse(c, obj));
137
+ this.findUses(c, obj);
99
138
  }
100
- return ret;
101
139
  }
102
- checkNode(node, obj) {
140
+ buildWorkarea(node, obj) {
103
141
  var _a;
142
+ const stype = node.getIdentifier().stype;
143
+ if (stype === _scope_type_1.ScopeType.OpenSQL) {
144
+ return;
145
+ }
146
+ for (const c of node.getChildren()) {
147
+ this.buildWorkarea(c, obj);
148
+ }
149
+ if (stype !== _scope_type_1.ScopeType.BuiltIn) {
150
+ const vars = node.getData().vars;
151
+ for (const name in vars) {
152
+ const meta = vars[name].getMeta();
153
+ if (((_a = this.conf.skipNames) === null || _a === void 0 ? void 0 : _a.length) > 0
154
+ && this.conf.skipNames.some((a) => a.toUpperCase() === name)) {
155
+ continue;
156
+ }
157
+ else if (name === "ME"
158
+ || name === "SUPER"
159
+ || meta.includes("event_parameter" /* EventParameter */)) {
160
+ // todo, workaround for "me" and "super", these should somehow be typed to built-in
161
+ continue;
162
+ }
163
+ const isInline = meta.includes("inline" /* InlineDefinition */);
164
+ this.workarea.push(vars[name], isInline ? 2 : 1);
165
+ }
166
+ }
167
+ }
168
+ buildIssues(obj) {
104
169
  const ret = [];
105
- const vars = node.getData().vars;
106
- for (const name in vars) {
107
- if (((_a = this.conf.skipNames) === null || _a === void 0 ? void 0 : _a.length) > 0
108
- && this.conf.skipNames.some((a) => a.toUpperCase() === name)) {
170
+ for (const w of this.workarea.get()) {
171
+ const filename = w.id.getFilename();
172
+ if (this.reg.isFileDependency(filename) === true) {
109
173
  continue;
110
174
  }
111
- if (name === "ME"
112
- || name === "SUPER"
113
- || vars[name].getMeta().includes("event_parameter" /* EventParameter */)) {
114
- // todo, workaround for "me" and "super", these should somehow be typed to built-in
175
+ else if (obj instanceof objects_1.Program === false && obj.containsFile(filename) === false) {
115
176
  continue;
116
177
  }
117
- else if ((obj.containsFile(vars[name].getFilename())
118
- || node.getIdentifier().stype === _scope_type_1.ScopeType.Program
119
- || node.getIdentifier().stype === _scope_type_1.ScopeType.Form)
120
- && this.isUsed(vars[name], node) === false) {
121
- const message = "Variable \"" + name.toLowerCase() + "\" not used";
122
- const statement = this.findStatement(vars[name]);
123
- if (statement === null || statement === void 0 ? void 0 : statement.getPragmas().map(t => t.getStr()).includes(this.getMetadata().pragma + "")) {
124
- continue;
125
- }
126
- else if (this.suppressedbyPseudo(statement, vars[name], obj)) {
127
- continue;
128
- }
129
- const fix = this.buildFix(vars[name], obj);
130
- ret.push(issue_1.Issue.atIdentifier(vars[name], message, this.getMetadata().key, this.conf.severity, fix));
178
+ const statement = this.findStatement(w.id);
179
+ if (statement === null || statement === void 0 ? void 0 : statement.getPragmas().map(t => t.getStr()).includes(this.getMetadata().pragma + "")) {
180
+ continue;
131
181
  }
182
+ else if (this.suppressedbyPseudo(statement, w.id, obj)) {
183
+ continue;
184
+ }
185
+ const name = w.id.getName();
186
+ const message = "Variable \"" + name.toLowerCase() + "\" not used";
187
+ const fix = this.buildFix(w.id, obj);
188
+ ret.push(issue_1.Issue.atIdentifier(w.id, message, this.getMetadata().key, this.conf.severity, fix));
132
189
  }
133
190
  return ret;
134
191
  }
@@ -151,16 +208,6 @@ class UnusedVariables {
151
208
  }
152
209
  return false;
153
210
  }
154
- isUsed(id, node) {
155
- const isInline = id.getMeta().includes("inline" /* InlineDefinition */);
156
- const found = new references_1.References(this.reg).search(id, node, true, isInline === false);
157
- if (isInline === true) {
158
- return found.length > 2; // inline definitions are always written to
159
- }
160
- else {
161
- return found.length > 1;
162
- }
163
- }
164
211
  findStatement(v) {
165
212
  const file = this.reg.getFileByName(v.getFilename());
166
213
  if (file === undefined) {
@@ -27,15 +27,15 @@ class UseBoolExpression extends _abap_rule_1.ABAPRule {
27
27
  shortDescription: `Use boolean expression, xsdbool from 740sp08 and up, boolc from 702 and up`,
28
28
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-xsdbool-to-set-boolean-variables`,
29
29
  tags: [_irule_1.RuleTag.Upport, _irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
30
- badExample: `IF line IS INITIAL.
31
- has_entries = abap_false.
32
- ELSE.
33
- has_entries = abap_true.
34
- ENDIF.
35
-
30
+ badExample: `IF line IS INITIAL.
31
+ has_entries = abap_false.
32
+ ELSE.
33
+ has_entries = abap_true.
34
+ ENDIF.
35
+
36
36
  DATA(fsdf) = COND #( WHEN foo <> bar THEN abap_true ELSE abap_false ).`,
37
- goodExample: `DATA(has_entries) = xsdbool( line IS NOT INITIAL ).
38
-
37
+ goodExample: `DATA(has_entries) = xsdbool( line IS NOT INITIAL ).
38
+
39
39
  DATA(fsdf) = xsdbool( foo <> bar ).`,
40
40
  };
41
41
  }
@@ -22,15 +22,15 @@ class UseLineExists extends _abap_rule_1.ABAPRule {
22
22
  key: "use_line_exists",
23
23
  title: "Use line_exists",
24
24
  shortDescription: `Use line_exists, from 740sp02 and up`,
25
- extendedInformation: `
26
- https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-line_exists-to-read-table-or-loop-at
27
-
25
+ extendedInformation: `
26
+ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-line_exists-to-read-table-or-loop-at
27
+
28
28
  Not reported if the READ TABLE statement contains BINARY SEARCH.`,
29
29
  tags: [_irule_1.RuleTag.Upport, _irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
30
- badExample: `READ TABLE my_table TRANSPORTING NO FIELDS WITH KEY key = 'A'.
31
- IF sy-subrc = 0.
30
+ badExample: `READ TABLE my_table TRANSPORTING NO FIELDS WITH KEY key = 'A'.
31
+ IF sy-subrc = 0.
32
32
  ENDIF.`,
33
- goodExample: `IF line_exists( my_table[ key = 'A' ] ).
33
+ goodExample: `IF line_exists( my_table[ key = 'A' ] ).
34
34
  ENDIF.`,
35
35
  };
36
36
  }
@@ -23,8 +23,8 @@ class UseNew extends _abap_rule_1.ABAPRule {
23
23
  key: "use_new",
24
24
  title: "Use NEW",
25
25
  shortDescription: `Checks for deprecated CREATE OBJECT statements.`,
26
- extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-new-to-create-object
27
-
26
+ extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-new-to-create-object
27
+
28
28
  If the target variable is referenced in the CREATE OBJECT statement, no errors are issued`,
29
29
  badExample: `CREATE OBJECT ref.`,
30
30
  goodExample: `ref = NEW #( ).`,
@@ -21,13 +21,13 @@ class WhenOthersLast extends _abap_rule_1.ABAPRule {
21
21
  title: "WHEN OTHERS last",
22
22
  shortDescription: `Checks that WHEN OTHERS is placed the last within a CASE statement.`,
23
23
  tags: [_irule_1.RuleTag.SingleFile],
24
- badExample: `CASE bar.
25
- WHEN OTHERS.
26
- WHEN 2.
24
+ badExample: `CASE bar.
25
+ WHEN OTHERS.
26
+ WHEN 2.
27
27
  ENDCASE.`,
28
- goodExample: `CASE bar.
29
- WHEN 2.
30
- WHEN OTHERS.
28
+ goodExample: `CASE bar.
29
+ WHEN 2.
30
+ WHEN OTHERS.
31
31
  ENDCASE.`,
32
32
  };
33
33
  }