@abaplint/cli 2.99.11 → 2.100.0

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 (2) hide show
  1. package/build/cli.js +189 -17
  2. package/package.json +4 -3
package/build/cli.js CHANGED
@@ -20687,6 +20687,9 @@ class CurrentScope {
20687
20687
  getDDICReferences() {
20688
20688
  return this.reg.getDDICReferences();
20689
20689
  }
20690
+ getMSAGReferences() {
20691
+ return this.reg.getMSAGReferences();
20692
+ }
20690
20693
  getParentObj() {
20691
20694
  return this.parentObj;
20692
20695
  }
@@ -24242,9 +24245,26 @@ const Expressions = __webpack_require__(/*! ../../2_statements/expressions */ ".
24242
24245
  const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
24243
24246
  class MessageSource {
24244
24247
  runSyntax(node, scope, filename) {
24248
+ var _a, _b, _c, _d;
24245
24249
  for (const f of node.findDirectExpressions(Expressions.Source)) {
24246
24250
  new source_1.Source().runSyntax(f, scope, filename);
24247
24251
  }
24252
+ if (node.getFirstToken().getStr().toUpperCase() === "ID") {
24253
+ const id = (_a = node.findExpressionAfterToken("ID")) === null || _a === void 0 ? void 0 : _a.concatTokens();
24254
+ const number = (_b = node.findDirectExpression(Expressions.MessageNumber)) === null || _b === void 0 ? void 0 : _b.concatTokens();
24255
+ if ((id === null || id === void 0 ? void 0 : id.startsWith("'")) && number) {
24256
+ const messageClass = id.substring(1, id.length - 1).toUpperCase();
24257
+ scope.getMSAGReferences().addUsing(filename, node.getFirstToken(), messageClass, number);
24258
+ }
24259
+ }
24260
+ else {
24261
+ const typeAndNumber = (_c = node.findDirectExpression(Expressions.MessageTypeAndNumber)) === null || _c === void 0 ? void 0 : _c.concatTokens();
24262
+ const messageNumber = typeAndNumber === null || typeAndNumber === void 0 ? void 0 : typeAndNumber.substring(1);
24263
+ const messageClass = (_d = node.findDirectExpression(Expressions.MessageClass)) === null || _d === void 0 ? void 0 : _d.concatTokens().toUpperCase();
24264
+ if (messageNumber && messageClass) {
24265
+ scope.getMSAGReferences().addUsing(filename, node.getFirstToken(), messageClass, messageNumber);
24266
+ }
24267
+ }
24248
24268
  }
24249
24269
  }
24250
24270
  exports.MessageSource = MessageSource;
@@ -31953,6 +31973,7 @@ class SyntaxLogic {
31953
31973
  }
31954
31974
  this.issues = [];
31955
31975
  this.reg.getDDICReferences().clear(this.object);
31976
+ this.reg.getMSAGReferences().clear(this.object);
31956
31977
  if (this.object instanceof objects_1.Program && this.object.isInclude()) {
31957
31978
  // todo, show some kind of error?
31958
31979
  return { issues: [], spaghetti: this.scope.pop(new position_1.Position(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER)) };
@@ -35987,21 +36008,21 @@ exports.InterfaceDefinition = InterfaceDefinition;
35987
36008
  Object.defineProperty(exports, "__esModule", ({ value: true }));
35988
36009
  exports.Message = void 0;
35989
36010
  class Message {
35990
- constructor(num, msg) {
35991
- this.num = num;
35992
- if (this.num === undefined) {
35993
- this.num = "";
36011
+ constructor(number, message) {
36012
+ this.number = number;
36013
+ if (this.number === undefined) {
36014
+ this.number = "";
35994
36015
  }
35995
- this.msg = msg;
35996
- if (this.msg === undefined) {
35997
- this.msg = "";
36016
+ this.message = message;
36017
+ if (this.message === undefined) {
36018
+ this.message = "";
35998
36019
  }
35999
36020
  }
36000
36021
  getNumber() {
36001
- return this.num;
36022
+ return this.number;
36002
36023
  }
36003
36024
  getMessage() {
36004
- return this.msg;
36025
+ return this.message;
36005
36026
  }
36006
36027
  getPlaceholderCount() {
36007
36028
  return (this.getMessage().match(/&/g) || []).length;
@@ -38316,10 +38337,11 @@ class DDICReferences {
38316
38337
  }
38317
38338
  }
38318
38339
  }
38319
- const newName = obj.getName().toUpperCase();
38320
- const newType = obj.getType();
38321
- if ((_b = this.nameTypeIndex[newName]) === null || _b === void 0 ? void 0 : _b[newType]) {
38322
- this.nameTypeIndex[newName][newType] = [];
38340
+ // remove from name + type index
38341
+ const name = obj.getName().toUpperCase();
38342
+ const type = obj.getType();
38343
+ if ((_b = this.nameTypeIndex[name]) === null || _b === void 0 ? void 0 : _b[type]) {
38344
+ this.nameTypeIndex[name][type] = [];
38323
38345
  }
38324
38346
  }
38325
38347
  listByFilename(filename, line) {
@@ -41084,6 +41106,65 @@ exports.Symbols = Symbols;
41084
41106
 
41085
41107
  /***/ }),
41086
41108
 
41109
+ /***/ "./node_modules/@abaplint/core/build/src/msag_references.js":
41110
+ /*!******************************************************************!*\
41111
+ !*** ./node_modules/@abaplint/core/build/src/msag_references.js ***!
41112
+ \******************************************************************/
41113
+ /***/ ((__unused_webpack_module, exports) => {
41114
+
41115
+ "use strict";
41116
+
41117
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
41118
+ exports.MSAGReferences = void 0;
41119
+ class MSAGReferences {
41120
+ constructor() {
41121
+ this.nameNumberIndex = {};
41122
+ this.filenameIndex = {};
41123
+ }
41124
+ addUsing(filename, token, messageClass, number) {
41125
+ if (this.filenameIndex[filename] === undefined) {
41126
+ this.filenameIndex[filename] = [];
41127
+ }
41128
+ this.filenameIndex[filename].push({
41129
+ token: token,
41130
+ messageClass: messageClass,
41131
+ number: number,
41132
+ });
41133
+ if (this.nameNumberIndex[messageClass] === undefined) {
41134
+ this.nameNumberIndex[messageClass] = {};
41135
+ }
41136
+ if (this.nameNumberIndex[messageClass][number] === undefined) {
41137
+ this.nameNumberIndex[messageClass][number] = [];
41138
+ }
41139
+ this.nameNumberIndex[messageClass][number].push({
41140
+ filename: filename,
41141
+ token: token,
41142
+ });
41143
+ }
41144
+ clear(obj) {
41145
+ for (const file of obj.getFiles()) {
41146
+ const filename = file.getFilename();
41147
+ for (const fIndex of this.filenameIndex[filename] || []) {
41148
+ // this should be okay for performance, each message should be referenced less than 10 times typically
41149
+ this.nameNumberIndex[fIndex.messageClass][fIndex.number] =
41150
+ this.nameNumberIndex[fIndex.messageClass][fIndex.number].filter(i => i.filename !== filename);
41151
+ }
41152
+ delete this.filenameIndex[filename];
41153
+ }
41154
+ }
41155
+ listByFilename(filename) {
41156
+ return this.filenameIndex[filename] || [];
41157
+ }
41158
+ listByMessage(messageClass, number) {
41159
+ var _a;
41160
+ return ((_a = this.nameNumberIndex[messageClass]) === null || _a === void 0 ? void 0 : _a[number]) || [];
41161
+ }
41162
+ }
41163
+ exports.MSAGReferences = MSAGReferences;
41164
+ //# sourceMappingURL=msag_references.js.map
41165
+
41166
+ /***/ }),
41167
+
41087
41168
  /***/ "./node_modules/@abaplint/core/build/src/objects/_abap_object.js":
41088
41169
  /*!***********************************************************************!*\
41089
41170
  !*** ./node_modules/@abaplint/core/build/src/objects/_abap_object.js ***!
@@ -44597,6 +44678,7 @@ class MessageClass extends _abstract_object_1.AbstractObject {
44597
44678
  return msg ? msg : [];
44598
44679
  }
44599
44680
  getByNumber(num) {
44681
+ // todo, optimize performance,
44600
44682
  for (const message of this.getMessages()) {
44601
44683
  if (message.getNumber() === num) {
44602
44684
  return message;
@@ -47558,6 +47640,7 @@ const find_global_definitions_1 = __webpack_require__(/*! ./abap/5_syntax/global
47558
47640
  const excludeHelper_1 = __webpack_require__(/*! ./utils/excludeHelper */ "./node_modules/@abaplint/core/build/src/utils/excludeHelper.js");
47559
47641
  const ddic_references_1 = __webpack_require__(/*! ./ddic_references */ "./node_modules/@abaplint/core/build/src/ddic_references.js");
47560
47642
  const rules_runner_1 = __webpack_require__(/*! ./rules_runner */ "./node_modules/@abaplint/core/build/src/rules_runner.js");
47643
+ const msag_references_1 = __webpack_require__(/*! ./msag_references */ "./node_modules/@abaplint/core/build/src/msag_references.js");
47561
47644
  // todo, this should really be an instance in case there are multiple Registry'ies
47562
47645
  class ParsingPerformance {
47563
47646
  static clear() {
@@ -47610,14 +47693,18 @@ class Registry {
47610
47693
  this.objectsByType = {};
47611
47694
  this.dependencies = {};
47612
47695
  this.conf = conf ? conf : config_1.Config.getDefault();
47613
- this.references = new ddic_references_1.DDICReferences();
47696
+ this.ddicReferences = new ddic_references_1.DDICReferences();
47697
+ this.msagReferences = new msag_references_1.MSAGReferences();
47614
47698
  }
47615
47699
  static abaplintVersion() {
47616
47700
  // magic, see build script "version.sh"
47617
- return "2.99.11";
47701
+ return "2.100.0";
47618
47702
  }
47619
47703
  getDDICReferences() {
47620
- return this.references;
47704
+ return this.ddicReferences;
47705
+ }
47706
+ getMSAGReferences() {
47707
+ return this.msagReferences;
47621
47708
  }
47622
47709
  *getObjects() {
47623
47710
  for (const name in this.objects) {
@@ -47705,7 +47792,8 @@ class Registry {
47705
47792
  const obj = this.find(file.getObjectName(), file.getObjectType());
47706
47793
  obj.removeFile(file);
47707
47794
  if (obj.getFiles().length === 0) {
47708
- this.references.clear(obj);
47795
+ this.ddicReferences.clear(obj);
47796
+ this.msagReferences.clear(obj);
47709
47797
  this.removeObject(obj);
47710
47798
  }
47711
47799
  return this;
@@ -54911,6 +54999,88 @@ exports.Downport = Downport;
54911
54999
 
54912
55000
  /***/ }),
54913
55001
 
55002
+ /***/ "./node_modules/@abaplint/core/build/src/rules/easy_to_find_messages.js":
55003
+ /*!******************************************************************************!*\
55004
+ !*** ./node_modules/@abaplint/core/build/src/rules/easy_to_find_messages.js ***!
55005
+ \******************************************************************************/
55006
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
55007
+
55008
+ "use strict";
55009
+
55010
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
55011
+ exports.EasyToFindMessages = exports.EasyToFindMessagesConf = void 0;
55012
+ const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
55013
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "./node_modules/@abaplint/core/build/src/rules/_irule.js");
55014
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
55015
+ const position_1 = __webpack_require__(/*! ../position */ "./node_modules/@abaplint/core/build/src/position.js");
55016
+ const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/syntax.js");
55017
+ const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "./node_modules/@abaplint/core/build/src/objects/_abap_object.js");
55018
+ class EasyToFindMessagesConf extends _basic_rule_config_1.BasicRuleConfig {
55019
+ }
55020
+ exports.EasyToFindMessagesConf = EasyToFindMessagesConf;
55021
+ class EasyToFindMessages {
55022
+ constructor() {
55023
+ this.conf = new EasyToFindMessagesConf();
55024
+ }
55025
+ getMetadata() {
55026
+ return {
55027
+ key: "easy_to_find_messages",
55028
+ title: "Easy to find messages",
55029
+ shortDescription: `Make messages easy to find`,
55030
+ extendedInformation: `All messages must be statically referenced exactly once
55031
+
55032
+ Only MESSAGE and RAISE statments are counted as static references
55033
+
55034
+ Also see rule "message_exists"
55035
+
55036
+ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#make-messages-easy-to-find`,
55037
+ tags: [_irule_1.RuleTag.Styleguide],
55038
+ };
55039
+ }
55040
+ getConfig() {
55041
+ return this.conf;
55042
+ }
55043
+ setConfig(conf) {
55044
+ this.conf = conf;
55045
+ }
55046
+ initialize(reg) {
55047
+ this.msagReferences = reg.getMSAGReferences();
55048
+ // the SyntaxLogic builds the references
55049
+ for (const obj of reg.getObjects()) {
55050
+ if (obj instanceof _abap_object_1.ABAPObject) {
55051
+ new syntax_1.SyntaxLogic(reg, obj).run();
55052
+ }
55053
+ }
55054
+ return this;
55055
+ }
55056
+ run(object) {
55057
+ const issues = [];
55058
+ if (object.getType() === "MSAG") {
55059
+ const msag = object;
55060
+ for (const message of msag.getMessages()) {
55061
+ const where = this.msagReferences.listByMessage(msag.getName().toUpperCase(), message.getNumber());
55062
+ if (where.length === 0) {
55063
+ const text = `Message ${message.getNumber()} not statically referenced`;
55064
+ const position = new position_1.Position(1, 1);
55065
+ const issue = issue_1.Issue.atPosition(object.getFiles()[0], position, text, this.getMetadata().key, this.conf.severity);
55066
+ issues.push(issue);
55067
+ }
55068
+ else if (where.length >= 2) {
55069
+ const text = `Message ${message.getNumber()} referenced more than once`;
55070
+ const position = new position_1.Position(1, 1);
55071
+ const issue = issue_1.Issue.atPosition(object.getFiles()[0], position, text, this.getMetadata().key, this.conf.severity);
55072
+ issues.push(issue);
55073
+ }
55074
+ }
55075
+ }
55076
+ return issues;
55077
+ }
55078
+ }
55079
+ exports.EasyToFindMessages = EasyToFindMessages;
55080
+ //# sourceMappingURL=easy_to_find_messages.js.map
55081
+
55082
+ /***/ }),
55083
+
54914
55084
  /***/ "./node_modules/@abaplint/core/build/src/rules/empty_line_in_statement.js":
54915
55085
  /*!********************************************************************************!*\
54916
55086
  !*** ./node_modules/@abaplint/core/build/src/rules/empty_line_in_statement.js ***!
@@ -57519,6 +57689,7 @@ __exportStar(__webpack_require__(/*! ./definitions_top */ "./node_modules/@abapl
57519
57689
  __exportStar(__webpack_require__(/*! ./description_empty */ "./node_modules/@abaplint/core/build/src/rules/description_empty.js"), exports);
57520
57690
  __exportStar(__webpack_require__(/*! ./double_space */ "./node_modules/@abaplint/core/build/src/rules/double_space.js"), exports);
57521
57691
  __exportStar(__webpack_require__(/*! ./downport */ "./node_modules/@abaplint/core/build/src/rules/downport.js"), exports);
57692
+ __exportStar(__webpack_require__(/*! ./easy_to_find_messages */ "./node_modules/@abaplint/core/build/src/rules/easy_to_find_messages.js"), exports);
57522
57693
  __exportStar(__webpack_require__(/*! ./empty_line_in_statement */ "./node_modules/@abaplint/core/build/src/rules/empty_line_in_statement.js"), exports);
57523
57694
  __exportStar(__webpack_require__(/*! ./empty_statement */ "./node_modules/@abaplint/core/build/src/rules/empty_statement.js"), exports);
57524
57695
  __exportStar(__webpack_require__(/*! ./empty_structure */ "./node_modules/@abaplint/core/build/src/rules/empty_structure.js"), exports);
@@ -59990,6 +60161,7 @@ class MSAGConsistency {
59990
60161
  key: "msag_consistency",
59991
60162
  title: "MSAG consistency check",
59992
60163
  shortDescription: `Checks the validity of messages in message classes`,
60164
+ extendedInformation: `Message numbers must be 3 digits, and message text must not be empty`,
59993
60165
  };
59994
60166
  }
59995
60167
  getDescription(reason) {
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.99.11",
3
+ "version": "2.100.0",
4
4
  "description": "abaplint - Command Line Interface",
5
+ "funding": "https://github.com/sponsors/larshp",
5
6
  "bin": {
6
7
  "abaplint": "./abaplint"
7
8
  },
@@ -37,12 +38,12 @@
37
38
  },
38
39
  "homepage": "https://abaplint.org",
39
40
  "devDependencies": {
40
- "@abaplint/core": "^2.99.11",
41
+ "@abaplint/core": "^2.100.0",
41
42
  "@types/chai": "^4.3.5",
42
43
  "@types/glob": "^7.2.0",
43
44
  "@types/minimist": "^1.2.2",
44
45
  "@types/mocha": "^10.0.1",
45
- "@types/node": "^20.1.2",
46
+ "@types/node": "^20.1.3",
46
47
  "@types/progress": "^2.0.5",
47
48
  "chai": "^4.3.7",
48
49
  "chalk": "^5.2.0",