@abaplint/cli 2.120.84 → 2.120.85
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.
- package/build/cli.js +142 -10
- package/package.json +2 -2
package/build/cli.js
CHANGED
|
@@ -11305,23 +11305,25 @@ class Result {
|
|
|
11305
11305
|
return this.tokens[this.tokenIndex + offset];
|
|
11306
11306
|
}
|
|
11307
11307
|
shift(node) {
|
|
11308
|
-
return Result.fromChain(this.tokens, this.tokenIndex + 1, { node, previous: this.nodes }, this.nodeCount + 1);
|
|
11308
|
+
return Result.fromChain(this.tokens, this.tokenIndex + 1, { node, tokenCount: 1, previous: this.nodes }, this.nodeCount + 1);
|
|
11309
11309
|
}
|
|
11310
11310
|
wrapConsumed(consumedTokens, node) {
|
|
11311
11311
|
let current = this.nodes;
|
|
11312
11312
|
let currentCount = this.nodeCount;
|
|
11313
|
+
let tokenCount = 0;
|
|
11313
11314
|
const children = [];
|
|
11314
11315
|
while (consumedTokens > 0) {
|
|
11315
11316
|
if (current === undefined) {
|
|
11316
11317
|
break;
|
|
11317
11318
|
}
|
|
11318
11319
|
children.push(current.node);
|
|
11319
|
-
consumedTokens = consumedTokens - current.
|
|
11320
|
+
consumedTokens = consumedTokens - current.tokenCount;
|
|
11321
|
+
tokenCount = tokenCount + current.tokenCount;
|
|
11320
11322
|
current = current.previous;
|
|
11321
11323
|
currentCount--;
|
|
11322
11324
|
}
|
|
11323
11325
|
node.setChildren(children.reverse());
|
|
11324
|
-
this.nodes = { node, previous: current };
|
|
11326
|
+
this.nodes = { node, tokenCount, previous: current };
|
|
11325
11327
|
this.nodeCount = currentCount + 1;
|
|
11326
11328
|
return this;
|
|
11327
11329
|
}
|
|
@@ -11350,7 +11352,7 @@ class Result {
|
|
|
11350
11352
|
this.nodes = undefined;
|
|
11351
11353
|
this.nodeCount = 0;
|
|
11352
11354
|
for (const node of n) {
|
|
11353
|
-
this.nodes = { node, previous: this.nodes };
|
|
11355
|
+
this.nodes = { node, tokenCount: node.countTokens(), previous: this.nodes };
|
|
11354
11356
|
this.nodeCount++;
|
|
11355
11357
|
}
|
|
11356
11358
|
}
|
|
@@ -50834,7 +50836,6 @@ const _abstract_node_1 = __webpack_require__(/*! ./_abstract_node */ "../core/bu
|
|
|
50834
50836
|
class ExpressionNode extends _abstract_node_1.AbstractNode {
|
|
50835
50837
|
constructor(expression) {
|
|
50836
50838
|
super();
|
|
50837
|
-
this.tokenCount = 0;
|
|
50838
50839
|
this.expression = expression;
|
|
50839
50840
|
}
|
|
50840
50841
|
addChild(_n) {
|
|
@@ -50845,13 +50846,15 @@ class ExpressionNode extends _abstract_node_1.AbstractNode {
|
|
|
50845
50846
|
}
|
|
50846
50847
|
setChildren(children) {
|
|
50847
50848
|
super.setChildren(children);
|
|
50848
|
-
for (const child of this.getChildren()) {
|
|
50849
|
-
this.tokenCount = this.tokenCount + child.countTokens();
|
|
50850
|
-
}
|
|
50851
50849
|
return this;
|
|
50852
50850
|
}
|
|
50851
|
+
// not stored on the node, saves a field per ExpressionNode, the statement parser tracks counts itself
|
|
50853
50852
|
countTokens() {
|
|
50854
|
-
|
|
50853
|
+
let count = 0;
|
|
50854
|
+
for (const child of this.getChildren()) {
|
|
50855
|
+
count = count + child.countTokens();
|
|
50856
|
+
}
|
|
50857
|
+
return count;
|
|
50855
50858
|
}
|
|
50856
50859
|
getFirstToken() {
|
|
50857
50860
|
for (const child of this.getChildren()) {
|
|
@@ -72651,7 +72654,7 @@ class Registry {
|
|
|
72651
72654
|
}
|
|
72652
72655
|
static abaplintVersion() {
|
|
72653
72656
|
// magic, see build script "version.js"
|
|
72654
|
-
return "2.120.
|
|
72657
|
+
return "2.120.85";
|
|
72655
72658
|
}
|
|
72656
72659
|
getDDICReferences() {
|
|
72657
72660
|
return this.ddicReferences;
|
|
@@ -91869,6 +91872,7 @@ __exportStar(__webpack_require__(/*! ./prefer_pragmas */ "../core/build/src/rule
|
|
|
91869
91872
|
__exportStar(__webpack_require__(/*! ./prefer_abap_bool */ "../core/build/src/rules/prefer_abap_bool.js"), exports);
|
|
91870
91873
|
__exportStar(__webpack_require__(/*! ./prefer_abap_bool_values */ "../core/build/src/rules/prefer_abap_bool_values.js"), exports);
|
|
91871
91874
|
__exportStar(__webpack_require__(/*! ./prefer_raise_exception_new */ "../core/build/src/rules/prefer_raise_exception_new.js"), exports);
|
|
91875
|
+
__exportStar(__webpack_require__(/*! ./prefer_raise_message */ "../core/build/src/rules/prefer_raise_message.js"), exports);
|
|
91872
91876
|
__exportStar(__webpack_require__(/*! ./prefer_string_template */ "../core/build/src/rules/prefer_string_template.js"), exports);
|
|
91873
91877
|
__exportStar(__webpack_require__(/*! ./prefer_returning_to_exporting */ "../core/build/src/rules/prefer_returning_to_exporting.js"), exports);
|
|
91874
91878
|
__exportStar(__webpack_require__(/*! ./prefer_xsdbool */ "../core/build/src/rules/prefer_xsdbool.js"), exports);
|
|
@@ -101304,6 +101308,134 @@ exports.PreferRaiseExceptionNew = PreferRaiseExceptionNew;
|
|
|
101304
101308
|
|
|
101305
101309
|
/***/ },
|
|
101306
101310
|
|
|
101311
|
+
/***/ "../core/build/src/rules/prefer_raise_message.js"
|
|
101312
|
+
/*!*******************************************************!*\
|
|
101313
|
+
!*** ../core/build/src/rules/prefer_raise_message.js ***!
|
|
101314
|
+
\*******************************************************/
|
|
101315
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
101316
|
+
|
|
101317
|
+
"use strict";
|
|
101318
|
+
|
|
101319
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
101320
|
+
if (k2 === undefined) k2 = k;
|
|
101321
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
101322
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
101323
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
101324
|
+
}
|
|
101325
|
+
Object.defineProperty(o, k2, desc);
|
|
101326
|
+
}) : (function(o, m, k, k2) {
|
|
101327
|
+
if (k2 === undefined) k2 = k;
|
|
101328
|
+
o[k2] = m[k];
|
|
101329
|
+
}));
|
|
101330
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
101331
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
101332
|
+
}) : function(o, v) {
|
|
101333
|
+
o["default"] = v;
|
|
101334
|
+
});
|
|
101335
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
101336
|
+
var ownKeys = function(o) {
|
|
101337
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
101338
|
+
var ar = [];
|
|
101339
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
101340
|
+
return ar;
|
|
101341
|
+
};
|
|
101342
|
+
return ownKeys(o);
|
|
101343
|
+
};
|
|
101344
|
+
return function (mod) {
|
|
101345
|
+
if (mod && mod.__esModule) return mod;
|
|
101346
|
+
var result = {};
|
|
101347
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
101348
|
+
__setModuleDefault(result, mod);
|
|
101349
|
+
return result;
|
|
101350
|
+
};
|
|
101351
|
+
})();
|
|
101352
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
101353
|
+
exports.PreferRaiseMessage = exports.PreferRaiseMessageConf = void 0;
|
|
101354
|
+
const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
|
|
101355
|
+
const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
|
|
101356
|
+
const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
|
|
101357
|
+
const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
|
|
101358
|
+
const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
|
|
101359
|
+
const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
|
|
101360
|
+
class PreferRaiseMessageConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
101361
|
+
constructor() {
|
|
101362
|
+
super(...arguments);
|
|
101363
|
+
/** List of exception class names to ignore, case insensitive */
|
|
101364
|
+
this.ignoreExceptionClasses = [];
|
|
101365
|
+
}
|
|
101366
|
+
}
|
|
101367
|
+
exports.PreferRaiseMessageConf = PreferRaiseMessageConf;
|
|
101368
|
+
class PreferRaiseMessage extends _abap_rule_1.ABAPRule {
|
|
101369
|
+
constructor() {
|
|
101370
|
+
super(...arguments);
|
|
101371
|
+
this.conf = new PreferRaiseMessageConf();
|
|
101372
|
+
}
|
|
101373
|
+
getMetadata() {
|
|
101374
|
+
return {
|
|
101375
|
+
key: "prefer_raise_message",
|
|
101376
|
+
title: "Prefer RAISE EXCEPTION with MESSAGE",
|
|
101377
|
+
shortDescription: `Prefer RAISE EXCEPTION with MESSAGE instead of supplying parameter TEXT`,
|
|
101378
|
+
extendedInformation: `Reports RAISE EXCEPTION statements where parameter TEXT is supplied.
|
|
101379
|
+
|
|
101380
|
+
Use a message class instead, so the text is translatable and can be found via where-used.
|
|
101381
|
+
|
|
101382
|
+
Exception classes can be excluded via configuration "ignoreExceptionClasses".`,
|
|
101383
|
+
tags: [_irule_1.RuleTag.SingleFile],
|
|
101384
|
+
goodExample: `RAISE EXCEPTION TYPE zcx_error MESSAGE e001(zclass).`,
|
|
101385
|
+
badExample: `RAISE EXCEPTION TYPE zcx_error
|
|
101386
|
+
EXPORTING text = 'hello world'.`,
|
|
101387
|
+
};
|
|
101388
|
+
}
|
|
101389
|
+
getConfig() {
|
|
101390
|
+
return this.conf;
|
|
101391
|
+
}
|
|
101392
|
+
setConfig(conf) {
|
|
101393
|
+
this.conf = conf;
|
|
101394
|
+
}
|
|
101395
|
+
runParsed(file) {
|
|
101396
|
+
var _a, _b, _c, _d;
|
|
101397
|
+
var _e;
|
|
101398
|
+
const issues = [];
|
|
101399
|
+
const ignore = ((_e = this.conf.ignoreExceptionClasses) !== null && _e !== void 0 ? _e : []).map(c => c.toUpperCase());
|
|
101400
|
+
for (const statement of file.getStatements()) {
|
|
101401
|
+
if (!(statement.get() instanceof Statements.Raise)) {
|
|
101402
|
+
continue;
|
|
101403
|
+
}
|
|
101404
|
+
const concat = statement.concatTokens().toUpperCase();
|
|
101405
|
+
if (!concat.startsWith("RAISE EXCEPTION ") && !concat.startsWith("RAISE RESUMABLE EXCEPTION ")) {
|
|
101406
|
+
continue;
|
|
101407
|
+
}
|
|
101408
|
+
else if (concat.includes(" MESSAGE")) {
|
|
101409
|
+
continue;
|
|
101410
|
+
}
|
|
101411
|
+
let className;
|
|
101412
|
+
let parameters;
|
|
101413
|
+
const newObject = (_b = (_a = statement.findDirectExpression(Expressions.Source)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.MethodCallChain)) === null || _b === void 0 ? void 0 : _b.findDirectExpression(Expressions.NewObject);
|
|
101414
|
+
if (newObject) {
|
|
101415
|
+
className = (_c = newObject.findDirectExpression(Expressions.TypeNameOrInfer)) === null || _c === void 0 ? void 0 : _c.concatTokens();
|
|
101416
|
+
parameters = newObject.findDirectExpression(Expressions.ParameterListS);
|
|
101417
|
+
}
|
|
101418
|
+
else {
|
|
101419
|
+
className = (_d = statement.findDirectExpression(Expressions.ClassName)) === null || _d === void 0 ? void 0 : _d.concatTokens();
|
|
101420
|
+
parameters = statement.findDirectExpression(Expressions.ParameterListS);
|
|
101421
|
+
}
|
|
101422
|
+
if (className === undefined || ignore.includes(className.toUpperCase())) {
|
|
101423
|
+
continue;
|
|
101424
|
+
}
|
|
101425
|
+
const text = parameters === null || parameters === void 0 ? void 0 : parameters.findDirectExpressions(Expressions.ParameterS).find(p => { var _a; return ((_a = p.findDirectExpression(Expressions.ParameterName)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase()) === "TEXT"; });
|
|
101426
|
+
if (text) {
|
|
101427
|
+
const message = "Prefer RAISE EXCEPTION with MESSAGE, " + className + " raised with parameter TEXT";
|
|
101428
|
+
issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
|
|
101429
|
+
}
|
|
101430
|
+
}
|
|
101431
|
+
return issues;
|
|
101432
|
+
}
|
|
101433
|
+
}
|
|
101434
|
+
exports.PreferRaiseMessage = PreferRaiseMessage;
|
|
101435
|
+
//# sourceMappingURL=prefer_raise_message.js.map
|
|
101436
|
+
|
|
101437
|
+
/***/ },
|
|
101438
|
+
|
|
101307
101439
|
/***/ "../core/build/src/rules/prefer_returning_to_exporting.js"
|
|
101308
101440
|
/*!****************************************************************!*\
|
|
101309
101441
|
!*** ../core/build/src/rules/prefer_returning_to_exporting.js ***!
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/cli",
|
|
3
|
-
"version": "2.120.
|
|
3
|
+
"version": "2.120.85",
|
|
4
4
|
"description": "abaplint - Command Line Interface",
|
|
5
5
|
"funding": "https://github.com/sponsors/larshp",
|
|
6
6
|
"bin": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"homepage": "https://abaplint.org",
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@abaplint/core": "^2.120.
|
|
42
|
+
"@abaplint/core": "^2.120.85",
|
|
43
43
|
"@types/chai": "^4.3.20",
|
|
44
44
|
"@types/minimist": "^1.2.5",
|
|
45
45
|
"@types/mocha": "^10.0.10",
|