@abaplint/core 2.87.0 → 2.88.2

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 (80) hide show
  1. package/README.md +6 -6
  2. package/build/src/abap/flow/flow_graph.js +7 -7
  3. package/build/src/lsp/help.js +7 -7
  4. package/build/src/registry.js +1 -1
  5. package/build/src/rules/7bit_ascii.js +2 -2
  6. package/build/src/rules/abapdoc.js +1 -1
  7. package/build/src/rules/align_parameters.js +33 -33
  8. package/build/src/rules/ambiguous_statement.js +5 -5
  9. package/build/src/rules/avoid_use.js +8 -8
  10. package/build/src/rules/begin_end_names.js +4 -4
  11. package/build/src/rules/begin_single_include.js +12 -12
  12. package/build/src/rules/call_transaction_authority_check.js +3 -3
  13. package/build/src/rules/chain_mainly_declarations.js +4 -4
  14. package/build/src/rules/check_abstract.js +2 -2
  15. package/build/src/rules/check_comments.js +4 -4
  16. package/build/src/rules/check_include.js +3 -3
  17. package/build/src/rules/check_subrc.js +8 -8
  18. package/build/src/rules/commented_code.js +1 -1
  19. package/build/src/rules/constructor_visibility_public.js +4 -4
  20. package/build/src/rules/contains_tab.js +2 -2
  21. package/build/src/rules/dangerous_statement.js +1 -1
  22. package/build/src/rules/downport.js +63 -56
  23. package/build/src/rules/exit_or_check.js +3 -3
  24. package/build/src/rules/exporting.js +1 -1
  25. package/build/src/rules/forbidden_identifier.js +1 -1
  26. package/build/src/rules/forbidden_void_type.js +2 -2
  27. package/build/src/rules/functional_writing.js +17 -17
  28. package/build/src/rules/global_class.js +9 -10
  29. package/build/src/rules/identical_conditions.js +2 -2
  30. package/build/src/rules/identical_contents.js +14 -14
  31. package/build/src/rules/identical_descriptions.js +4 -4
  32. package/build/src/rules/if_in_if.js +7 -7
  33. package/build/src/rules/implement_methods.js +3 -3
  34. package/build/src/rules/in_statement_indentation.js +11 -11
  35. package/build/src/rules/index.js +2 -2
  36. package/build/src/rules/intf_referencing_clas.js +3 -3
  37. package/build/src/rules/line_break_style.js +2 -2
  38. package/build/src/rules/line_length.js +1 -1
  39. package/build/src/rules/line_only_punc.js +1 -1
  40. package/build/src/rules/local_variable_names.js +2 -2
  41. package/build/src/rules/many_parentheses.js +10 -10
  42. package/build/src/rules/max_one_method_parameter_per_line.js +7 -7
  43. package/build/src/rules/max_one_statement.js +3 -3
  44. package/build/src/rules/method_overwrites_builtin.js +2 -2
  45. package/build/src/rules/nesting.js +1 -1
  46. package/build/src/rules/no_chained_assignment.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/nrob_consistency.js +2 -2
  50. package/build/src/rules/obsolete_statement.js +40 -40
  51. package/build/src/rules/omit_parameter_name.js +3 -3
  52. package/build/src/rules/omit_receiving.js +13 -13
  53. package/build/src/rules/parser_702_chaining.js +2 -2
  54. package/build/src/rules/parser_error.js +2 -2
  55. package/build/src/rules/parser_missing_space.js +1 -1
  56. package/build/src/rules/{pragma_placement.js → pragma_style.js} +28 -10
  57. package/build/src/rules/prefer_inline.js +16 -16
  58. package/build/src/rules/prefer_is_not.js +7 -7
  59. package/build/src/rules/prefer_raise_exception_new.js +3 -3
  60. package/build/src/rules/prefer_returning_to_exporting.js +1 -1
  61. package/build/src/rules/prefer_xsdbool.js +2 -2
  62. package/build/src/rules/remove_descriptions.js +4 -4
  63. package/build/src/rules/rfc_error_handling.js +9 -9
  64. package/build/src/rules/select_add_order_by.js +5 -5
  65. package/build/src/rules/select_performance.js +2 -2
  66. package/build/src/rules/sicf_consistency.js +4 -4
  67. package/build/src/rules/slow_parameter_passing.js +1 -1
  68. package/build/src/rules/space_before_dot.js +2 -2
  69. package/build/src/rules/start_at_tab.js +1 -1
  70. package/build/src/rules/sy_modification.js +2 -2
  71. package/build/src/rules/tabl_enhancement_category.js +2 -2
  72. package/build/src/rules/unnecessary_pragma.js +126 -0
  73. package/build/src/rules/unused_methods.js +9 -9
  74. package/build/src/rules/unused_variables.js +6 -6
  75. package/build/src/rules/use_bool_expression.js +8 -8
  76. package/build/src/rules/use_line_exists.js +6 -6
  77. package/build/src/rules/use_new.js +4 -4
  78. package/build/src/rules/when_others_last.js +6 -6
  79. package/package.json +66 -66
  80. package/build/src/rules/check_no_handler_pragma.js +0 -81
