@abaplint/core 2.107.0 → 2.107.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.
@@ -65,7 +65,7 @@ class Registry {
65
65
  }
66
66
  static abaplintVersion() {
67
67
  // magic, see build script "version.sh"
68
- return "2.107.0";
68
+ return "2.107.2";
69
69
  }
70
70
  getDDICReferences() {
71
71
  return this.ddicReferences;
@@ -23,6 +23,8 @@ https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abencharacter_set_gui
23
23
 
24
24
  Checkes files with extensions ".abap" and ".asddls"`,
25
25
  tags: [_irule_1.RuleTag.SingleFile],
26
+ badExample: `WRITE '뽑'.`,
27
+ goodExample: `WRITE cl_abap_conv_in_ce=>uccp( 'BF51' ).`,
26
28
  };
27
29
  }
28
30
  initialize(_reg) {
@@ -1,17 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AlignTypeExpressions = exports.AlignTypeExpressionsConf = void 0;
4
- const issue_1 = require("../issue");
5
4
  const _abap_rule_1 = require("./_abap_rule");
6
5
  const _basic_rule_config_1 = require("./_basic_rule_config");
6
+ const objects_1 = require("../objects");
7
+ const ddic_1 = require("../ddic");
7
8
  const _irule_1 = require("./_irule");
8
- const Structures = require("../abap/3_structures/structures");
9
- const Statements = require("../abap/2_statements/statements");
9
+ const issue_1 = require("../issue");
10
+ const position_1 = require("../position");
10
11
  const Expressions = require("../abap/2_statements/expressions");
11
- /*
12
- import {EditHelper, IEdit} from "../edit_helper";
13
- */
12
+ const Statements = require("../abap/2_statements/statements");
13
+ const Structures = require("../abap/3_structures/structures");
14
+ const edit_helper_1 = require("../edit_helper");
14
15
  class AlignTypeExpressionsConf extends _basic_rule_config_1.BasicRuleConfig {
16
+ constructor() {
17
+ super(...arguments);
18
+ /** Ignore global exception classes */
19
+ this.ignoreExceptions = true;
20
+ }
15
21
  }
16
22
  exports.AlignTypeExpressionsConf = AlignTypeExpressionsConf;
17
23
  class AlignTypeExpressions extends _abap_rule_1.ABAPRule {
@@ -27,9 +33,11 @@ class AlignTypeExpressions extends _abap_rule_1.ABAPRule {
27
33
  extendedInformation: `
28
34
  Currently works for METHODS + BEGIN OF
29
35
 
36
+ If BEGIN OF has an INCLUDE TYPE its ignored
37
+
30
38
  Also note that clean ABAP does not recommend aligning TYPE clauses:
31
39
  https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#dont-align-type-clauses`,
32
- tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Whitespace],
40
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Quickfix],
33
41
  badExample: `
34
42
  TYPES: BEGIN OF foo,
35
43
  bar TYPE i,
@@ -62,16 +70,45 @@ ENDINTERFACE.`,
62
70
  setConfig(conf) {
63
71
  this.conf = conf;
64
72
  }
