@abaplint/core 2.108.0 → 2.108.2
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
|
@@ -6,6 +6,8 @@ const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
|
6
6
|
const _irule_1 = require("./_irule");
|
|
7
7
|
const issue_1 = require("../issue");
|
|
8
8
|
const _statement_1 = require("../abap/2_statements/statements/_statement");
|
|
9
|
+
const position_1 = require("../position");
|
|
10
|
+
const edit_helper_1 = require("../edit_helper");
|
|
9
11
|
class AlignPseudoCommentsConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
10
12
|
}
|
|
11
13
|
exports.AlignPseudoCommentsConf = AlignPseudoCommentsConf;
|
|
@@ -19,7 +21,7 @@ class AlignPseudoComments extends _abap_rule_1.ABAPRule {
|
|
|
19
21
|
key: "align_pseudo_comments",
|
|
20
22
|
title: "Align pseudo comments",
|
|
21
23
|
shortDescription: `Align code inspector pseudo comments in statements`,
|
|
22
|
-
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Whitespace],
|
|
24
|
+
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Quickfix],
|
|
23
25
|
badExample: `WRITE 'sdf'. "#EC sdf`,
|
|
24
26
|
goodExample: `WRITE 'sdf'. "#EC sdf`,
|
|
25
27
|
};
|
|
@@ -46,16 +48,22 @@ class AlignPseudoComments extends _abap_rule_1.ABAPRule {
|
|
|
46
48
|
else if (previousEnd === undefined) {
|
|
47
49
|
continue;
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const message = "Align pseudo comment to column " + expectedColumn;
|
|
53
|
-
issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
|
|
54
|
-
}
|
|
51
|
+
let expectedColumn = 61;
|
|
52
|
+
if (commentLength > 10) {
|
|
53
|
+
expectedColumn = 72 - commentLength;
|
|
55
54
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
const col = firstCommentToken.getStart().getCol();
|
|
56
|
+
if (previousEnd.getCol() < expectedColumn && col !== expectedColumn) {
|
|
57
|
+
let fix = undefined;
|
|
58
|
+
if (col < expectedColumn) {
|
|
59
|
+
fix = edit_helper_1.EditHelper.insertAt(file, firstCommentToken.getStart(), " ".repeat(expectedColumn - col));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const from = new position_1.Position(firstCommentToken.getStart().getRow(), expectedColumn);
|
|
63
|
+
fix = edit_helper_1.EditHelper.deleteRange(file, from, firstCommentToken.getStart());
|
|
64
|
+
}
|
|
65
|
+
const message = "Align pseudo comment to column " + expectedColumn;
|
|
66
|
+
issues.push(issue_1.Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity, fix));
|
|
59
67
|
}
|
|
60
68
|
}
|
|
61
69
|
return issues;
|
|
@@ -12,6 +12,8 @@ class EmptyStructureConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
|
12
12
|
super(...arguments);
|
|
13
13
|
/** Checks for empty LOOP blocks */
|
|
14
14
|
this.loop = true;
|
|
15
|
+
/** Allow empty LOOP if subrc is checked after the loop */
|
|
16
|
+
this.loopAllowIfSubrc = true;
|
|
15
17
|
/** Checks for empty IF blocks */
|
|
16
18
|
this.if = true;
|
|
17
19
|
/** Checks for empty WHILE blocks */
|
|
@@ -44,6 +46,14 @@ class EmptyStructure extends _abap_rule_1.ABAPRule {
|
|
|
44
46
|
shortDescription: `Checks that the code does not contain empty blocks.`,
|
|
45
47
|
extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#no-empty-if-branches`,
|
|
46
48
|
tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
|
|
49
|
+
badExample: `IF foo = bar.
|
|
50
|
+
ENDIF.
|
|
51
|
+
|
|
52
|
+
DO 2 TIMES.
|
|
53
|
+
ENDDO.`,
|
|
54
|
+
goodExample: `LOOP AT itab WHERE qty = 0 OR date > sy-datum.
|
|
55
|
+
ENDLOOP.
|
|
56
|
+
result = xsdbool( sy-subrc = 0 ).`,
|
|
47
57
|
};
|
|
48
58
|
}
|
|
49
59
|
getDescription(name) {
|
|
@@ -61,15 +71,13 @@ class EmptyStructure extends _abap_rule_1.ABAPRule {
|
|
|
61
71
|
if (stru === undefined) {
|
|
62
72
|
return [];
|
|
63
73
|
}
|
|
64
|
-
|
|
74
|
+
const statements = file.getStatements();
|
|
75
|
+
for (const statement of statements) {
|
|
65
76
|
if (statement.get() instanceof _statement_1.Unknown) {
|
|
66
77
|
return []; // contains parser errors
|
|
67
78
|
}
|
|
68
79
|
}
|
|
69
80
|
const candidates = [];
|
|
70
|
-
if (this.getConfig().loop === true) {
|
|
71
|
-
candidates.push(...stru.findAllStructuresRecursive(Structures.Loop));
|
|
72
|
-
}
|
|
73
81
|
if (this.getConfig().while === true) {
|
|
74
82
|
candidates.push(...stru.findAllStructuresRecursive(Structures.While));
|
|
75
83
|
}
|
|
@@ -105,6 +113,22 @@ class EmptyStructure extends _abap_rule_1.ABAPRule {
|
|
|
105
113
|
}
|
|
106
114
|
}
|
|
107
115
|
}
|
|
116
|
+
if (this.getConfig().loop === true) {
|
|
117
|
+
const loops = stru.findAllStructuresRecursive(Structures.Loop);
|
|
118
|
+
for (const loop of loops) {
|
|
119
|
+
if (loop.getChildren().length === 2) {
|
|
120
|
+
const endloopStatement = loop.getLastChild();
|
|
121
|
+
const endloopIndex = statements.findIndex((s) => s === endloopStatement);
|
|
122
|
+
const afterEndloop = statements[endloopIndex + 1];
|
|
123
|
+
if (afterEndloop !== undefined && afterEndloop.concatTokens().toUpperCase().includes("SY-SUBRC")) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const token = loop.getFirstToken();
|
|
127
|
+
const issue = issue_1.Issue.atToken(file, token, this.getDescription(loop.get().constructor.name), this.getMetadata().key, this.conf.severity);
|
|
128
|
+
issues.push(issue);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
108
132
|
if (this.getConfig().if === true) {
|
|
109
133
|
const tries = stru.findAllStructuresRecursive(Structures.If)
|
|
110
134
|
.concat(stru.findAllStructuresRecursive(Structures.Else))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.108.
|
|
3
|
+
"version": "2.108.2",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
},
|
|
51
51
|
"homepage": "https://abaplint.org",
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@microsoft/api-extractor": "^7.43.
|
|
53
|
+
"@microsoft/api-extractor": "^7.43.3",
|
|
54
54
|
"@types/chai": "^4.3.16",
|
|
55
55
|
"@types/mocha": "^10.0.6",
|
|
56
|
-
"@types/node": "^20.12.
|
|
56
|
+
"@types/node": "^20.12.11",
|
|
57
57
|
"chai": "^4.4.1",
|
|
58
58
|
"eslint": "^8.57.0",
|
|
59
59
|
"mocha": "^10.4.0",
|