@abaplint/core 2.120.85 → 2.120.86
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/abap/2_statements/statements/submit.js +5 -1
- package/build/src/abap/5_syntax/basic_types.js +4 -0
- package/build/src/registry.js +1 -1
- package/build/src/rules/abapdoc_shorttext_length.js +88 -0
- package/build/src/rules/avoid_use.js +22 -2
- package/build/src/rules/index.js +1 -0
- package/build/src/rules/prefer_raise_message.js +5 -5
- package/package.json +1 -1
|
@@ -33,11 +33,15 @@ class Submit {
|
|
|
33
33
|
const datasetExpiration = (0, combi_1.seq)("DATASET EXPIRATION", expressions_1.Source);
|
|
34
34
|
const coverText = (0, combi_1.seq)("COVER TEXT", expressions_1.Source);
|
|
35
35
|
const listName = (0, combi_1.seq)("LIST NAME", expressions_1.Source);
|
|
36
|
+
const listDataset = (0, combi_1.seq)("LIST DATASET", expressions_1.Source);
|
|
37
|
+
const listAuthority = (0, combi_1.seq)("LIST AUTHORITY", expressions_1.Source);
|
|
38
|
+
const coverPage = (0, combi_1.seq)("COVER PAGE", expressions_1.Source);
|
|
39
|
+
const department = (0, combi_1.seq)("DEPARTMENT", expressions_1.Source);
|
|
36
40
|
const keep = (0, combi_1.seq)("KEEP IN SPOOL", expressions_1.Source);
|
|
37
41
|
const imm = (0, combi_1.seq)("IMMEDIATELY", expressions_1.Source);
|
|
38
42
|
const dest = (0, combi_1.seq)("DESTINATION", expressions_1.Source);
|
|
39
43
|
const language = (0, combi_1.seq)("LANGUAGE", expressions_1.Source);
|
|
40
|
-
const perm = (0, combi_1.per)((0, combi_1.plusPrio)(awith), selectionTable, (0, combi_1.plusPrio)(awith), (0, combi_1.plusPrio)(awith), spool, lineSize, lineCount, archive, archiveMode, receiver, user, sset, ssetp, keep, cover, imm, layout, dest, coverText, listName, language, free, newList, uss, copies, datasetExpiration, "TO SAP-SPOOL", "WITHOUT SPOOL DYNPRO", "VIA SELECTION-SCREEN", exporting, expressions_1.AndReturn, job);
|
|
44
|
+
const perm = (0, combi_1.per)((0, combi_1.plusPrio)(awith), selectionTable, (0, combi_1.plusPrio)(awith), (0, combi_1.plusPrio)(awith), spool, lineSize, lineCount, archive, archiveMode, receiver, user, sset, ssetp, keep, cover, imm, layout, dest, coverText, listName, listDataset, listAuthority, coverPage, department, language, free, newList, uss, copies, datasetExpiration, "TO SAP-SPOOL", "WITHOUT SPOOL DYNPRO", "VIA SELECTION-SCREEN", exporting, expressions_1.AndReturn, job);
|
|
41
45
|
const ret = (0, combi_1.seq)("SUBMIT", prog, (0, combi_1.opt)(perm));
|
|
42
46
|
return (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, ret);
|
|
43
47
|
}
|
|
@@ -1071,6 +1071,10 @@ class BasicTypes {
|
|
|
1071
1071
|
this.input.issues.push((0, _syntax_input_1.syntaxIssue)(this.input, chain.getFirstToken(), message));
|
|
1072
1072
|
return undefined;
|
|
1073
1073
|
}
|
|
1074
|
+
else if (concat === "SY-REPID" || concat === "SYST-REPID") {
|
|
1075
|
+
// predefined constant in every program, not a SYST component
|
|
1076
|
+
return undefined;
|
|
1077
|
+
}
|
|
1074
1078
|
return this.resolveConstantValue(chain);
|
|
1075
1079
|
}
|
|
1076
1080
|
throw new Error("findValue, unexpected");
|
package/build/src/registry.js
CHANGED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbapdocShorttextLength = exports.AbapdocShorttextLengthConf = void 0;
|
|
4
|
+
const issue_1 = require("../issue");
|
|
5
|
+
const _abap_rule_1 = require("./_abap_rule");
|
|
6
|
+
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
7
|
+
const _irule_1 = require("./_irule");
|
|
8
|
+
const _statement_1 = require("../abap/2_statements/statements/_statement");
|
|
9
|
+
class AbapdocShorttextLengthConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
10
|
+
}
|
|
11
|
+
exports.AbapdocShorttextLengthConf = AbapdocShorttextLengthConf;
|
|
12
|
+
const MAX_LENGTH = 60;
|
|
13
|
+
class AbapdocShorttextLength extends _abap_rule_1.ABAPRule {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.conf = new AbapdocShorttextLengthConf();
|
|
17
|
+
}
|
|
18
|
+
getMetadata() {
|
|
19
|
+
return {
|
|
20
|
+
key: "abapdoc_shorttext_length",
|
|
21
|
+
title: "ABAP Doc shorttext too long",
|
|
22
|
+
shortDescription: `Reports ABAP Doc shorttexts longer than 60 characters.`,
|
|
23
|
+
extendedInformation: `A shorttext is written as <p class="shorttext">...</p> or
|
|
24
|
+
<p class="shorttext synchronized">...</p>, the system warns "Shorttext must not exceed 60 characters."
|
|
25
|
+
if the text is longer.
|
|
26
|
+
|
|
27
|
+
The text may span several "! lines, line breaks count as one blank. Leading and trailing blanks are not counted,
|
|
28
|
+
an entity like < counts as one character.`,
|
|
29
|
+
tags: [_irule_1.RuleTag.SingleFile],
|
|
30
|
+
badExample: `INTERFACE zif_foo PUBLIC.
|
|
31
|
+
"! <p class="shorttext synchronized">Returns the name of the selected row in the table of the view</p>
|
|
32
|
+
METHODS name RETURNING VALUE(result) TYPE string.
|
|
33
|
+
ENDINTERFACE.`,
|
|
34
|
+
goodExample: `INTERFACE zif_foo PUBLIC.
|
|
35
|
+
"! <p class="shorttext synchronized">Returns the name of the selected row</p>
|
|
36
|
+
METHODS name RETURNING VALUE(result) TYPE string.
|
|
37
|
+
ENDINTERFACE.`,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
getConfig() {
|
|
41
|
+
return this.conf;
|
|
42
|
+
}
|
|
43
|
+
setConfig(conf) {
|
|
44
|
+
this.conf = conf;
|
|
45
|
+
}
|
|
46
|
+
runParsed(file) {
|
|
47
|
+
const issues = [];
|
|
48
|
+
let block = [];
|
|
49
|
+
for (const statement of file.getStatements()) {
|
|
50
|
+
const token = statement.getFirstToken();
|
|
51
|
+
const doc = statement.get() instanceof _statement_1.Comment && token.getStr().startsWith(`"!`);
|
|
52
|
+
const previous = block[block.length - 1];
|
|
53
|
+
if (doc === false || (previous !== undefined && token.getStart().getRow() !== previous.getStart().getRow() + 1)) {
|
|
54
|
+
issues.push(...this.checkBlock(file, block));
|
|
55
|
+
block = [];
|
|
56
|
+
}
|
|
57
|
+
if (doc === true) {
|
|
58
|
+
block.push(token);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
issues.push(...this.checkBlock(file, block));
|
|
62
|
+
return issues;
|
|
63
|
+
}
|
|
64
|
+
checkBlock(file, block) {
|
|
65
|
+
const issues = [];
|
|
66
|
+
if (block.length === 0) {
|
|
67
|
+
return issues;
|
|
68
|
+
}
|
|
69
|
+
const text = block.map(t => t.getStr().substring(2)).join("\n");
|
|
70
|
+
const regex = /<p\s[^>]*class\s*=\s*"shorttext(?:\s+synchronized)?"[^>]*>([\s\S]*?)<\/p>/gi;
|
|
71
|
+
let match;
|
|
72
|
+
while ((match = regex.exec(text)) !== null) {
|
|
73
|
+
const length = this.decode(match[1].replace(/\s+/g, " ").trim()).length;
|
|
74
|
+
if (length <= MAX_LENGTH) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const token = block[text.substring(0, match.index).split("\n").length - 1];
|
|
78
|
+
const message = `Shorttext must not exceed ${MAX_LENGTH} characters, found ${length}`;
|
|
79
|
+
issues.push(issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity));
|
|
80
|
+
}
|
|
81
|
+
return issues;
|
|
82
|
+
}
|
|
83
|
+
decode(text) {
|
|
84
|
+
return text.replace(/&(#\d+|#x[0-9a-fA-F]+|[a-zA-Z]+);/g, "_");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.AbapdocShorttextLength = AbapdocShorttextLength;
|
|
88
|
+
//# sourceMappingURL=abapdoc_shorttext_length.js.map
|
|
@@ -89,8 +89,28 @@ TEST-SEAMS: https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md
|
|
|
89
89
|
|
|
90
90
|
BREAK points`,
|
|
91
91
|
tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
|
|
92
|
-
badExample: `
|
|
93
|
-
|
|
92
|
+
badExample: `DEFINE _hello.
|
|
93
|
+
WRITE 'hello'.
|
|
94
|
+
END-OF-DEFINITION.
|
|
95
|
+
|
|
96
|
+
STATICS count TYPE i.
|
|
97
|
+
|
|
98
|
+
TYPES ty_items TYPE STANDARD TABLE OF i WITH DEFAULT KEY.
|
|
99
|
+
|
|
100
|
+
BREAK-POINT.
|
|
101
|
+
|
|
102
|
+
TEST-SEAM seam_name.
|
|
103
|
+
count = 1.
|
|
104
|
+
END-TEST-SEAM.
|
|
105
|
+
|
|
106
|
+
DESCRIBE TABLE items LINES count.
|
|
107
|
+
|
|
108
|
+
EXPORT data = items TO MEMORY ID 'ZFOO'.
|
|
109
|
+
|
|
110
|
+
EXPORT data = items TO DATABASE indx(zz) ID 'ZFOO'.`,
|
|
111
|
+
goodExample: `count = lines( items ).
|
|
112
|
+
|
|
113
|
+
TYPES ty_items TYPE STANDARD TABLE OF i WITH EMPTY KEY.`,
|
|
94
114
|
};
|
|
95
115
|
}
|
|
96
116
|
getDescription(statement) {
|
package/build/src/rules/index.js
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./abapdoc"), exports);
|
|
|
19
19
|
__exportStar(require("./abapdoc_html_tag"), exports);
|
|
20
20
|
__exportStar(require("./abapdoc_leading_at"), exports);
|
|
21
21
|
__exportStar(require("./abapdoc_parameter_names"), exports);
|
|
22
|
+
__exportStar(require("./abapdoc_shorttext_length"), exports);
|
|
22
23
|
__exportStar(require("./add_test_attributes"), exports);
|
|
23
24
|
__exportStar(require("./aff_and_xml"), exports);
|
|
24
25
|
__exportStar(require("./alias_never_reassigned"), exports);
|
|
@@ -57,8 +57,8 @@ class PreferRaiseMessage extends _abap_rule_1.ABAPRule {
|
|
|
57
57
|
return {
|
|
58
58
|
key: "prefer_raise_message",
|
|
59
59
|
title: "Prefer RAISE EXCEPTION with MESSAGE",
|
|
60
|
-
shortDescription: `Prefer RAISE EXCEPTION with MESSAGE instead of supplying parameter TEXT`,
|
|
61
|
-
extendedInformation: `Reports RAISE EXCEPTION statements where parameter TEXT is supplied.
|
|
60
|
+
shortDescription: `Prefer RAISE EXCEPTION with MESSAGE instead of supplying parameter TEXT or TEXTID`,
|
|
61
|
+
extendedInformation: `Reports RAISE EXCEPTION statements where parameter TEXT or TEXTID is supplied.
|
|
62
62
|
|
|
63
63
|
Use a message class instead, so the text is translatable and can be found via where-used.
|
|
64
64
|
|
|
@@ -105,9 +105,9 @@ Exception classes can be excluded via configuration "ignoreExceptionClasses".`,
|
|
|
105
105
|
if (className === undefined || ignore.includes(className.toUpperCase())) {
|
|
106
106
|
continue;
|
|
107
107
|
}
|
|
108
|
-
const
|
|
109
|
-
if (
|
|
110
|
-
const message = "Prefer RAISE EXCEPTION with MESSAGE, " + className + " raised with parameter
|
|
108
|
+
const name = parameters === null || parameters === void 0 ? void 0 : parameters.findDirectExpressions(Expressions.ParameterS).map(p => { var _a; return (_a = p.findDirectExpression(Expressions.ParameterName)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase(); }).find(n => n === "TEXT" || n === "TEXTID");
|
|
109
|
+
if (name) {
|
|
110
|
+
const message = "Prefer RAISE EXCEPTION with MESSAGE, " + className + " raised with parameter " + name;
|
|
111
111
|
issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
|
|
112
112
|
}
|
|
113
113
|
}
|