@abaplint/core 2.120.85 → 2.120.87
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 +13 -1
- package/build/src/abap/5_syntax/statements/insert_internal.js +4 -0
- package/build/src/registry.js +1 -1
- package/build/src/rules/abapdoc_shorttext_length.js +88 -0
- package/build/src/rules/align_type_expressions.js +11 -4
- package/build/src/rules/avoid_use.js +22 -2
- package/build/src/rules/downport.js +45 -0
- 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
|
}
|
|
@@ -52,6 +52,7 @@ const expressions_1 = require("../2_statements/expressions");
|
|
|
52
52
|
const _builtin_1 = require("./_builtin");
|
|
53
53
|
const position_1 = require("../../position");
|
|
54
54
|
const _syntax_input_1 = require("./_syntax_input");
|
|
55
|
+
const version_1 = require("../../version");
|
|
55
56
|
class BasicTypes {
|
|
56
57
|
constructor(input) {
|
|
57
58
|
this.input = input;
|
|
@@ -277,7 +278,14 @@ class BasicTypes {
|
|
|
277
278
|
}
|
|
278
279
|
const chainText = typeName.concatTokens().toUpperCase();
|
|
279
280
|
const f = this.input.scope.getDDIC().lookupBuiltinType(chainText, length, decimals, qualifiedName);
|
|
280
|
-
if (f
|
|
281
|
+
if (f instanceof Types.Integer8Type
|
|
282
|
+
&& !(0, version_1.releaseAtLeast)(this.input.scope.getRelease(), version_1.Release.v750)
|
|
283
|
+
&& !this.input.scope.getOpenABAP()) {
|
|
284
|
+
const message = "Type INT8 requires 7.50";
|
|
285
|
+
this.input.issues.push((0, _syntax_input_1.syntaxIssue)(this.input, typeName.getFirstToken(), message));
|
|
286
|
+
return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
|
|
287
|
+
}
|
|
288
|
+
else if (f !== undefined) {
|
|
281
289
|
return f;
|
|
282
290
|
}
|
|
283
291
|
const typ = this.input.scope.findType(chainText);
|
|
@@ -1071,6 +1079,10 @@ class BasicTypes {
|
|
|
1071
1079
|
this.input.issues.push((0, _syntax_input_1.syntaxIssue)(this.input, chain.getFirstToken(), message));
|
|
1072
1080
|
return undefined;
|
|
1073
1081
|
}
|
|
1082
|
+
else if (concat === "SY-REPID" || concat === "SYST-REPID") {
|
|
1083
|
+
// predefined constant in every program, not a SYST component
|
|
1084
|
+
return undefined;
|
|
1085
|
+
}
|
|
1074
1086
|
return this.resolveConstantValue(chain);
|
|
1075
1087
|
}
|
|
1076
1088
|
throw new Error("findValue, unexpected");
|
|
@@ -96,6 +96,10 @@ class InsertInternal {
|
|
|
96
96
|
if (sourceType instanceof basic_1.IntegerType && targetType instanceof basic_1.Integer8Type) {
|
|
97
97
|
error = true;
|
|
98
98
|
}
|
|
99
|
+
else if (targetType instanceof basic_1.TableType && targetType.isWithHeader() && sourceType instanceof basic_1.TableType) {
|
|
100
|
+
// LINES OF into a table with header line, compare the row types
|
|
101
|
+
error = new _type_utils_1.TypeUtils(input.scope).isAssignable(sourceType.getRowType(), targetType.getRowType()) === false;
|
|
102
|
+
}
|
|
99
103
|
else if (new _type_utils_1.TypeUtils(input.scope).isAssignable(sourceType, targetType) === false) {
|
|
100
104
|
error = true;
|
|
101
105
|
}
|
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
|
|
@@ -45,6 +45,7 @@ const Expressions = __importStar(require("../abap/2_statements/expressions"));
|
|
|
45
45
|
const Statements = __importStar(require("../abap/2_statements/statements"));
|
|
46
46
|
const Structures = __importStar(require("../abap/3_structures/structures"));
|
|
47
47
|
const edit_helper_1 = require("../edit_helper");
|
|
48
|
+
const tokens_1 = require("../abap/1_lexer/tokens");
|
|
48
49
|
class AlignTypeExpressionsConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
49
50
|
constructor() {
|
|
50
51
|
super(...arguments);
|
|
@@ -212,12 +213,18 @@ ENDINTERFACE.`,
|
|
|
212
213
|
let column = 0;
|
|
213
214
|
const st = t.findDirectStatements(Statements.Type);
|
|
214
215
|
for (const s of st) {
|
|
215
|
-
const
|
|
216
|
+
const children = s.getChildren();
|
|
217
|
+
const length = s.findDirectExpression(Expressions.ConstantFieldLength);
|
|
218
|
+
const nameEnd = (length !== null && length !== void 0 ? length : children[1]).getLastToken().getEnd();
|
|
219
|
+
const after = children[length ? 3 : 2];
|
|
220
|
+
if (after === undefined || after.getFirstToken() instanceof tokens_1.Punctuation) {
|
|
221
|
+
continue; // no TYPE clause, eg. "foo(1)," with implicit type
|
|
222
|
+
}
|
|
216
223
|
fields.push({
|
|
217
|
-
nameEnd:
|
|
218
|
-
after:
|
|
224
|
+
nameEnd: nameEnd,
|
|
225
|
+
after: after.getFirstToken().getStart()
|
|
219
226
|
});
|
|
220
|
-
column = Math.max(column,
|
|
227
|
+
column = Math.max(column, nameEnd.getCol() + 1);
|
|
221
228
|
}
|
|
222
229
|
issues.push(...this.check(fields, column, file));
|
|
223
230
|
}
|
|
@@ -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) {
|
|
@@ -331,6 +331,17 @@ Make sure to test the downported code, it might not always be completely correct
|
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
|
+
// INSERT with a 702 built-in function as the operand parses in the low version, but 702
|
|
335
|
+
// reads the function as a method call, "Method SUBSTRING does not exist"
|
|
336
|
+
if (ret.length === 0) {
|
|
337
|
+
for (let i = 0; i < lowStatements.length; i++) {
|
|
338
|
+
const issue = this.outlineInsertBuiltin(lowStatements[i], highStatements[i], lowFile, highSyntax);
|
|
339
|
+
if (issue) {
|
|
340
|
+
ret.push(issue);
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
334
345
|
// INTO after WHERE parses as a valid SELECT in the low version, but is only allowed in
|
|
335
346
|
// strict SQL syntax, so move it also when the statement is no longer Unknown
|
|
336
347
|
if (ret.length === 0) {
|
|
@@ -1163,6 +1174,40 @@ ${indentation}`);
|
|
|
1163
1174
|
}
|
|
1164
1175
|
return undefined;
|
|
1165
1176
|
}
|
|
1177
|
+
/** INSERT substring( ... ) INTO TABLE tab, the operand is outlined into a variable */
|
|
1178
|
+
outlineInsertBuiltin(low, high, lowFile, highSyntax) {
|
|
1179
|
+
var _a;
|
|
1180
|
+
if (!(high.get() instanceof Statements.InsertInternal)) {
|
|
1181
|
+
return undefined;
|
|
1182
|
+
}
|
|
1183
|
+
else if (this.lowReg.getConfig().isOpenABAP()) {
|
|
1184
|
+
return undefined;
|
|
1185
|
+
}
|
|
1186
|
+
else if (low.getFirstToken().getStart() instanceof virtual_position_1.VirtualPosition) {
|
|
1187
|
+
return undefined;
|
|
1188
|
+
}
|
|
1189
|
+
// the whole operand is the call, a longer expression is outlined by replaceInsertExpression
|
|
1190
|
+
const source = high.getChildren()[1];
|
|
1191
|
+
if (!(source instanceof nodes_1.ExpressionNode)
|
|
1192
|
+
|| !(source.get() instanceof Expressions.SimpleSource4 || source.get() instanceof Expressions.Source)
|
|
1193
|
+
|| source.getChildren().length !== 1
|
|
1194
|
+
|| !(((_a = source.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.MethodCallChain)) {
|
|
1195
|
+
return undefined;
|
|
1196
|
+
}
|
|
1197
|
+
const type = this.builtinReturnType(source, lowFile, highSyntax);
|
|
1198
|
+
if (type === undefined) {
|
|
1199
|
+
return undefined;
|
|
1200
|
+
}
|
|
1201
|
+
const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
1202
|
+
const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
|
|
1203
|
+
const code = `DATA ${uniqueName} TYPE ${type}.\n` +
|
|
1204
|
+
indentation + `${uniqueName} = ${source.concatTokens()}.\n` +
|
|
1205
|
+
indentation;
|
|
1206
|
+
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, high.getFirstToken().getStart(), code);
|
|
1207
|
+
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, source.getFirstToken().getStart(), source.getLastToken().getEnd(), uniqueName);
|
|
1208
|
+
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
1209
|
+
return issue_1.Issue.atToken(lowFile, source.getFirstToken(), "Outline built-in function in INSERT", this.getMetadata().key, this.conf.severity, fix);
|
|
1210
|
+
}
|
|
1166
1211
|
/** the ABAP type returned by the built-in function this Source starts with, or undefined
|
|
1167
1212
|
* if it does not start with one, or with one that predates 702 */
|
|
1168
1213
|
builtinReturnType(source, lowFile, highSyntax) {
|
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
|
}
|