@@ -1,23 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PragmaPlacement = exports.PragmaPlacementConf = void 0;
3
+ exports.PragmaStyle = exports.PragmaStyleConf = void 0;
4
4
  const issue_1 = require("../issue");
5
5
  const _abap_rule_1 = require("./_abap_rule");
6
6
  const _basic_rule_config_1 = require("./_basic_rule_config");
7
7
  const _irule_1 = require("./_irule");
8
- class PragmaPlacementConf extends _basic_rule_config_1.BasicRuleConfig {
8
+ const keyword_case_1 = require("./keyword_case");
9
+ class PragmaStyleConf extends _basic_rule_config_1.BasicRuleConfig {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.style = keyword_case_1.KeywordCaseStyle.Upper;
13
+ }
9
14
  }
10
- exports.PragmaPlacementConf = PragmaPlacementConf;
11
- class PragmaPlacement extends _abap_rule_1.ABAPRule {
15
+ exports.PragmaStyleConf = PragmaStyleConf;
16
+ class PragmaStyle extends _abap_rule_1.ABAPRule {
12
17
  constructor() {
13
18
  super(...arguments);
14
- this.conf = new PragmaPlacementConf();
19
+ this.conf = new PragmaStyleConf();
15
20
  }
16
21
  getMetadata() {
17
22
  return {
18
- key: "pragma_placement",
19
- title: "Pragma Placement",
20
- shortDescription: `Place pragmas at end of statements`,
23
+ key: "pragma_style",
24
+ title: "Pragma Style",
25
+ shortDescription: `Check pragmas placment and case`,
21
26
  tags: [_irule_1.RuleTag.SingleFile],
22
27
  extendedInformation: `https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/abenpragma.htm`,
23
28
  badExample: `DATA field ##NO_TEXT TYPE i.`,
@@ -29,6 +34,9 @@ class PragmaPlacement extends _abap_rule_1.ABAPRule {
29
34
  }
30
35
  setConfig(conf) {
31
36
  this.conf = conf;
37
+ if (this.conf.style === undefined) {
38
+ this.conf.style = keyword_case_1.KeywordCaseStyle.Upper;
39
+ }
32
40
  }
33
41
  runParsed(file) {
34
42
  const issues = [];
@@ -47,10 +55,20 @@ class PragmaPlacement extends _abap_rule_1.ABAPRule {
47
55
  issues.push(issue);
48
56
  continue; // max one finding per statement
49
57
  }
58
+ if (this.conf.style === keyword_case_1.KeywordCaseStyle.Upper && p.getStr() !== p.getStr().toUpperCase()) {
59
+ const message = "Upper case pragmas";
60
+ const issue = issue_1.Issue.atToken(file, p, message, this.getMetadata().key, this.conf.severity);
61
+ issues.push(issue);
62
+ }
63
+ else if (this.conf.style === keyword_case_1.KeywordCaseStyle.Lower && p.getStr() !== p.getStr().toLowerCase()) {
64
+ const message = "Lower case pragmas";
65
+ const issue = issue_1.Issue.atToken(file, p, message, this.getMetadata().key, this.conf.severity);
66
+ issues.push(issue);
67
+ }
50
68
  }
51
69
  }
52
70
  return issues;
53
71
  }
54
72
  }
55
- exports.PragmaPlacement = PragmaPlacement;
56
- //# sourceMappingURL=pragma_placement.js.map
73
+ exports.PragmaStyle = PragmaStyle;
74
+ //# sourceMappingURL=pragma_style.js.map
@@ -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
  }
@@ -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
  }
@@ -49,7 +49,7 @@ class SlowParameterPassing {
49
49
  }
50
50
  const writes = this.listWritePositions(m, id);
51
51
  if (writes.length === 0) {
52
- const message = "Parameter passed by VALUE but not changed";
52
+ const message = "Parameter " + id.getName() + " passed by VALUE but not changed";
53
53
  issues.push(issue_1.Issue.atIdentifier(id, message, this.getMetadata().key, this.getConfig().severity));
54
54
  }
55
55
  }
