@abaplint/core 2.83.25 → 2.84.0
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
|
@@ -365,10 +365,14 @@ ${indentation}`);
|
|
|
365
365
|
}
|
|
366
366
|
const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
|
|
367
367
|
const name = ((_c = inlineData.findFirstExpression(Expressions.TargetField)) === null || _c === void 0 ? void 0 : _c.concatTokens()) || "error";
|
|
368
|
-
|
|
368
|
+
let fix1 = edit_helper_1.EditHelper.insertAt(lowFile, high.getStart(), `TYPES: BEGIN OF ${uniqueName},
|
|
369
369
|
${fieldDefinitions}${indentation} END OF ${uniqueName}.
|
|
370
370
|
${indentation}DATA ${name} TYPE STANDARD TABLE OF ${uniqueName} WITH DEFAULT KEY.
|
|
371
371
|
${indentation}`);
|
|
372
|
+
if (fieldDefinitions === "") {
|
|
373
|
+
fix1 = edit_helper_1.EditHelper.insertAt(lowFile, high.getStart(), `DATA ${name} TYPE STANDARD TABLE OF ${tableName} WITH DEFAULT KEY.
|
|
374
|
+
${indentation}`);
|
|
375
|
+
}
|
|
372
376
|
const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, inlineData.getFirstToken().getStart(), inlineData.getLastToken().getEnd(), name);
|
|
373
377
|
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
374
378
|
return issue_1.Issue.atToken(lowFile, inlineData.getFirstToken(), "Outline SELECT @DATA", this.getMetadata().key, this.conf.severity, fix);
|
package/build/src/rules/index.js
CHANGED
|
@@ -100,6 +100,7 @@ __exportStar(require("./no_yoda_conditions"), exports);
|
|
|
100
100
|
__exportStar(require("./object_naming"), exports);
|
|
101
101
|
__exportStar(require("./obsolete_statement"), exports);
|
|
102
102
|
__exportStar(require("./omit_parameter_name"), exports);
|
|
103
|
+
__exportStar(require("./omit_preceding_zeros"), exports);
|
|
103
104
|
__exportStar(require("./omit_receiving"), exports);
|
|
104
105
|
__exportStar(require("./parser_702_chaining"), exports);
|
|
105
106
|
__exportStar(require("./parser_error"), exports);
|
|
@@ -38,13 +38,13 @@ class MethodLength {
|
|
|
38
38
|
tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
getDescription(issueType, actual) {
|
|
41
|
+
getDescription(issueType, actual, type) {
|
|
42
42
|
switch (issueType) {
|
|
43
43
|
case IssueType.EmptyMethod: {
|
|
44
|
-
return "Empty
|
|
44
|
+
return "Empty " + type;
|
|
45
45
|
}
|
|
46
46
|
case IssueType.MaxStatements: {
|
|
47
|
-
return "Reduce
|
|
47
|
+
return "Reduce " + type + " length to max " + this.conf.statements + " statements, currently " + actual;
|
|
48
48
|
}
|
|
49
49
|
default: {
|
|
50
50
|
return "";
|
|
@@ -62,15 +62,16 @@ class MethodLength {
|
|
|
62
62
|
}
|
|
63
63
|
run(obj) {
|
|
64
64
|
const methodStats = method_length_stats_1.MethodLengthStats.run(obj);
|
|
65
|
-
const methodIssues = this.check(methodStats);
|
|
65
|
+
const methodIssues = this.check(methodStats, "METHOD");
|
|
66
66
|
let formIssues = [];
|
|
67
67
|
if (this.conf.checkForms) {
|
|
68
68
|
const formStats = form_length_stats_1.FormLengthStats.run(obj);
|
|
69
|
-
formIssues = this.check(formStats);
|
|
69
|
+
formIssues = this.check(formStats, "FORM");
|
|
70
70
|
}
|
|
71
71
|
return methodIssues.concat(formIssues);
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
// ***********************
|
|
74
|
+
check(stats, type) {
|
|
74
75
|
const issues = [];
|
|
75
76
|
for (const s of stats) {
|
|
76
77
|
if ((this.conf.ignoreTestClasses === true)
|
|
@@ -78,12 +79,12 @@ class MethodLength {
|
|
|
78
79
|
continue;
|
|
79
80
|
}
|
|
80
81
|
if (s.count === 0 && this.conf.errorWhenEmpty === true) {
|
|
81
|
-
const issue = issue_1.Issue.atPosition(s.file, s.pos, this.getDescription(IssueType.EmptyMethod, "0"), this.getMetadata().key, this.conf.severity);
|
|
82
|
+
const issue = issue_1.Issue.atPosition(s.file, s.pos, this.getDescription(IssueType.EmptyMethod, "0", type), this.getMetadata().key, this.conf.severity);
|
|
82
83
|
issues.push(issue);
|
|
83
84
|
continue;
|
|
84
85
|
}
|
|
85
86
|
if (s.count > this.conf.statements) {
|
|
86
|
-
const message = this.getDescription(IssueType.MaxStatements, s.count.toString());
|
|
87
|
+
const message = this.getDescription(IssueType.MaxStatements, s.count.toString(), type);
|
|
87
88
|
const issue = issue_1.Issue.atPosition(s.file, s.pos, message, this.getMetadata().key, this.conf.severity);
|
|
88
89
|
issues.push(issue);
|
|
89
90
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OmitPrecedingZeros = exports.OmitPrecedingZerosConf = void 0;
|
|
4
|
+
const _abap_rule_1 = require("./_abap_rule");
|
|
5
|
+
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
6
|
+
const issue_1 = require("../issue");
|
|
7
|
+
const Expressions = require("../abap/2_statements/expressions");
|
|
8
|
+
const _irule_1 = require("./_irule");
|
|
9
|
+
class OmitPrecedingZerosConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
10
|
+
}
|
|
11
|
+
exports.OmitPrecedingZerosConf = OmitPrecedingZerosConf;
|
|
12
|
+
class OmitPrecedingZeros extends _abap_rule_1.ABAPRule {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.conf = new OmitPrecedingZerosConf();
|
|
16
|
+
}
|
|
17
|
+
getMetadata() {
|
|
18
|
+
return {
|
|
19
|
+
key: "omit_preceding_zeros",
|
|
20
|
+
title: "Omit preceding zeros",
|
|
21
|
+
shortDescription: `Omit preceding zeros from integer constants`,
|
|
22
|
+
tags: [_irule_1.RuleTag.SingleFile],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
getConfig() {
|
|
26
|
+
return this.conf;
|
|
27
|
+
}
|
|
28
|
+
setConfig(conf) {
|
|
29
|
+
this.conf = conf;
|
|
30
|
+
}
|
|
31
|
+
runParsed(file) {
|
|
32
|
+
var _a;
|
|
33
|
+
const issues = [];
|
|
34
|
+
for (const i of ((_a = file.getStructure()) === null || _a === void 0 ? void 0 : _a.findAllExpressions(Expressions.Integer)) || []) {
|
|
35
|
+
const token = i.getLastToken();
|
|
36
|
+
const str = token.getStr();
|
|
37
|
+
if (str.length > 1 && str.startsWith("0")) {
|
|
38
|
+
const message = "Omit preceding zeros";
|
|
39
|
+
const issue = issue_1.Issue.atToken(file, token, message, this.getMetadata().key, this.getConfig().severity);
|
|
40
|
+
issues.push(issue);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return issues;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.OmitPrecedingZeros = OmitPrecedingZeros;
|
|
47
|
+
//# sourceMappingURL=omit_preceding_zeros.js.map
|