@abaplint/core 2.103.10 → 2.104.1
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/abaplint.d.ts
CHANGED
|
@@ -5595,6 +5595,20 @@ declare class Skip implements IStatement {
|
|
|
5595
5595
|
getMatcher(): IStatementRunnable;
|
|
5596
5596
|
}
|
|
5597
5597
|
|
|
5598
|
+
export declare class SkipLogic {
|
|
5599
|
+
private readonly reg;
|
|
5600
|
+
/** TOBJ cache hashmap */
|
|
5601
|
+
private tobj;
|
|
5602
|
+
constructor(reg: IRegistry);
|
|
5603
|
+
skip(obj: IObject): boolean;
|
|
5604
|
+
private isGeneratedBOPFInterface;
|
|
5605
|
+
private isGeneratedProxyInterface;
|
|
5606
|
+
private isGeneratedProxyClass;
|
|
5607
|
+
private isGeneratedFunctionGroup;
|
|
5608
|
+
private isGeneratedGatewayClass;
|
|
5609
|
+
private isGeneratedPersistentClass;
|
|
5610
|
+
}
|
|
5611
|
+
|
|
5598
5612
|
declare class SmartForm extends AbstractObject {
|
|
5599
5613
|
getType(): string;
|
|
5600
5614
|
getAllowedNaming(): {
|
package/build/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.RuleTag = void 0;
|
|
3
|
+
exports.Visibility = exports.Info = exports.Rename = exports.PrettyPrinter = exports.Position = exports.CurrentScope = exports.ABAPFile = exports.RulesRunner = exports.SpaghettiScope = exports.SyntaxLogic = exports.ABAPObject = exports.Tokens = exports.ExpressionsCDS = exports.CDSParser = exports.LanguageServerTypes = exports.DDLParser = exports.applyEditList = exports.applyEditSingle = exports.SpaghettiScopeNode = exports.AbstractFile = exports.Token = exports.ScopeType = exports.BasicTypes = exports.TypedIdentifier = exports.AbstractType = exports.VirtualPosition = exports.Comment = exports.Unknown = exports.Empty = exports.Identifier = exports.Nodes = exports.Types = exports.Expressions = exports.Statements = exports.Structures = exports.SkipLogic = exports.Objects = exports.ArtifactsRules = exports.ArtifactsObjects = exports.ArtifactsABAP = exports.BuiltIn = exports.MethodLengthStats = exports.LanguageServer = exports.Registry = exports.CyclomaticComplexityStats = exports.ReferenceType = exports.Version = exports.Config = exports.Issue = exports.MemoryFile = void 0;
|
|
4
|
+
exports.RuleTag = exports.Severity = void 0;
|
|
5
5
|
const issue_1 = require("./issue");
|
|
6
6
|
Object.defineProperty(exports, "Issue", { enumerable: true, get: function () { return issue_1.Issue; } });
|
|
7
7
|
const config_1 = require("./config");
|
|
@@ -100,4 +100,6 @@ const _irule_1 = require("./rules/_irule");
|
|
|
100
100
|
Object.defineProperty(exports, "RuleTag", { enumerable: true, get: function () { return _irule_1.RuleTag; } });
|
|
101
101
|
const cyclomatic_complexity_stats_1 = require("./utils/cyclomatic_complexity_stats");
|
|
102
102
|
Object.defineProperty(exports, "CyclomaticComplexityStats", { enumerable: true, get: function () { return cyclomatic_complexity_stats_1.CyclomaticComplexityStats; } });
|
|
103
|
+
const skip_logic_1 = require("./skip_logic");
|
|
104
|
+
Object.defineProperty(exports, "SkipLogic", { enumerable: true, get: function () { return skip_logic_1.SkipLogic; } });
|
|
103
105
|
//# sourceMappingURL=index.js.map
|
package/build/src/registry.js
CHANGED
package/build/src/rules/index.js
CHANGED
|
@@ -129,6 +129,7 @@ __exportStar(require("./prefer_returning_to_exporting"), exports);
|
|
|
129
129
|
__exportStar(require("./prefer_xsdbool"), exports);
|
|
130
130
|
__exportStar(require("./preferred_compare_operator"), exports);
|
|
131
131
|
__exportStar(require("./prefix_is_current_class"), exports);
|
|
132
|
+
__exportStar(require("./reduce_procedural_code"), exports);
|
|
132
133
|
__exportStar(require("./reduce_string_templates"), exports);
|
|
133
134
|
__exportStar(require("./release_idoc"), exports);
|
|
134
135
|
__exportStar(require("./remove_descriptions"), exports);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReduceProceduralCode = exports.ReduceProceduralCodeConf = void 0;
|
|
4
|
+
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
5
|
+
const _abap_rule_1 = require("./_abap_rule");
|
|
6
|
+
const _irule_1 = require("./_irule");
|
|
7
|
+
const Statements = require("../abap/2_statements/statements");
|
|
8
|
+
const issue_1 = require("../issue");
|
|
9
|
+
class ReduceProceduralCodeConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.maxStatements = 10;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.ReduceProceduralCodeConf = ReduceProceduralCodeConf;
|
|
16
|
+
class ReduceProceduralCode extends _abap_rule_1.ABAPRule {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.conf = new ReduceProceduralCodeConf();
|
|
20
|
+
}
|
|
21
|
+
getMetadata() {
|
|
22
|
+
return {
|
|
23
|
+
key: "reduce_procedural_code",
|
|
24
|
+
title: "Reduce procedural code",
|
|
25
|
+
shortDescription: `Checks FORM and FUNCTION-MODULE have few statements`,
|
|
26
|
+
extendedInformation: `Delegate logic to a class method instead of using FORM or FUNCTION-MODULE.
|
|
27
|
+
|
|
28
|
+
https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-object-orientation-to-procedural-programming`,
|
|
29
|
+
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide],
|
|
30
|
+
badExample: `FORM foo.
|
|
31
|
+
DATA lv_bar TYPE i.
|
|
32
|
+
lv_bar = 2 + 2.
|
|
33
|
+
IF lv_bar = 4.
|
|
34
|
+
WRITE 'hello world'.
|
|
35
|
+
ENDIF.
|
|
36
|
+
DATA lv_bar TYPE i.
|
|
37
|
+
lv_bar = 2 + 2.
|
|
38
|
+
IF lv_bar = 4.
|
|
39
|
+
WRITE 'hello world'.
|
|
40
|
+
ENDIF.
|
|
41
|
+
ENDFORM.`,
|
|
42
|
+
goodExample: `FORM foo.
|
|
43
|
+
NEW zcl_global_class( )->run_logic( ).
|
|
44
|
+
ENDFORM.`,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
getConfig() {
|
|
48
|
+
return this.conf;
|
|
49
|
+
}
|
|
50
|
+
setConfig(conf) {
|
|
51
|
+
this.conf = conf;
|
|
52
|
+
}
|
|
53
|
+
runParsed(file) {
|
|
54
|
+
const issues = [];
|
|
55
|
+
if (file.getStructure() === undefined) {
|
|
56
|
+
// constains syntax errors, skip this check
|
|
57
|
+
return issues;
|
|
58
|
+
}
|
|
59
|
+
let doCount = undefined;
|
|
60
|
+
let count = 0;
|
|
61
|
+
for (const statement of file.getStatements()) {
|
|
62
|
+
if (statement.get() instanceof Statements.Form || statement.get() instanceof Statements.FunctionModule) {
|
|
63
|
+
doCount = statement;
|
|
64
|
+
count = 0;
|
|
65
|
+
}
|
|
66
|
+
else if (statement.get() instanceof Statements.EndForm || statement.get() instanceof Statements.EndFunction) {
|
|
67
|
+
if (count >= this.conf.maxStatements && doCount !== undefined) {
|
|
68
|
+
const message = "Reduce procedural code, max " + this.conf.maxStatements + " statements";
|
|
69
|
+
const issue = issue_1.Issue.atStatement(file, doCount, message, this.getMetadata().key, this.conf.severity);
|
|
70
|
+
issues.push(issue);
|
|
71
|
+
}
|
|
72
|
+
doCount = undefined;
|
|
73
|
+
}
|
|
74
|
+
else if (doCount !== undefined) {
|
|
75
|
+
count = count + 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return issues;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.ReduceProceduralCode = ReduceProceduralCode;
|
|
82
|
+
//# sourceMappingURL=reduce_procedural_code.js.map
|
|
@@ -147,6 +147,8 @@ DATA: BEGIN OF blah ##NEEDED,
|
|
|
147
147
|
&& !(statement.get() instanceof Statements.Parameter)
|
|
148
148
|
&& !(statement.get() instanceof Statements.Data)
|
|
149
149
|
&& !(statement.get() instanceof Statements.DataBegin)
|
|
150
|
+
&& !(statement.get() instanceof Statements.ClassData)
|
|
151
|
+
&& !(statement.get() instanceof Statements.ClassDataBegin)
|
|
150
152
|
&& !(statement.get() instanceof Statements.Type)
|
|
151
153
|
&& !(statement.get() instanceof Statements.Form)
|
|
152
154
|
&& !(statement.get() instanceof Statements.Tables)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.104.1",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@microsoft/api-extractor": "^7.38.3",
|
|
54
54
|
"@types/chai": "^4.3.11",
|
|
55
55
|
"@types/mocha": "^10.0.6",
|
|
56
|
-
"@types/node": "^20.10.
|
|
56
|
+
"@types/node": "^20.10.1",
|
|
57
57
|
"chai": "^4.3.10",
|
|
58
58
|
"eslint": "^8.54.0",
|
|
59
59
|
"mocha": "^10.2.0",
|