@@ -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,126 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnnecessaryPragma = exports.UnnecessaryPragmaConf = void 0;
4
+ const issue_1 = require("../issue");
5
+ const Statements = require("../abap/2_statements/statements");
6
+ const Expressions = require("../abap/2_statements/expressions");
7
+ const _abap_rule_1 = require("./_abap_rule");
8
+ const _basic_rule_config_1 = require("./_basic_rule_config");
9
+ const _statement_1 = require("../abap/2_statements/statements/_statement");
10
+ const _irule_1 = require("./_irule");
11
+ class UnnecessaryPragmaConf extends _basic_rule_config_1.BasicRuleConfig {
12
+ }
13
+ exports.UnnecessaryPragmaConf = UnnecessaryPragmaConf;
14
+ class UnnecessaryPragma extends _abap_rule_1.ABAPRule {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.conf = new UnnecessaryPragmaConf();
18
+ }
19
+ getMetadata() {
20
+ return {
21
+ key: "unnecessary_pragma",
22
+ title: "Unnecessary Pragma",
23
+ shortDescription: `Finds pragmas which can be removed`,
24
+ extendedInformation: `* NO_HANDLER with handler
25
+
26
+ * NEEDED without definition
27
+
28
+ * NO_TEXT without texts`,
29
+ tags: [_irule_1.RuleTag.SingleFile],
30
+ badExample: `TRY.
31
+ ...
32
+ CATCH zcx_abapgit_exception ##NO_HANDLER.
33
+ RETURN. " it has a handler
34
+ ENDTRY.
35
+ MESSAGE w125(zbar) WITH c_foo INTO message ##NEEDED ##NO_TEXT.`,
36
+ goodExample: `TRY.
37
+ ...
38
+ CATCH zcx_abapgit_exception.
39
+ RETURN.
40
+ ENDTRY.
41
+ MESSAGE w125(zbar) WITH c_foo INTO message.`,
42
+ };
43
+ }
44
+ getConfig() {
45
+ return this.conf;
46
+ }
47
+ setConfig(conf) {
48
+ this.conf = conf;
49
+ }
50
+ runParsed(file) {
51
+ const issues = [];
52
+ let noHandler = false;
53
+ const statements = file.getStatements();
54
+ for (let i = 0; i < statements.length; i++) {
55
+ const statement = statements[i];
56
+ if (statement.get() instanceof Statements.EndTry) {
57
+ noHandler = false;
58
+ }
59
+ else if (statement.get() instanceof _statement_1.Comment) {
60
+ continue;
61
+ }
62
+ else if (noHandler === true && !(statement.get() instanceof Statements.Catch)) {
63
+ const message = "NO_HANDLER pragma or pseudo comment can be removed";
64
+ const issue = issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity);
65
+ issues.push(issue);
66
+ noHandler = false;
67
+ }
68
+ else {
69
+ noHandler = this.containsNoHandler(statement, statements[i + 1]);
70
+ }
71
+ issues.push(...this.checkText(statement, file));
72
+ issues.push(...this.checkNeeded(statement, file));
73
+ }
74
+ return issues;
75
+ }
76
+ checkText(statement, file) {
77
+ const p = statement.getPragmas().find(t => t.getStr().toUpperCase() === "##NO_TEXT");
78
+ if (p === undefined) {
79
+ return [];
80
+ }
81
+ if (statement.findFirstExpression(Expressions.ConstantString) === undefined
82
+ && statement.findFirstExpression(Expressions.StringTemplate) === undefined) {
83
+ const message = "There is no text, NO_TEXT can be removed";
84
+ return [issue_1.Issue.atToken(file, p, message, this.getMetadata().key, this.getConfig().severity)];
85
+ }
86
+ return [];
87
+ }
88
+ checkNeeded(statement, file) {
89
+ const p = statement.getPragmas().find(t => t.getStr().toUpperCase() === "##NEEDED");
90
+ if (p === undefined) {
91
+ return [];
92
+ }
93
+ if (statement.findFirstExpression(Expressions.InlineData) === undefined
94
+ && !(statement.get() instanceof Statements.Parameter)
95
+ && !(statement.get() instanceof Statements.Data)
96
+ && !(statement.get() instanceof Statements.DataEnd)
97
+ && !(statement.get() instanceof Statements.Type)
98
+ && !(statement.get() instanceof Statements.TypeEnd)
99
+ && !(statement.get() instanceof Statements.Constant)
100
+ && !(statement.get() instanceof Statements.ConstantEnd)
101
+ && !(statement.get() instanceof Statements.TypeEnum)
102
+ && !(statement.get() instanceof Statements.TypeEnumEnd)
103
+ && !(statement.get() instanceof Statements.MethodImplementation)
104
+ && !(statement.get() instanceof Statements.MethodDef)
105
+ && statement.findFirstExpression(Expressions.InlineFS) === undefined) {
106
+ const message = "There is no data definition, NEEDED can be removed";
107
+ return [issue_1.Issue.atToken(file, p, message, this.getMetadata().key, this.getConfig().severity)];
108
+ }
109
+ return [];
110
+ }
111
+ containsNoHandler(statement, next) {
112
+ for (const t of statement.getPragmas()) {
113
+ if (t.getStr().toUpperCase() === "##NO_HANDLER") {
114
+ return true;
115
+ }
116
+ }
117
+ if (next
118
+ && next.get() instanceof _statement_1.Comment
119
+ && next.concatTokens().toUpperCase().includes("#EC NO_HANDLER")) {
120
+ return true;
121
+ }
122
+ return false;
123
+ }
124
+ }
125
+ exports.UnnecessaryPragma = UnnecessaryPragma;
126
+ //# sourceMappingURL=unnecessary_pragma.js.map
@@ -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
- 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
+ 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",
@@ -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,10 +23,10 @@ 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
-
28
- If the target variable is referenced in the CREATE OBJECT statement, no errors are issued
29
-
26
+ extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-new-to-create-object
27
+
28
+ If the target variable is referenced in the CREATE OBJECT statement, no errors are issued
29
+
30
30
  Applicable from v740sp02 and up`,
31
31
  badExample: `CREATE OBJECT ref.`,
32
32
  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
  }