@abaplint/core 2.82.12 → 2.82.16

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.
@@ -879,10 +879,7 @@ declare class ConcatenatedConstant extends Expression {
879
879
 
880
880
  declare class ConceptsOfPackage extends AbstractObject {
881
881
  getType(): string;
882
- getAllowedNaming(): {
883
- maxLength: number;
884
- allowNamespace: boolean;
885
- };
882
+ getAllowedNaming(): IAllowedNaming;
886
883
  getDescription(): string | undefined;
887
884
  }
888
885
 
@@ -2347,12 +2344,15 @@ declare interface IAliases {
2347
2344
  getAll(): readonly Alias[];
2348
2345
  }
2349
2346
 
2347
+ declare interface IAllowedNaming {
2348
+ maxLength: number;
2349
+ allowNamespace: boolean;
2350
+ customRegex?: RegExp;
2351
+ }
2352
+
2350
2353
  declare interface IArtifact {
2351
2354
  getType(): string;
2352
- getAllowedNaming(): {
2353
- maxLength: number;
2354
- allowNamespace: boolean;
2355
- };
2355
+ getAllowedNaming(): IAllowedNaming;
2356
2356
  }
2357
2357
 
2358
2358
  declare interface IAttributes {
@@ -3150,7 +3150,7 @@ export declare class Issue {
3150
3150
  static atRow(file: IFile, row: number, message: string, key: string, severity?: Severity): Issue;
3151
3151
  static atStatement(file: IFile, statement: StatementNode, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
3152
3152
  static atPosition(file: IFile, start: Position, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
3153
- static atRowRange(file: IFile, row: number, startCol: number, endCol: number, message: string, key: string, severity?: Severity): Issue;
3153
+ static atRowRange(file: IFile, row: number, startCol: number, endCol: number, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
3154
3154
  static atRange(file: IFile, start: Position, end: Position, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
3155
3155
  static atToken(file: IFile, token: Token, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
3156
3156
  static atIdentifier(identifier: Identifier, message: string, key: string, severity?: Severity, fix?: IEdit): Issue;
@@ -3608,10 +3608,7 @@ declare class Multiply implements IStatement {
3608
3608
 
3609
3609
  declare class Namespace extends AbstractObject {
3610
3610
  getType(): string;
3611
- getAllowedNaming(): {
3612
- maxLength: number;
3613
- allowNamespace: boolean;
3614
- };
3611
+ getAllowedNaming(): IAllowedNaming;
3615
3612
  getDescription(): string | undefined;
3616
3613
  }
3617
3614
 
@@ -5911,10 +5908,7 @@ declare class WebDynproComponentConfiguration extends AbstractObject {
5911
5908
 
5912
5909
  declare class WebMIME extends AbstractObject {
5913
5910
  getType(): string;
5914
- getAllowedNaming(): {
5915
- maxLength: number;
5916
- allowNamespace: boolean;
5917
- };
5911
+ getAllowedNaming(): IAllowedNaming;
5918
5912
  getDescription(): string | undefined;
5919
5913
  }
5920
5914
 
@@ -7,7 +7,7 @@ const target_1 = require("../expressions/target");
7
7
  const dynamic_1 = require("../expressions/dynamic");
8
8
  class GetBadi {
9
9
  runSyntax(node, scope, filename) {
10
- for (const s of node.findDirectExpressions(Expressions.Source)) {
10
+ for (const s of node.findAllExpressions(Expressions.Source)) {
11
11
  new source_1.Source().runSyntax(s, scope, filename);
12
12
  }
13
13
  for (const t of node.findDirectExpressions(Expressions.Target)) {
@@ -11,7 +11,7 @@ const enum_type_1 = require("../../types/basic/enum_type");
11
11
  class TypeEnum {
12
12
  runSyntax(node, scope, filename) {
13
13
  var _a;
14
- const values = [];
14
+ let values = [];
15
15
  const types = [];
16
16
  if (!(node.get() instanceof Structures.TypeEnum)) {
17
17
  throw new Error("TypeEnum, unexpected type");
@@ -61,6 +61,7 @@ class TypeEnum {
61
61
  type: r.getType(),
62
62
  });
63
63
  }
64
+ values = [];
64
65
  const id = new _typed_identifier_1.TypedIdentifier(stru.getFirstToken(), filename, new basic_1.StructureType(components), ["enum" /* Enum */]);
65
66
  values.push(id);
66
67
  }
@@ -48,7 +48,7 @@ class Issue {
48
48
  severity,
49
49
  });
50
50
  }
51
- static atRowRange(file, row, startCol, endCol, message, key, severity) {
51
+ static atRowRange(file, row, startCol, endCol, message, key, severity, fix) {
52
52
  const start = new position_1.Position(row, startCol);
53
53
  const end = new position_1.Position(row, endCol);
54
54
  severity = severity !== null && severity !== void 0 ? severity : severity_1.Severity.Error;
@@ -58,6 +58,7 @@ class Issue {
58
58
  key,
59
59
  start,
60
60
  end,
61
+ fix,
61
62
  severity,
62
63
  });
63
64
  }
@@ -10,6 +10,7 @@ class ConceptsOfPackage extends _abstract_object_1.AbstractObject {
10
10
  return {
11
11
  maxLength: 30,
12
12
  allowNamespace: true,
13
+ customRegex: new RegExp(/^(\/[A-Z_\d]{3,8}\/)?[A-Z_-\d<> ]+$/i),
13
14
  };
14
15
  }
15
16
  getDescription() {
@@ -10,6 +10,7 @@ class Namespace extends _abstract_object_1.AbstractObject {
10
10
  return {
11
11
  maxLength: 10,
12
12
  allowNamespace: true,
13
+ customRegex: new RegExp(/^\/[A-Z_\d]{3,8}\/$/i),
13
14
  };
14
15
  }
15
16
  getDescription() {
@@ -10,6 +10,7 @@ class WebMIME extends _abstract_object_1.AbstractObject {
10
10
  return {
11
11
  maxLength: 40,
12
12
  allowNamespace: true,
13
+ customRegex: new RegExp(/^[A-Z_-\d/<> ]+$/i),
13
14
  };
14
15
  }
15
16
  getDescription() {
@@ -68,7 +68,7 @@ class Registry {
68
68
  }
69
69
  static abaplintVersion() {
70
70
  // magic, see build script "version.sh"
71
- return "2.82.12";
71
+ return "2.82.16";
72
72
  }
73
73
  getDDICReferences() {
74
74
  return this.references;
@@ -30,19 +30,20 @@ class AllowedObjectNaming {
30
30
  }
31
31
  run(obj) {
32
32
  const allowed = obj.getAllowedNaming();
33
+ const name = obj.getName();
33
34
  let message = "";
34
- if (obj.getName().length > allowed.maxLength) {
35
+ if (name.length > allowed.maxLength) {
35
36
  message = "Name exceeds max length";
36
37
  }
37
- else if (allowed.allowNamespace === false && obj.getName().indexOf("/") >= 0) {
38
+ else if (allowed.allowNamespace === false && name.indexOf("/") >= 0) {
38
39
  message = "Namespace not allowed for object type";
39
40
  }
40
- else if (obj.getType() === "NSPC") {
41
- if (obj.getName().match(/^\/[A-Z_\d]{3,8}\/$/i) === null) {
41
+ else if (allowed.customRegex !== undefined) {
42
+ if (name.match(allowed.customRegex) === null) {
42
43
  message = "Name not allowed";
43
44
  }
44
45
  }
45
- else if (obj.getName().match(/^(\/[A-Z_\d]{3,8}\/)?[A-Z_-\d<> ]+$/i) === null) {
46
+ else if (name.match(/^(\/[A-Z_\d]{3,8}\/)?[A-Z_\d<> ]+$/i) === null) {
46
47
  message = "Name not allowed";
47
48
  }
48
49
  if (message.length > 0) {
@@ -4,6 +4,7 @@ exports.ImplementMethods = exports.ImplementMethodsConf = 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
+ const objects_1 = require("../objects");
7
8
  const Statements = require("../abap/2_statements/statements");
8
9
  const Expressions = require("../abap/2_statements/expressions");
9
10
  const _irule_1 = require("./_irule");
@@ -22,6 +23,7 @@ class ImplementMethods extends _abap_rule_1.ABAPRule {
22
23
  key: "implement_methods",
23
24
  title: "Implement methods",
24
25
  shortDescription: `Checks for abstract methods and methods from interfaces which need implementing.`,
26
+ extendedInformation: `INCLUDE programs are only checked in connection with their main programs.`,
25
27
  tags: [_irule_1.RuleTag.Syntax, _irule_1.RuleTag.Quickfix],
26
28
  };
27
29
  }
@@ -36,6 +38,9 @@ class ImplementMethods extends _abap_rule_1.ABAPRule {
36
38
  if (file.getStructure() === undefined) {
37
39
  return [];
38
40
  }
41
+ else if (obj instanceof objects_1.Program && obj.isInclude() === true) {
42
+ return [];
43
+ }
39
44
  this.obj = obj;
40
45
  for (const classDefinition of file.getInfo().listClassDefinitions()) {
41
46
  const classImplementation = this.lookupImplementationInObject(classDefinition.name, obj);
@@ -63,6 +63,8 @@ class ObsoleteStatementConf extends _basic_rule_config_1.BasicRuleConfig {
63
63
  this.callTransformation = true;
64
64
  /** Check for POSIX REGEX usage */
65
65
  this.regex = true;
66
+ /** Check for OCCURENCES vs OCCURRENCES usage */
67
+ this.occurences = true;
66
68
  }
67
69
  }
68
70
  exports.ObsoleteStatementConf = ObsoleteStatementConf;
@@ -113,7 +115,9 @@ SORT BY FS: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapsort_
113
115
 
114
116
  CALL TRANSFORMATION OBJECTS: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abapcall_transformation_objects.htm
115
117
 
116
- POSIX REGEX: https://help.sap.com/doc/abapdocu_755_index_htm/7.55/en-US/index.htm`,
118
+ POSIX REGEX: https://help.sap.com/doc/abapdocu_755_index_htm/7.55/en-US/index.htm
119
+
120
+ OCCURENCES: check for OCCURENCES vs OCCURRENCES`,
117
121
  };
118
122
  }
119
123
  getConfig() {
@@ -270,6 +274,13 @@ POSIX REGEX: https://help.sap.com/doc/abapdocu_755_index_htm/7.55/en-US/index.ht
270
274
  issues.push(issue);
271
275
  }
272
276
  }
277
+ if (this.conf.occurences && sta instanceof Statements.Replace) {
278
+ const concat = staNode.concatTokens().toUpperCase();
279
+ if (concat.includes(" OCCURENCES ")) {
280
+ const issue = issue_1.Issue.atStatement(file, staNode, "Use \"OCCURRENCES\"", this.getMetadata().key, this.conf.severity);
281
+ issues.push(issue);
282
+ }
283
+ }
273
284
  if (configVersion >= version_1.Version.v756 && this.conf.regex) {
274
285
  if (sta instanceof Statements.Find || sta instanceof Statements.Replace) {
275
286
  if ((_c = staNode.findFirstExpression(Expressions.FindType)) === null || _c === void 0 ? void 0 : _c.concatTokens().includes("REGEX")) {
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SpaceBeforeColon = exports.SpaceBeforeColonConf = void 0;
4
+ const position_1 = require("../position");
5
+ const edit_helper_1 = require("../edit_helper");
4
6
  const issue_1 = require("../issue");
5
7
  const _abap_rule_1 = require("./_abap_rule");
6
8
  const _basic_rule_config_1 = require("./_basic_rule_config");
@@ -19,7 +21,7 @@ class SpaceBeforeColon extends _abap_rule_1.ABAPRule {
19
21
  title: "Space before colon",
20
22
  shortDescription: `Checks that there are no spaces in front of colons in chained statements.`,
21
23
  extendedInformation: `https://docs.abapopenchecks.org/checks/80/`,
22
- tags: [_irule_1.RuleTag.Whitespace, _irule_1.RuleTag.SingleFile],
24
+ tags: [_irule_1.RuleTag.Whitespace, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
23
25
  badExample: `DATA : foo TYPE string.`,
24
26
  goodExample: `DATA: foo TYPE string.`,
25
27
  };
@@ -44,8 +46,10 @@ class SpaceBeforeColon extends _abap_rule_1.ABAPRule {
44
46
  else if (token.getStr() === ":"
45
47
  && prev.getRow() === token.getRow()
46
48
  && prev.getCol() + prev.getStr().length < token.getCol()) {
47
- const issue = issue_1.Issue.atRowRange(file, token.getRow(), prev.getEnd().getCol(), token.getStart().getCol(), this.getMessage(), this.getMetadata().key, this.conf.severity);
48
- // const issue = Issue.atToken(file, token, this.getMessage(), this.getMetadata().key);
49
+ const start = new position_1.Position(token.getRow(), prev.getEnd().getCol());
50
+ const end = new position_1.Position(token.getRow(), token.getStart().getCol());
51
+ const fix = edit_helper_1.EditHelper.deleteRange(file, start, end);
52
+ const issue = issue_1.Issue.atRowRange(file, start.getRow(), start.getCol(), end.getCol(), this.getMessage(), this.getMetadata().key, this.conf.severity, fix);
49
53
  issues.push(issue);
50
54
  }
51
55
  prev = token;
@@ -5,6 +5,8 @@ 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
+ const edit_helper_1 = require("../edit_helper");
9
+ const _statement_1 = require("../abap/2_statements/statements/_statement");
8
10
  class UnnecessaryChainingConf extends _basic_rule_config_1.BasicRuleConfig {
9
11
  }
10
12
  exports.UnnecessaryChainingConf = UnnecessaryChainingConf;
@@ -19,7 +21,7 @@ class UnnecessaryChaining extends _abap_rule_1.ABAPRule {
19
21
  title: "Unnecessary Chaining",
20
22
  shortDescription: `Find unnecessary chaining, all statements are checked`,
21
23
  extendedInformation: ``,
22
- tags: [_irule_1.RuleTag.SingleFile],
24
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
23
25
  badExample: `WRITE: bar.`,
24
26
  goodExample: `WRITE bar.`,
25
27
  };
@@ -31,7 +33,7 @@ class UnnecessaryChaining extends _abap_rule_1.ABAPRule {
31
33
  this.conf = conf;
32
34
  }
33
35
  runParsed(file) {
34
- var _a, _b;
36
+ var _a;
35
37
  const issues = [];
36
38
  const statements = file.getStatements();
37
39
  for (let i = 0; i < statements.length; i++) {
@@ -39,16 +41,24 @@ class UnnecessaryChaining extends _abap_rule_1.ABAPRule {
39
41
  if (colon === undefined) {
40
42
  continue;
41
43
  }
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
+ // find the next non Comment statement
45
+ let j = 1;
46
+ let nextStatement = statements[i + j];
47
+ while ((nextStatement === null || nextStatement === void 0 ? void 0 : nextStatement.get()) instanceof _statement_1.Comment) {
48
+ j++;
49
+ nextStatement = statements[i + j];
50
+ }
51
+ const next = nextStatement === null || nextStatement === void 0 ? void 0 : nextStatement.getColon();
52
+ const prev = (_a = statements[i - 1]) === null || _a === void 0 ? void 0 : _a.getColon();
44
53
  if (next !== undefined && colon.getStart().equals(next.getStart())) {
45
54
  continue;
46
55
  }
47
56
  else if (prev !== undefined && colon.getStart().equals(prev.getStart())) {
48
57
  continue;
49
58
  }
59
+ const fix = edit_helper_1.EditHelper.deleteRange(file, colon.getStart(), colon.getEnd());
50
60
  const message = "Unnecessary chaining";
51
- const issue = issue_1.Issue.atStatement(file, statements[i], message, this.getMetadata().key);
61
+ const issue = issue_1.Issue.atStatement(file, statements[i], message, this.getMetadata().key, this.conf.severity, fix);
52
62
  issues.push(issue);
53
63
  }
54
64
  return issues;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.82.12",
3
+ "version": "2.82.16",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",
@@ -45,17 +45,17 @@
45
45
  },
46
46
  "homepage": "https://abaplint.org",
47
47
  "devDependencies": {
48
- "@microsoft/api-extractor": "^7.18.19",
49
- "@types/chai": "^4.2.22",
48
+ "@microsoft/api-extractor": "^7.19.2",
49
+ "@types/chai": "^4.3.0",
50
50
  "@types/mocha": "^9.0.0",
51
- "@types/node": "^16.11.11",
51
+ "@types/node": "^16.11.12",
52
52
  "chai": "^4.3.4",
53
- "eslint": "^8.3.0",
53
+ "eslint": "^8.4.1",
54
54
  "mocha": "^9.1.3",
55
55
  "c8": "^7.10.0",
56
56
  "source-map-support": "^0.5.21",
57
57
  "ts-json-schema-generator": "^0.97.0",
58
- "typescript": "^4.5.2"
58
+ "typescript": "^4.5.3"
59
59
  },
60
60
  "dependencies": {
61
61
  "fast-xml-parser": "^3.21.1",