@abaplint/core 2.120.72 → 2.120.73
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/src/registry.js
CHANGED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GenericRegex = exports.GenericRegexConf = void 0;
|
|
4
|
+
const issue_1 = require("../issue");
|
|
5
|
+
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
6
|
+
const _irule_1 = require("./_irule");
|
|
7
|
+
class GenericRegexConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
/** List of forbidden regular expressions, case insensitive, checked against each line of every file.
|
|
11
|
+
* Patterns use JavaScript regex syntax without enclosing slashes or flags.
|
|
12
|
+
* @uniqueItems true
|
|
13
|
+
*/
|
|
14
|
+
this.regexes = [];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.GenericRegexConf = GenericRegexConf;
|
|
18
|
+
class GenericRegex {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.conf = new GenericRegexConf();
|
|
21
|
+
this.regexes = [];
|
|
22
|
+
}
|
|
23
|
+
getMetadata() {
|
|
24
|
+
return {
|
|
25
|
+
key: "generic_regex",
|
|
26
|
+
title: "Generic regex",
|
|
27
|
+
shortDescription: "Report an issue for each match of a configured regular expression.",
|
|
28
|
+
extendedInformation: `Checks each line of every object file, including comments, strings, and XML.
|
|
29
|
+
Patterns use JavaScript regular expression syntax without enclosing slashes or flags.
|
|
30
|
+
Matching is case insensitive and does not span multiple lines. Each non-overlapping match is reported.
|
|
31
|
+
Use the standard exclude configuration to skip files.
|
|
32
|
+
|
|
33
|
+
Example configuration: \`{"generic_regex": {"regexes": ["TODO", "BREAK-POINT"]}}\``,
|
|
34
|
+
tags: [_irule_1.RuleTag.SingleFile],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
getConfig() {
|
|
38
|
+
return this.conf;
|
|
39
|
+
}
|
|
40
|
+
setConfig(conf) {
|
|
41
|
+
var _a;
|
|
42
|
+
this.conf = Object.assign(new GenericRegexConf(), conf);
|
|
43
|
+
this.conf.regexes = (_a = this.conf.regexes) !== null && _a !== void 0 ? _a : [];
|
|
44
|
+
}
|
|
45
|
+
initialize(_reg) {
|
|
46
|
+
this.regexes = this.conf.regexes.map(pattern => {
|
|
47
|
+
try {
|
|
48
|
+
return new RegExp(pattern, "gi");
|
|
49
|
+
}
|
|
50
|
+
catch (_a) {
|
|
51
|
+
throw new Error(`generic_regex: Invalid regular expression "${pattern}"`);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
run(obj) {
|
|
57
|
+
const issues = [];
|
|
58
|
+
if (this.regexes.length === 0) {
|
|
59
|
+
return issues;
|
|
60
|
+
}
|
|
61
|
+
for (const file of obj.getFiles()) {
|
|
62
|
+
const rows = file.getRawRows();
|
|
63
|
+
for (let row = 0; row < rows.length; row++) {
|
|
64
|
+
const text = rows[row].replace(/\r$/, "");
|
|
65
|
+
for (const regex of this.regexes) {
|
|
66
|
+
regex.lastIndex = 0;
|
|
67
|
+
for (;;) {
|
|
68
|
+
const match = regex.exec(text);
|
|
69
|
+
if (match === null) {
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
const startCol = match.index + 1;
|
|
73
|
+
const message = `Text matches forbidden regular expression "${regex.source}"`;
|
|
74
|
+
issues.push(issue_1.Issue.atRowRange(file, row + 1, startCol, startCol + match[0].length, message, this.getMetadata().key, this.conf.severity));
|
|
75
|
+
if (match[0].length === 0) {
|
|
76
|
+
regex.lastIndex++;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return issues;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.GenericRegex = GenericRegex;
|
|
86
|
+
//# sourceMappingURL=generic_regex.js.map
|
package/build/src/rules/index.js
CHANGED
|
@@ -82,6 +82,7 @@ __exportStar(require("./fully_type_constants"), exports);
|
|
|
82
82
|
__exportStar(require("./fully_type_itabs"), exports);
|
|
83
83
|
__exportStar(require("./function_module_recommendations"), exports);
|
|
84
84
|
__exportStar(require("./functional_writing"), exports);
|
|
85
|
+
__exportStar(require("./generic_regex"), exports);
|
|
85
86
|
__exportStar(require("./global_class"), exports);
|
|
86
87
|
__exportStar(require("./identical_conditions"), exports);
|
|
87
88
|
__exportStar(require("./identical_contents"), exports);
|