65
- runParsed(file) {
73
+ runParsed(file, obj) {
66
74
  const issues = [];
67
75
  const stru = file.getStructure();
68
76
  if (stru === undefined) {
69
77
  return issues; // parser error
70
78
  }
79
+ const ddic = new ddic_1.DDIC(this.reg);
80
+ if (obj instanceof objects_1.Class) {
81
+ const definition = obj.getClassDefinition();
82
+ if (definition === undefined) {
83
+ return [];
84
+ }
85
+ else if (this.conf.ignoreExceptions && ddic.isException(definition, obj)) {
86
+ return [];
87
+ }
88
+ }
71
89
  issues.push(...this.checkTypes(stru, file));
72
90
  issues.push(...this.checkMethods(stru, file));
73
91
  return issues;
74
92
  }
93
+ check(fields, column, file) {
94
+ const issues = [];
95
+ for (const f of fields) {
96
+ if (f.after.getCol() === column) {
97
+ continue;
98
+ }
99
+ let fix = undefined;
100
+ if (f.after.getCol() < column) {
101
+ fix = edit_helper_1.EditHelper.insertAt(file, f.after, " ".repeat(column - f.after.getCol()));
102
+ }
103
+ else {
104
+ fix = edit_helper_1.EditHelper.deleteRange(file, new position_1.Position(f.after.getRow(), column), f.after);
105
+ }
106
+ const message = `Align TYPE expressions to column ${column}`;
107
+ const issue = issue_1.Issue.atPosition(file, f.after, message, this.getMetadata().key, this.conf.severity, fix);
108
+ issues.push(issue);
109
+ }
110
+ return issues;
111
+ }
75
112
  checkMethods(stru, file) {
76
113
  const issues = [];
77
114
  const methods = stru.findAllStatements(Statements.MethodDef);
@@ -98,14 +135,7 @@ ENDINTERFACE.`,
98
135
  });
99
136
  column = Math.max(column, name.getLastToken().getEnd().getCol() + 1);
100
137
  }
101
- for (const f of fields) {
102
- if (f.after.getCol() !== column) {
103
- // const fix = this.buildFix(f.name, column);
104
- const message = `Align TYPE expressions to column ${column}`;
105
- const issue = issue_1.Issue.atPosition(file, f.after, message, this.getMetadata().key, this.conf.severity);
106
- issues.push(issue);
107
- }
108
- }
138
+ issues.push(...this.check(fields, column, file));
109
139
  }
110
140
  return issues;
111
141
  }
@@ -113,6 +143,9 @@ ENDINTERFACE.`,
113
143
  const issues = [];
114
144
  const types = stru.findAllStructuresRecursive(Structures.Types);
115
145
  for (const t of types) {
146
+ if (t.findDirectStatement(Statements.IncludeType)) {
147
+ continue;
148
+ }
116
149
  const fields = [];
117
150
  let column = 0;
118
151
  const st = t.findDirectStatements(Statements.Type);
@@ -124,14 +157,7 @@ ENDINTERFACE.`,
124
157
  });
125
158
  column = Math.max(column, name.getFirstToken().getEnd().getCol() + 1);
126
159
  }
127
- for (const f of fields) {
128
- if (f.after.getCol() !== column) {
129
- // const fix = this.buildFix(f.name, column);
130
- const message = `Align TYPE expressions to column ${column}`;
131
- const issue = issue_1.Issue.atPosition(file, f.after, message, this.getMetadata().key, this.conf.severity);
132
- issues.push(issue);
133
- }
134
- }
160
+ issues.push(...this.check(fields, column, file));
135
161
  }
136
162
  return issues;
137
163
  }
@@ -33,7 +33,8 @@ STATICS BEGIN OF bar.
33
33
  INCLUDE STRUCTURE syst.
34
34
  STATICS END OF bar.`,
35
35
  goodExample: `DATA BEGIN OF foo.
36
- INCLUDE STRUCTURE dselc.
36
+ DATA field TYPE i.
37
+ INCLUDE STRUCTURE dselc.
37
38
  DATA END OF foo.`,
38
39
  };
39
40
  }
@@ -33,6 +33,7 @@ class CommentedCode extends _abap_rule_1.ABAPRule {
33
33
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#delete-code-instead-of-commenting-it
34
34
  https://docs.abapopenchecks.org/checks/14/`,
35
35
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
36
+ badExample: `* WRITE 'hello world'.`,
36
37
  };
37
38
  }
