@abaplint/core 2.105.5 → 2.105.7
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/README.md +6 -6
- package/build/abaplint.d.ts +2 -8
- package/build/src/abap/5_syntax/expressions/new_object.js +6 -0
- package/build/src/abap/5_syntax/statements/assign.js +3 -3
- package/build/src/abap/5_syntax/statements/concatenate.js +2 -2
- package/build/src/abap/5_syntax/statements/create_object.js +4 -1
- package/build/src/abap/flow/flow_graph.js +7 -7
- package/build/src/lsp/help.js +7 -7
- package/build/src/objects/neptune_api.js +1 -0
- package/build/src/registry.js +1 -1
- package/build/src/rules/7bit_ascii.js +4 -4
- package/build/src/rules/abapdoc.js +11 -6
- package/build/src/rules/align_parameters.js +40 -40
- package/build/src/rules/allowed_object_naming.js +2 -1
- package/build/src/rules/ambiguous_statement.js +6 -6
- package/build/src/rules/avoid_use.js +10 -10
- package/build/src/rules/begin_end_names.js +4 -4
- package/build/src/rules/begin_single_include.js +12 -12
- package/build/src/rules/call_transaction_authority_check.js +3 -3
- package/build/src/rules/cds_comment_style.js +4 -4
- package/build/src/rules/cds_legacy_view.js +4 -4
- package/build/src/rules/chain_mainly_declarations.js +4 -4
- package/build/src/rules/change_if_to_case.js +8 -8
- package/build/src/rules/check_abstract.js +2 -2
- package/build/src/rules/check_comments.js +4 -4
- package/build/src/rules/check_include.js +3 -3
- package/build/src/rules/check_subrc.js +8 -8
- package/build/src/rules/classic_exceptions_overlap.js +10 -10
- package/build/src/rules/commented_code.js +1 -1
- package/build/src/rules/constructor_visibility_public.js +4 -4
- package/build/src/rules/contains_tab.js +2 -2
- package/build/src/rules/cyclic_oo.js +4 -4
- package/build/src/rules/dangerous_statement.js +1 -1
- package/build/src/rules/definitions_top.js +6 -6
- package/build/src/rules/downport.js +82 -82
- package/build/src/rules/easy_to_find_messages.js +6 -6
- package/build/src/rules/empty_line_in_statement.js +2 -2
- package/build/src/rules/exit_or_check.js +3 -3
- package/build/src/rules/expand_macros.js +5 -5
- package/build/src/rules/exporting.js +1 -1
- package/build/src/rules/forbidden_identifier.js +1 -1
- package/build/src/rules/forbidden_void_type.js +2 -2
- package/build/src/rules/fully_type_itabs.js +1 -1
- package/build/src/rules/functional_writing.js +17 -17
- package/build/src/rules/global_class.js +8 -8
- package/build/src/rules/identical_conditions.js +13 -10
- package/build/src/rules/identical_contents.js +14 -14
- package/build/src/rules/identical_descriptions.js +6 -6
- package/build/src/rules/if_in_if.js +35 -35
- package/build/src/rules/implement_methods.js +3 -3
- package/build/src/rules/in_statement_indentation.js +11 -11
- package/build/src/rules/intf_referencing_clas.js +3 -3
- package/build/src/rules/line_break_style.js +2 -2
- package/build/src/rules/line_length.js +1 -1
- package/build/src/rules/line_only_punc.js +1 -1
- package/build/src/rules/local_variable_names.js +2 -2
- package/build/src/rules/main_file_contents.js +4 -4
- package/build/src/rules/many_parentheses.js +10 -10
- package/build/src/rules/max_one_method_parameter_per_line.js +7 -7
- package/build/src/rules/max_one_statement.js +5 -5
- package/build/src/rules/method_length.js +2 -2
- package/build/src/rules/method_overwrites_builtin.js +4 -4
- package/build/src/rules/nesting.js +1 -1
- package/build/src/rules/no_chained_assignment.js +1 -1
- package/build/src/rules/no_external_form_calls.js +2 -2
- package/build/src/rules/no_inline_in_optional_branches.js +11 -11
- package/build/src/rules/no_prefixes.js +6 -6
- package/build/src/rules/no_public_attributes.js +1 -1
- package/build/src/rules/no_yoda_conditions.js +4 -4
- package/build/src/rules/nrob_consistency.js +2 -2
- package/build/src/rules/obsolete_statement.js +51 -51
- package/build/src/rules/omit_parameter_name.js +3 -3
- package/build/src/rules/omit_receiving.js +13 -13
- package/build/src/rules/parser_702_chaining.js +2 -2
- package/build/src/rules/parser_error.js +2 -2
- package/build/src/rules/parser_missing_space.js +1 -1
- package/build/src/rules/prefer_inline.js +16 -16
- package/build/src/rules/prefer_is_not.js +9 -9
- package/build/src/rules/prefer_raise_exception_new.js +5 -5
- package/build/src/rules/prefer_returning_to_exporting.js +1 -1
- package/build/src/rules/prefer_xsdbool.js +2 -2
- package/build/src/rules/reduce_procedural_code.js +17 -17
- package/build/src/rules/remove_descriptions.js +4 -4
- package/build/src/rules/rfc_error_handling.js +9 -9
- package/build/src/rules/select_add_order_by.js +5 -5
- package/build/src/rules/select_performance.js +5 -5
- package/build/src/rules/select_single_full_key.js +2 -2
- package/build/src/rules/sicf_consistency.js +2 -2
- package/build/src/rules/space_before_dot.js +2 -2
- package/build/src/rules/sql_value_conversion.js +6 -6
- package/build/src/rules/start_at_tab.js +1 -1
- package/build/src/rules/strict_sql.js +6 -6
- package/build/src/rules/sy_modification.js +3 -3
- package/build/src/rules/tabl_enhancement_category.js +2 -2
- package/build/src/rules/type_form_parameters.js +2 -2
- package/build/src/rules/unnecessary_pragma.js +29 -29
- package/build/src/rules/unnecessary_return.js +11 -11
- package/build/src/rules/unused_methods.js +11 -11
- package/build/src/rules/unused_variables.js +12 -12
- package/build/src/rules/use_bool_expression.js +8 -8
- package/build/src/rules/use_line_exists.js +6 -6
- package/build/src/rules/use_new.js +4 -4
- package/build/src/rules/when_others_last.js +6 -6
- package/package.json +70 -70
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# @abaplint/core
|
|
2
|
-
|
|
3
|
-
[abaplint](https://abaplint.org) core library
|
|
4
|
-
|
|
5
|
-
Exposes functionality like the parser and rules, which can be used in other projects.
|
|
6
|
-
|
|
1
|
+
# @abaplint/core
|
|
2
|
+
|
|
3
|
+
[abaplint](https://abaplint.org) core library
|
|
4
|
+
|
|
5
|
+
Exposes functionality like the parser and rules, which can be used in other projects.
|
|
6
|
+
|
|
7
7
|
For more information see https://github.com/abaplint/abaplint
|
package/build/abaplint.d.ts
CHANGED
|
@@ -71,10 +71,7 @@ declare abstract class AbstractObject implements IObject {
|
|
|
71
71
|
private files;
|
|
72
72
|
private readonly name;
|
|
73
73
|
abstract getType(): string;
|
|
74
|
-
abstract getAllowedNaming():
|
|
75
|
-
maxLength: number;
|
|
76
|
-
allowNamespace: boolean;
|
|
77
|
-
};
|
|
74
|
+
abstract getAllowedNaming(): IAllowedNaming;
|
|
78
75
|
abstract getDescription(): string | undefined;
|
|
79
76
|
constructor(name: string);
|
|
80
77
|
getParsingIssues(): readonly Issue[];
|
|
@@ -4310,10 +4307,7 @@ declare class NamespaceSimpleName extends Expression {
|
|
|
4310
4307
|
|
|
4311
4308
|
declare class NeptuneAPI extends AbstractObject {
|
|
4312
4309
|
getType(): string;
|
|
4313
|
-
getAllowedNaming():
|
|
4314
|
-
maxLength: number;
|
|
4315
|
-
allowNamespace: boolean;
|
|
4316
|
-
};
|
|
4310
|
+
getAllowedNaming(): IAllowedNaming;
|
|
4317
4311
|
getDescription(): string | undefined;
|
|
4318
4312
|
}
|
|
4319
4313
|
|
|
@@ -23,6 +23,12 @@ class NewObject {
|
|
|
23
23
|
if (clas) {
|
|
24
24
|
scope.addReference(typeToken, clas, _reference_1.ReferenceType.InferredType, filename);
|
|
25
25
|
}
|
|
26
|
+
else {
|
|
27
|
+
const intf = scope.findInterfaceDefinition(targetType.getIdentifierName());
|
|
28
|
+
if (intf) {
|
|
29
|
+
throw new Error(intf.getName() + " is an interface, cannot be instantiated");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
26
32
|
ret = targetType;
|
|
27
33
|
if ((clas === null || clas === void 0 ? void 0 : clas.isAbstract()) === true) {
|
|
28
34
|
throw new Error(clas.getName() + " is abstract, cannot be instantiated");
|
|
@@ -19,9 +19,9 @@ class Assign {
|
|
|
19
19
|
const thirdAssign = assignSource === null || assignSource === void 0 ? void 0 : assignSource.getChildren()[2];
|
|
20
20
|
if ((secondAssign === null || secondAssign === void 0 ? void 0 : secondAssign.concatTokens()) === "=>" && firstAssign && (thirdAssign === null || thirdAssign === void 0 ? void 0 : thirdAssign.get()) instanceof Expressions.Dynamic) {
|
|
21
21
|
const name = firstAssign.concatTokens();
|
|
22
|
-
const found = scope.
|
|
23
|
-
if (found === undefined && scope.getDDIC().inErrorNamespace(name)) {
|
|
24
|
-
throw new Error(
|
|
22
|
+
const found = scope.findClassDefinition(name) || scope.findVariable(name);
|
|
23
|
+
if (found === undefined && scope.getDDIC().inErrorNamespace(name) && name.startsWith("(") === false) {
|
|
24
|
+
throw new Error(name + " not found, dynamic");
|
|
25
25
|
}
|
|
26
26
|
sourceType = new basic_1.VoidType("Dynamic");
|
|
27
27
|
}
|
|
@@ -23,7 +23,7 @@ class Concatenate {
|
|
|
23
23
|
}
|
|
24
24
|
else if (target) {
|
|
25
25
|
const type = new target_1.Target().runSyntax(target, scope, filename);
|
|
26
|
-
const compatible = byteMode ? new _type_utils_1.TypeUtils(scope).isHexLike(type) : new _type_utils_1.TypeUtils(scope).
|
|
26
|
+
const compatible = byteMode ? new _type_utils_1.TypeUtils(scope).isHexLike(type) : new _type_utils_1.TypeUtils(scope).isCharLikeStrict(type);
|
|
27
27
|
if (compatible === false) {
|
|
28
28
|
throw new Error("Target type not compatible");
|
|
29
29
|
}
|
|
@@ -37,7 +37,7 @@ class Concatenate {
|
|
|
37
37
|
linesMode = false;
|
|
38
38
|
continue;
|
|
39
39
|
}
|
|
40
|
-
const compatible = byteMode ? new _type_utils_1.TypeUtils(scope).isHexLike(type) : new _type_utils_1.TypeUtils(scope).
|
|
40
|
+
const compatible = byteMode ? new _type_utils_1.TypeUtils(scope).isHexLike(type) : new _type_utils_1.TypeUtils(scope).isCharLikeStrict(type);
|
|
41
41
|
if (compatible === false) {
|
|
42
42
|
throw new Error("Source type not compatible");
|
|
43
43
|
}
|
|
@@ -99,11 +99,14 @@ class CreateObject {
|
|
|
99
99
|
}
|
|
100
100
|
const source = p.findDirectExpression(Expressions.Source);
|
|
101
101
|
const sourceType = new source_1.Source().runSyntax(source, scope, filename);
|
|
102
|
+
const calculated = (source === null || source === void 0 ? void 0 : source.findFirstExpression(Expressions.MethodCallChain)) !== undefined
|
|
103
|
+
|| (source === null || source === void 0 ? void 0 : source.findFirstExpression(Expressions.StringTemplate)) !== undefined
|
|
104
|
+
|| (source === null || source === void 0 ? void 0 : source.findFirstExpression(Expressions.ArithOperator)) !== undefined;
|
|
102
105
|
const found = allImporting === null || allImporting === void 0 ? void 0 : allImporting.find(p => p.getName().toUpperCase() === name);
|
|
103
106
|
if (found === undefined) {
|
|
104
107
|
throw new Error(`constructor parameter "${name}" does not exist`);
|
|
105
108
|
}
|
|
106
|
-
else if (new _type_utils_1.TypeUtils(scope).isAssignableStrict(sourceType, found.getType()) === false) {
|
|
109
|
+
else if (new _type_utils_1.TypeUtils(scope).isAssignableStrict(sourceType, found.getType(), calculated) === false) {
|
|
107
110
|
throw new Error(`constructor parameter "${name}" type not compatible`);
|
|
108
111
|
}
|
|
109
112
|
requiredImporting.delete(name);
|
|
@@ -84,13 +84,13 @@ class FlowGraph {
|
|
|
84
84
|
this.label = label;
|
|
85
85
|
}
|
|
86
86
|
toDigraph() {
|
|
87
|
-
return `digraph G {
|
|
88
|
-
labelloc="t";
|
|
89
|
-
label="${this.label}";
|
|
90
|
-
graph [fontname = "helvetica"];
|
|
91
|
-
node [fontname = "helvetica", shape="box"];
|
|
92
|
-
edge [fontname = "helvetica"];
|
|
93
|
-
${this.toTextEdges()}
|
|
87
|
+
return `digraph G {
|
|
88
|
+
labelloc="t";
|
|
89
|
+
label="${this.label}";
|
|
90
|
+
graph [fontname = "helvetica"];
|
|
91
|
+
node [fontname = "helvetica", shape="box"];
|
|
92
|
+
edge [fontname = "helvetica"];
|
|
93
|
+
${this.toTextEdges()}
|
|
94
94
|
}`;
|
|
95
95
|
}
|
|
96
96
|
listSources(node) {
|
package/build/src/lsp/help.js
CHANGED
|
@@ -19,13 +19,13 @@ class Help {
|
|
|
19
19
|
/////////////////////////////////////////////////
|
|
20
20
|
static dumpABAP(file, reg, textDocument, position) {
|
|
21
21
|
let content = "";
|
|
22
|
-
content = `
|
|
23
|
-
<a href="#_tokens" rel="no-refresh">Tokens</a> |
|
|
24
|
-
<a href="#_statements" rel="no-refresh">Statements</a> |
|
|
25
|
-
<a href="#_structure" rel="no-refresh">Structure</a> |
|
|
26
|
-
<a href="#_files" rel="no-refresh">Files</a> |
|
|
27
|
-
<a href="#_info" rel="no-refresh">Info Dump</a>
|
|
28
|
-
<hr>
|
|
22
|
+
content = `
|
|
23
|
+
<a href="#_tokens" rel="no-refresh">Tokens</a> |
|
|
24
|
+
<a href="#_statements" rel="no-refresh">Statements</a> |
|
|
25
|
+
<a href="#_structure" rel="no-refresh">Structure</a> |
|
|
26
|
+
<a href="#_files" rel="no-refresh">Files</a> |
|
|
27
|
+
<a href="#_info" rel="no-refresh">Info Dump</a>
|
|
28
|
+
<hr>
|
|
29
29
|
` +
|
|
30
30
|
"<tt>" + textDocument.uri + " (" +
|
|
31
31
|
(position.line + 1) + ", " +
|
package/build/src/registry.js
CHANGED
|
@@ -17,10 +17,10 @@ class SevenBitAscii {
|
|
|
17
17
|
key: "7bit_ascii",
|
|
18
18
|
title: "Check for 7bit ascii",
|
|
19
19
|
shortDescription: `Only allow characters from the 7bit ASCII set.`,
|
|
20
|
-
extendedInformation: `https://docs.abapopenchecks.org/checks/05/
|
|
21
|
-
|
|
22
|
-
https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abencharacter_set_guidl.htm
|
|
23
|
-
|
|
20
|
+
extendedInformation: `https://docs.abapopenchecks.org/checks/05/
|
|
21
|
+
|
|
22
|
+
https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abencharacter_set_guidl.htm
|
|
23
|
+
|
|
24
24
|
Checkes files with extensions ".abap" and ".asddls"`,
|
|
25
25
|
tags: [_irule_1.RuleTag.SingleFile],
|
|
26
26
|
};
|
|
@@ -13,6 +13,8 @@ class AbapdocConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
|
13
13
|
this.checkLocal = false;
|
|
14
14
|
this.classDefinition = false;
|
|
15
15
|
this.interfaceDefinition = false;
|
|
16
|
+
/** Ignores classes flagged as FOR TESTING */
|
|
17
|
+
this.ignoreTestClasses = true;
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
exports.AbapdocConf = AbapdocConf;
|
|
@@ -26,10 +28,10 @@ class Abapdoc extends _abap_rule_1.ABAPRule {
|
|
|
26
28
|
key: "abapdoc",
|
|
27
29
|
title: "Check abapdoc",
|
|
28
30
|
shortDescription: `Various checks regarding abapdoc.`,
|
|
29
|
-
extendedInformation: `Base rule checks for existence of abapdoc for public class methods and all interface methods.
|
|
30
|
-
|
|
31
|
-
Plus class and interface definitions.
|
|
32
|
-
|
|
31
|
+
extendedInformation: `Base rule checks for existence of abapdoc for public class methods and all interface methods.
|
|
32
|
+
|
|
33
|
+
Plus class and interface definitions.
|
|
34
|
+
|
|
33
35
|
https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#abap-doc-only-for-public-apis`,
|
|
34
36
|
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide],
|
|
35
37
|
};
|
|
@@ -52,8 +54,11 @@ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#abap-doc-on
|
|
|
52
54
|
if (this.conf.checkLocal === false && classDef.isLocal === true) {
|
|
53
55
|
continue;
|
|
54
56
|
}
|
|
57
|
+
if (this.conf.ignoreTestClasses === true && classDef.isForTesting === true) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
55
60
|
methods = methods.concat(classDef.methods.filter(m => m.visibility === visibility_1.Visibility.Public));
|
|
56
|
-
if (this.
|
|
61
|
+
if (this.conf.classDefinition === true) {
|
|
57
62
|
const previousRow = classDef.identifier.getStart().getRow() - 2;
|
|
58
63
|
if (((_a = rows[previousRow]) === null || _a === void 0 ? void 0 : _a.trim().substring(0, 2)) !== "\"!") {
|
|
59
64
|
const message = "Missing ABAP Doc for class " + classDef.identifier.getToken().getStr();
|
|
@@ -67,7 +72,7 @@ https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#abap-doc-on
|
|
|
67
72
|
continue;
|
|
68
73
|
}
|
|
69
74
|
methods = methods.concat(interfaceDef.methods);
|
|
70
|
-
if (this.
|
|
75
|
+
if (this.conf.interfaceDefinition === true) {
|
|
71
76
|
const previousRow = interfaceDef.identifier.getStart().getRow() - 2;
|
|
72
77
|
if (((_b = rows[previousRow]) === null || _b === void 0 ? void 0 : _b.trim().substring(0, 2)) !== "\"!") {
|
|
73
78
|
const message = "Missing ABAP Doc for interface " + interfaceDef.identifier.getToken().getStr();
|
|
@@ -22,49 +22,49 @@ class AlignParameters extends _abap_rule_1.ABAPRule {
|
|
|
22
22
|
key: "align_parameters",
|
|
23
23
|
title: "Align Parameters",
|
|
24
24
|
shortDescription: `Checks for vertially aligned parameters`,
|
|
25
|
-
extendedInformation: `Checks:
|
|
26
|
-
* function module calls
|
|
27
|
-
* method calls
|
|
28
|
-
* VALUE constructors
|
|
29
|
-
* NEW constructors
|
|
30
|
-
* RAISE EXCEPTION statements
|
|
31
|
-
* CREATE OBJECT statements
|
|
32
|
-
* RAISE EVENT statements
|
|
33
|
-
|
|
34
|
-
https://github.com/SAP/styleguides/blob/master/clean-abap/CleanABAP.md#align-parameters
|
|
35
|
-
|
|
36
|
-
Does not take effect on non functional method calls, use https://rules.abaplint.org/functional_writing/
|
|
37
|
-
|
|
38
|
-
If parameters are on the same row, no issues are reported, see
|
|
25
|
+
extendedInformation: `Checks:
|
|
26
|
+
* function module calls
|
|
27
|
+
* method calls
|
|
28
|
+
* VALUE constructors
|
|
29
|
+
* NEW constructors
|
|
30
|
+
* RAISE EXCEPTION statements
|
|
31
|
+
* CREATE OBJECT statements
|
|
32
|
+
* RAISE EVENT statements
|
|
33
|
+
|
|
34
|
+
https://github.com/SAP/styleguides/blob/master/clean-abap/CleanABAP.md#align-parameters
|
|
35
|
+
|
|
36
|
+
Does not take effect on non functional method calls, use https://rules.abaplint.org/functional_writing/
|
|
37
|
+
|
|
38
|
+
If parameters are on the same row, no issues are reported, see
|
|
39
39
|
https://rules.abaplint.org/max_one_method_parameter_per_line/ for splitting parameters to lines`,
|
|
40
40
|
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix],
|
|
41
|
-
badExample: `CALL FUNCTION 'FOOBAR'
|
|
42
|
-
EXPORTING
|
|
43
|
-
foo = 2
|
|
44
|
-
parameter = 3.
|
|
45
|
-
|
|
46
|
-
foobar( moo = 1
|
|
47
|
-
param = 1 ).
|
|
48
|
-
|
|
49
|
-
foo = VALUE #(
|
|
50
|
-
foo = bar
|
|
41
|
+
badExample: `CALL FUNCTION 'FOOBAR'
|
|
42
|
+
EXPORTING
|
|
43
|
+
foo = 2
|
|
44
|
+
parameter = 3.
|
|
45
|
+
|
|
46
|
+
foobar( moo = 1
|
|
47
|
+
param = 1 ).
|
|
48
|
+
|
|
49
|
+
foo = VALUE #(
|
|
50
|
+
foo = bar
|
|
51
51
|
moo = 2 ).`,
|
|
52
|
-
goodExample: `CALL FUNCTION 'FOOBAR'
|
|
53
|
-
EXPORTING
|
|
54
|
-
foo = 2
|
|
55
|
-
parameter = 3.
|
|
56
|
-
|
|
57
|
-
foobar( moo = 1
|
|
58
|
-
param = 1 ).
|
|
59
|
-
|
|
60
|
-
foo = VALUE #(
|
|
61
|
-
foo = bar
|
|
62
|
-
moo = 2 ).
|
|
63
|
-
|
|
64
|
-
DATA(sdf) = VALUE type(
|
|
65
|
-
common_val = 2
|
|
66
|
-
another_common = 5
|
|
67
|
-
( row_value = 4
|
|
52
|
+
goodExample: `CALL FUNCTION 'FOOBAR'
|
|
53
|
+
EXPORTING
|
|
54
|
+
foo = 2
|
|
55
|
+
parameter = 3.
|
|
56
|
+
|
|
57
|
+
foobar( moo = 1
|
|
58
|
+
param = 1 ).
|
|
59
|
+
|
|
60
|
+
foo = VALUE #(
|
|
61
|
+
foo = bar
|
|
62
|
+
moo = 2 ).
|
|
63
|
+
|
|
64
|
+
DATA(sdf) = VALUE type(
|
|
65
|
+
common_val = 2
|
|
66
|
+
another_common = 5
|
|
67
|
+
( row_value = 4
|
|
68
68
|
value_foo = 5 ) ).`,
|
|
69
69
|
};
|
|
70
70
|
}
|
|
@@ -4,6 +4,7 @@ exports.AllowedObjectNaming = exports.AllowedObjectNamingConf = void 0;
|
|
|
4
4
|
const issue_1 = require("../issue");
|
|
5
5
|
const _irule_1 = require("./_irule");
|
|
6
6
|
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
7
|
+
const NAME_REGEX = /^(\/[A-Z_\d]{3,8}\/)?[A-Z_\d<> ]+$/i;
|
|
7
8
|
class AllowedObjectNamingConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
8
9
|
}
|
|
9
10
|
exports.AllowedObjectNamingConf = AllowedObjectNamingConf;
|
|
@@ -43,7 +44,7 @@ class AllowedObjectNaming {
|
|
|
43
44
|
message = "Name not allowed";
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
|
-
else if (name.match(
|
|
47
|
+
else if (name.match(NAME_REGEX) === null) {
|
|
47
48
|
message = "Name not allowed";
|
|
48
49
|
}
|
|
49
50
|
if (message.length > 0) {
|
|
@@ -20,15 +20,15 @@ class AmbiguousStatement extends _abap_rule_1.ABAPRule {
|
|
|
20
20
|
return {
|
|
21
21
|
key: "ambiguous_statement",
|
|
22
22
|
title: "Check for ambigious statements",
|
|
23
|
-
shortDescription: `Checks for ambiguity between deleting or modifying from internal and database table
|
|
24
|
-
Add "TABLE" keyword or "@" for escaping SQL variables
|
|
25
|
-
|
|
23
|
+
shortDescription: `Checks for ambiguity between deleting or modifying from internal and database table
|
|
24
|
+
Add "TABLE" keyword or "@" for escaping SQL variables
|
|
25
|
+
|
|
26
26
|
Only works if the target version is 740sp05 or above`,
|
|
27
27
|
tags: [_irule_1.RuleTag.SingleFile],
|
|
28
|
-
badExample: `DELETE foo FROM bar.
|
|
28
|
+
badExample: `DELETE foo FROM bar.
|
|
29
29
|
MODIFY foo FROM bar.`,
|
|
30
|
-
goodExample: `DELETE foo FROM @bar.
|
|
31
|
-
MODIFY TABLE foo FROM bar.
|
|
30
|
+
goodExample: `DELETE foo FROM @bar.
|
|
31
|
+
MODIFY TABLE foo FROM bar.
|
|
32
32
|
MODIFY zfoo FROM @wa.`,
|
|
33
33
|
};
|
|
34
34
|
}
|
|
@@ -43,16 +43,16 @@ class AvoidUse extends _abap_rule_1.ABAPRule {
|
|
|
43
43
|
key: "avoid_use",
|
|
44
44
|
title: "Avoid use of certain statements",
|
|
45
45
|
shortDescription: `Detects usage of certain statements.`,
|
|
46
|
-
extendedInformation: `DEFAULT KEY: https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-default-key
|
|
47
|
-
|
|
48
|
-
Macros: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abenmacros_guidl.htm
|
|
49
|
-
|
|
50
|
-
STATICS: use CLASS-DATA instead
|
|
51
|
-
|
|
52
|
-
DESCRIBE TABLE LINES: use lines() instead (quickfix exists)
|
|
53
|
-
|
|
54
|
-
TEST-SEAMS: https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-test-seams-as-temporary-workaround
|
|
55
|
-
|
|
46
|
+
extendedInformation: `DEFAULT KEY: https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-default-key
|
|
47
|
+
|
|
48
|
+
Macros: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abenmacros_guidl.htm
|
|
49
|
+
|
|
50
|
+
STATICS: use CLASS-DATA instead
|
|
51
|
+
|
|
52
|
+
DESCRIBE TABLE LINES: use lines() instead (quickfix exists)
|
|
53
|
+
|
|
54
|
+
TEST-SEAMS: https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-test-seams-as-temporary-workaround
|
|
55
|
+
|
|
56
56
|
BREAK points`,
|
|
57
57
|
tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
|
|
58
58
|
};
|
|
@@ -23,11 +23,11 @@ class BeginEndNames extends _abap_rule_1.ABAPRule {
|
|
|
23
23
|
title: "Check BEGIN END names",
|
|
24
24
|
shortDescription: `Check BEGIN OF and END OF names match, plus there must be statements between BEGIN and END`,
|
|
25
25
|
tags: [_irule_1.RuleTag.Syntax, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
|
|
26
|
-
badExample: `DATA: BEGIN OF stru,
|
|
27
|
-
field TYPE i,
|
|
26
|
+
badExample: `DATA: BEGIN OF stru,
|
|
27
|
+
field TYPE i,
|
|
28
28
|
END OF structure_not_the_same.`,
|
|
29
|
-
goodExample: `DATA: BEGIN OF stru,
|
|
30
|
-
field TYPE i,
|
|
29
|
+
goodExample: `DATA: BEGIN OF stru,
|
|
30
|
+
field TYPE i,
|
|
31
31
|
END OF stru.`,
|
|
32
32
|
};
|
|
33
33
|
}
|
|
@@ -21,19 +21,19 @@ class BeginSingleInclude extends _abap_rule_1.ABAPRule {
|
|
|
21
21
|
title: "BEGIN contains single INCLUDE",
|
|
22
22
|
shortDescription: `Finds TYPE BEGIN with just one INCLUDE TYPE, and DATA with single INCLUDE STRUCTURE`,
|
|
23
23
|
tags: [_irule_1.RuleTag.SingleFile],
|
|
24
|
-
badExample: `TYPES: BEGIN OF dummy1.
|
|
25
|
-
INCLUDE TYPE dselc.
|
|
26
|
-
TYPES: END OF dummy1.
|
|
27
|
-
|
|
28
|
-
DATA BEGIN OF foo.
|
|
29
|
-
INCLUDE STRUCTURE syst.
|
|
30
|
-
DATA END OF foo.
|
|
31
|
-
|
|
32
|
-
STATICS BEGIN OF bar.
|
|
33
|
-
INCLUDE STRUCTURE syst.
|
|
24
|
+
badExample: `TYPES: BEGIN OF dummy1.
|
|
25
|
+
INCLUDE TYPE dselc.
|
|
26
|
+
TYPES: END OF dummy1.
|
|
27
|
+
|
|
28
|
+
DATA BEGIN OF foo.
|
|
29
|
+
INCLUDE STRUCTURE syst.
|
|
30
|
+
DATA END OF foo.
|
|
31
|
+
|
|
32
|
+
STATICS BEGIN OF bar.
|
|
33
|
+
INCLUDE STRUCTURE syst.
|
|
34
34
|
STATICS END OF bar.`,
|
|
35
|
-
goodExample: `DATA BEGIN OF foo.
|
|
36
|
-
INCLUDE STRUCTURE dselc.
|
|
35
|
+
goodExample: `DATA BEGIN OF foo.
|
|
36
|
+
INCLUDE STRUCTURE dselc.
|
|
37
37
|
DATA END OF foo.`,
|
|
38
38
|
};
|
|
39
39
|
}
|
|
@@ -24,9 +24,9 @@ class CallTransactionAuthorityCheck extends _abap_rule_1.ABAPRule {
|
|
|
24
24
|
extendedInformation: `https://docs.abapopenchecks.org/checks/54/`,
|
|
25
25
|
tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Security],
|
|
26
26
|
badExample: `CALL TRANSACTION 'FOO'.`,
|
|
27
|
-
goodExample: `TRY.
|
|
28
|
-
CALL TRANSACTION 'FOO' WITH AUTHORITY-CHECK.
|
|
29
|
-
CATCH cx_sy_authorization_error.
|
|
27
|
+
goodExample: `TRY.
|
|
28
|
+
CALL TRANSACTION 'FOO' WITH AUTHORITY-CHECK.
|
|
29
|
+
CATCH cx_sy_authorization_error.
|
|
30
30
|
ENDTRY.`,
|
|
31
31
|
};
|
|
32
32
|
}
|
|
@@ -19,10 +19,10 @@ class CDSCommentStyle {
|
|
|
19
19
|
key: "cds_comment_style",
|
|
20
20
|
title: "CDS Comment Style",
|
|
21
21
|
shortDescription: `Check for obsolete comment style`,
|
|
22
|
-
extendedInformation: `Check for obsolete comment style
|
|
23
|
-
|
|
24
|
-
Comments starting with "--" are considered obsolete
|
|
25
|
-
|
|
22
|
+
extendedInformation: `Check for obsolete comment style
|
|
23
|
+
|
|
24
|
+
Comments starting with "--" are considered obsolete
|
|
25
|
+
|
|
26
26
|
https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-us/abencds_general_syntax_rules.htm`,
|
|
27
27
|
tags: [_irule_1.RuleTag.SingleFile],
|
|
28
28
|
badExample: "-- this is a comment",
|
|
@@ -19,10 +19,10 @@ class CDSLegacyView {
|
|
|
19
19
|
title: "CDS Legacy View",
|
|
20
20
|
shortDescription: `Identify CDS Legacy Views`,
|
|
21
21
|
// eslint-disable-next-line max-len
|
|
22
|
-
extendedInformation: `Use DEFINE VIEW ENTITY instead of DEFINE VIEW
|
|
23
|
-
|
|
24
|
-
https://blogs.sap.com/2021/10/16/a-new-generation-of-cds-views-how-to-migrate-your-cds-views-to-cds-view-entities/
|
|
25
|
-
|
|
22
|
+
extendedInformation: `Use DEFINE VIEW ENTITY instead of DEFINE VIEW
|
|
23
|
+
|
|
24
|
+
https://blogs.sap.com/2021/10/16/a-new-generation-of-cds-views-how-to-migrate-your-cds-views-to-cds-view-entities/
|
|
25
|
+
|
|
26
26
|
v755 and up`,
|
|
27
27
|
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Upport],
|
|
28
28
|
};
|
|
@@ -45,10 +45,10 @@ class ChainMainlyDeclarations extends _abap_rule_1.ABAPRule {
|
|
|
45
45
|
key: "chain_mainly_declarations",
|
|
46
46
|
title: "Chain mainly declarations",
|
|
47
47
|
shortDescription: `Chain mainly declarations, allows chaining for the configured statements, reports errors for other statements.`,
|
|
48
|
-
extendedInformation: `
|
|
49
|
-
https://docs.abapopenchecks.org/checks/23/
|
|
50
|
-
|
|
51
|
-
https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenchained_statements_guidl.htm
|
|
48
|
+
extendedInformation: `
|
|
49
|
+
https://docs.abapopenchecks.org/checks/23/
|
|
50
|
+
|
|
51
|
+
https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenchained_statements_guidl.htm
|
|
52
52
|
`,
|
|
53
53
|
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
|
|
54
54
|
badExample: `CALL METHOD: bar.`,
|
|
@@ -29,17 +29,17 @@ class ChangeIfToCase extends _abap_rule_1.ABAPRule {
|
|
|
29
29
|
title: "Change IF to CASE",
|
|
30
30
|
shortDescription: `Finds IF constructs that can be changed to CASE`,
|
|
31
31
|
// eslint-disable-next-line max-len
|
|
32
|
-
extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-case-to-else-if-for-multiple-alternative-conditions
|
|
33
|
-
|
|
32
|
+
extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-case-to-else-if-for-multiple-alternative-conditions
|
|
33
|
+
|
|
34
34
|
If the first comparison is a boolean compare, no issue is reported.`,
|
|
35
35
|
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide],
|
|
36
|
-
badExample: `IF l_fcat-fieldname EQ 'FOO'.
|
|
37
|
-
ELSEIF l_fcat-fieldname = 'BAR'
|
|
38
|
-
OR l_fcat-fieldname = 'MOO'.
|
|
36
|
+
badExample: `IF l_fcat-fieldname EQ 'FOO'.
|
|
37
|
+
ELSEIF l_fcat-fieldname = 'BAR'
|
|
38
|
+
OR l_fcat-fieldname = 'MOO'.
|
|
39
39
|
ENDIF.`,
|
|
40
|
-
goodExample: `CASE l_fcat-fieldname.
|
|
41
|
-
WHEN 'FOO'.
|
|
42
|
-
WHEN 'BAR' OR 'MOO'.
|
|
40
|
+
goodExample: `CASE l_fcat-fieldname.
|
|
41
|
+
WHEN 'FOO'.
|
|
42
|
+
WHEN 'BAR' OR 'MOO'.
|
|
43
43
|
ENDCASE.`,
|
|
44
44
|
};
|
|
45
45
|
}
|
|
@@ -23,8 +23,8 @@ class CheckAbstract extends _abap_rule_1.ABAPRule {
|
|
|
23
23
|
return {
|
|
24
24
|
key: "check_abstract",
|
|
25
25
|
title: "Check abstract methods and classes",
|
|
26
|
-
shortDescription: `Checks abstract methods and classes:
|
|
27
|
-
- class defined as abstract and final,
|
|
26
|
+
shortDescription: `Checks abstract methods and classes:
|
|
27
|
+
- class defined as abstract and final,
|
|
28
28
|
- non-abstract class contains abstract methods`,
|
|
29
29
|
extendedInformation: `If a class defines only constants, use an interface instead`,
|
|
30
30
|
tags: [_irule_1.RuleTag.SingleFile],
|
|
@@ -27,11 +27,11 @@ class CheckComments extends _abap_rule_1.ABAPRule {
|
|
|
27
27
|
return {
|
|
28
28
|
key: "check_comments",
|
|
29
29
|
title: "Check Comments",
|
|
30
|
-
shortDescription: `
|
|
30
|
+
shortDescription: `
|
|
31
31
|
Various checks for comment usage.`,
|
|
32
|
-
extendedInformation: `
|
|
33
|
-
Detects end of line comments. Comments starting with "#EC" or "##" are ignored
|
|
34
|
-
|
|
32
|
+
extendedInformation: `
|
|
33
|
+
Detects end of line comments. Comments starting with "#EC" or "##" are ignored
|
|
34
|
+
|
|
35
35
|
https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#put-comments-before-the-statement-they-relate-to`,
|
|
36
36
|
tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile],
|
|
37
37
|
badExample: `WRITE 2. " descriptive comment`,
|
|
@@ -17,9 +17,9 @@ class CheckInclude {
|
|
|
17
17
|
key: "check_include",
|
|
18
18
|
title: "Check INCLUDEs",
|
|
19
19
|
shortDescription: `Checks INCLUDE statements`,
|
|
20
|
-
extendedInformation: `
|
|
21
|
-
* Reports unused includes
|
|
22
|
-
* Errors if the includes are not found
|
|
20
|
+
extendedInformation: `
|
|
21
|
+
* Reports unused includes
|
|
22
|
+
* Errors if the includes are not found
|
|
23
23
|
* Error if including a main program`,
|
|
24
24
|
tags: [_irule_1.RuleTag.Syntax],
|
|
25
25
|
};
|
|
@@ -34,14 +34,14 @@ class CheckSubrc extends _abap_rule_1.ABAPRule {
|
|
|
34
34
|
key: "check_subrc",
|
|
35
35
|
title: "Check sy-subrc",
|
|
36
36
|
shortDescription: `Check sy-subrc`,
|
|
37
|
-
extendedInformation: `Pseudo comment "#EC CI_SUBRC can be added to suppress findings
|
|
38
|
-
|
|
39
|
-
If sy-dbcnt is checked after database statements, it is considered okay.
|
|
40
|
-
|
|
41
|
-
"SELECT SINGLE @abap_true FROM " is considered as an existence check, also "SELECT COUNT( * )" is considered okay
|
|
42
|
-
|
|
43
|
-
If IS ASSIGNED is checked after assigning, it is considered okay.
|
|
44
|
-
|
|
37
|
+
extendedInformation: `Pseudo comment "#EC CI_SUBRC can be added to suppress findings
|
|
38
|
+
|
|
39
|
+
If sy-dbcnt is checked after database statements, it is considered okay.
|
|
40
|
+
|
|
41
|
+
"SELECT SINGLE @abap_true FROM " is considered as an existence check, also "SELECT COUNT( * )" is considered okay
|
|
42
|
+
|
|
43
|
+
If IS ASSIGNED is checked after assigning, it is considered okay.
|
|
44
|
+
|
|
45
45
|
FIND statement with MATCH COUNT is considered okay if subrc is not checked`,
|
|
46
46
|
tags: [_irule_1.RuleTag.SingleFile],
|
|
47
47
|
pseudoComment: "EC CI_SUBRC",
|
|
@@ -21,17 +21,17 @@ class ClassicExceptionsOverlap extends _abap_rule_1.ABAPRule {
|
|
|
21
21
|
shortDescription: `Find overlapping classic exceptions`,
|
|
22
22
|
extendedInformation: `When debugging its typically good to know exactly which exception is caught`,
|
|
23
23
|
tags: [_irule_1.RuleTag.SingleFile],
|
|
24
|
-
badExample: `CALL FUNCTION 'SOMETHING'
|
|
25
|
-
EXCEPTIONS
|
|
26
|
-
system_failure = 1 MESSAGE lv_message
|
|
27
|
-
communication_failure = 1 MESSAGE lv_message
|
|
28
|
-
resource_failure = 1
|
|
24
|
+
badExample: `CALL FUNCTION 'SOMETHING'
|
|
25
|
+
EXCEPTIONS
|
|
26
|
+
system_failure = 1 MESSAGE lv_message
|
|
27
|
+
communication_failure = 1 MESSAGE lv_message
|
|
28
|
+
resource_failure = 1
|
|
29
29
|
OTHERS = 1.`,
|
|
30
|
-
goodExample: `CALL FUNCTION 'SOMETHING'
|
|
31
|
-
EXCEPTIONS
|
|
32
|
-
system_failure = 1 MESSAGE lv_message
|
|
33
|
-
communication_failure = 2 MESSAGE lv_message
|
|
34
|
-
resource_failure = 3
|
|
30
|
+
goodExample: `CALL FUNCTION 'SOMETHING'
|
|
31
|
+
EXCEPTIONS
|
|
32
|
+
system_failure = 1 MESSAGE lv_message
|
|
33
|
+
communication_failure = 2 MESSAGE lv_message
|
|
34
|
+
resource_failure = 3
|
|
35
35
|
OTHERS = 4.`,
|
|
36
36
|
};
|
|
37
37
|
}
|
|
@@ -30,7 +30,7 @@ class CommentedCode extends _abap_rule_1.ABAPRule {
|
|
|
30
30
|
key: "commented_code",
|
|
31
31
|
title: "Find commented code",
|
|
32
32
|
shortDescription: `Detects usage of commented out code.`,
|
|
33
|
-
extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#delete-code-instead-of-commenting-it
|
|
33
|
+
extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#delete-code-instead-of-commenting-it
|
|
34
34
|
https://docs.abapopenchecks.org/checks/14/`,
|
|
35
35
|
tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
|
|
36
36
|
};
|