38
39
  getMessage() {
@@ -29,6 +29,8 @@ class ContainsTab extends _abap_rule_1.ABAPRule {
29
29
  https://docs.abapopenchecks.org/checks/09/
30
30
  https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#indent-and-snap-to-tab`,
31
31
  tags: [_irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
32
+ badExample: `\tWRITE 'hello world'.`,
33
+ goodExample: ` WRITE 'hello world'.`,
32
34
  };
33
35
  }
34
36
  getMessage() {
@@ -22,6 +22,8 @@ class EmptyStatement extends _abap_rule_1.ABAPRule {
22
22
  title: "Remove empty statement",
23
23
  shortDescription: `Checks for empty statements (an empty statement is a single dot)`,
24
24
  tags: [_irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
25
+ badExample: `WRITE 'hello world'..`,
26
+ goodExample: `WRITE 'hello world'.`,
25
27
  };
26
28
  }
27
29
  getConfig() {
@@ -39,6 +39,24 @@ class Indentation extends _abap_rule_1.ABAPRule {
39
39
  title: "Indentation",
40
40
  shortDescription: `Checks indentation`,
41
41
  tags: [_irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
42
+ badExample: `CLASS lcl DEFINITION.
43
+ PRIVATE SECTION.
44
+ METHODS constructor.
45
+ ENDCLASS.
46
+
47
+ CLASS lcl IMPLEMENTATION.
48
+ METHOD constructor.
49
+ ENDMETHOD.
50
+ ENDCLASS.`,
51
+ goodExample: `CLASS lcl DEFINITION.
52
+ PRIVATE SECTION.
53
+ METHODS constructor.
54
+ ENDCLASS.
55
+
56
+ CLASS lcl IMPLEMENTATION.
57
+ METHOD constructor.
58
+ ENDMETHOD.
59
+ ENDCLASS.`,
42
60
  };
43
61
  }
44
62
  getConfig() {
@@ -113,6 +113,8 @@ class KeywordCase extends _abap_rule_1.ABAPRule {
113
113
  shortDescription: `Checks that keywords have the same case. Non-keywords must be lower case.`,
114
114
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-your-pretty-printer-team-settings`,
115
115
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
116
+ badExample: `write 'hello world'.`,
117
+ goodExample: `WRITE 'hello world'.`,
116
118
  };
117
119
  }
118
120
  getConfig() {
@@ -34,6 +34,12 @@ class LocalVariableNames extends _abap_rule_1.ABAPRule {
34
34
  Allows you to enforce a pattern, such as a prefix, for local variables, constants and field symbols.
35
35
  Regexes are case-insensitive.`,
36
36
  tags: [_irule_1.RuleTag.Naming, _irule_1.RuleTag.SingleFile],
37
+ badExample: `FORM bar.
38
+ DATA foo.
39
+ ENDFORM.`,
40
+ goodExample: `FORM bar.
41
+ DATA lv_foo.
42
+ ENDFORM.`,
37
43
  };
38
44
  }
39
45
  getDescription(expected, actual) {
@@ -25,6 +25,15 @@ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-obscu
25
25
 
26
26
  Interface method names are ignored`,
27
27
  tags: [_irule_1.RuleTag.Naming, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide],
28
+ badExample: `CLASS lcl DEFINITION.
29
+ PUBLIC SECTION.
30
+ METHODS matches.
31
+ ENDCLASS.
32
+
33
+ CLASS lcl IMPLEMENTATION.
34
+ METHOD matches.
35
+ ENDMETHOD.
36
+ ENDCLASS.`,
28
37
  };
29
38
  }
30
39
  getConfig() {
@@ -23,6 +23,13 @@ class MixReturning extends _abap_rule_1.ABAPRule {
23
23
  // eslint-disable-next-line max-len
24
24
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-either-returning-or-exporting-or-changing-but-not-a-combination`,
25
25
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
26
+ badExample: `CLASS lcl DEFINITION.
27
+ PUBLIC SECTION.
28
+ METHODS
29
+ foobar
30
+ EXPORTING foo TYPE i
31
+ RETURNING VALUE(rv_string) TYPE string.
32
+ ENDCLASS.`,
26
33
  };
27
34
  }
28
35
  getMessage() {
@@ -23,6 +23,10 @@ class PreferReturningToExporting extends _abap_rule_1.ABAPRule {
23
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
+ badExample: `CLASS lcl DEFINITION.
27
+ PUBLIC SECTION.
28
+ METHODS test EXPORTING ev_foo TYPE i.
29
+ ENDCLASS.`,
26
30
  };
27
31
  }
28
32
  getConfig() {
@@ -27,6 +27,10 @@ class PreferredCompareOperator extends _abap_rule_1.ABAPRule {
27
27
  title: "Preferred compare operator",
28
28
  shortDescription: `Configure undesired operator variants`,
29
29
  tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
30
+ badExample: `IF foo EQ bar.
31
+ ENDIF.`,
32
+ goodExample: `IF foo = bar.
33
+ ENDIF.`,
30
34
  };
31
35
  }
32
36
  getDescription(operator) {
@@ -32,6 +32,8 @@ add ORDER BY PRIMARY KEY if in doubt
32
32
 
33
33
  If the target is a sorted/hashed table, no issue is reported`,
34
34
  tags: [_irule_1.RuleTag.SingleFile],
35
+ badExample: `SELECT * FROM db INTO TABLE @DATA(tab).`,
36
+ goodExample: `SELECT * FROM db INTO TABLE @DATA(tab) ORDER BY PRIMARY KEY.`,
35
37
  };
36
38
  }
37
39
  getConfig() {
@@ -28,6 +28,8 @@ class TypesNaming extends _abap_rule_1.ABAPRule {
28
28
  shortDescription: `Allows you to enforce a pattern for TYPES definitions`,
29
29
  extendedInformation: `Does not run for TYPE POOLS`,
30
30
  tags: [_irule_1.RuleTag.Naming, _irule_1.RuleTag.SingleFile],
31
+ badExample: `TYPES foo TYPE i.`,
32
+ goodExample: `TYPES ty_foo TYPE i.`,
31
33
  };
32
34
  }
33
35
  getConfig() {
@@ -22,6 +22,16 @@ class UseClassBasedExceptions extends _abap_rule_1.ABAPRule {
22
22
  shortDescription: `Use class based exceptions, checks interface and class definitions`,
23
23
  extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-class-based-exceptions`,
24
24
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
25
+ badExample: `INTERFACE lif.
26
+ METHODS load_data
27
+ EXCEPTIONS
28
+ invalid_parameter.
29
+ ENDINTERFACE.`,
30
+ goodExample: `INTERFACE lif.
31
+ METHODS load_data
32
+ RAISING
33
+ cx_something.
34
+ ENDINTERFACE.`,
25
35
  };
26
36
  }
27
37
  getMessage() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.107.0",
3
+ "version": "2.107.2",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -51,9 +51,9 @@
51
51
  "homepage": "https://abaplint.org",
52
52
  "devDependencies": {
53
53
  "@microsoft/api-extractor": "^7.43.1",
54
- "@types/chai": "^4.3.14",
54
+ "@types/chai": "^4.3.15",
55
55
  "@types/mocha": "^10.0.6",
56
- "@types/node": "^20.12.7",
56
+ "@types/node": "^20.12.8",
57
57
  "chai": "^4.4.1",
58
58
  "eslint": "^8.57.0",
59
59
  "mocha": "^10.4.0",