@abaplint/core 2.80.9 → 2.81.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/abaplint.d.ts +8 -0
- package/build/src/abap/2_statements/expressions/sql_arithmetics.js +2 -1
- package/build/src/abap/2_statements/expressions/sql_function.js +14 -3
- package/build/src/abap/2_statements/statements/move.js +3 -2
- package/build/src/abap/3_structures/structures/normal.js +1 -1
- package/build/src/abap/5_syntax/_current_scope.js +26 -0
- package/build/src/abap/5_syntax/_scope_type.js +1 -0
- package/build/src/abap/5_syntax/basic_types.js +5 -1
- package/build/src/abap/5_syntax/spaghetti_scope.js +13 -0
- package/build/src/abap/5_syntax/statements/class_implementation.js +4 -2
- package/build/src/abap/5_syntax/statements/method_implementation.js +7 -3
- package/build/src/abap/5_syntax/statements/read_table.js +4 -1
- package/build/src/abap/5_syntax/syntax.js +6 -1
- package/build/src/edit_helper.js +28 -9
- package/build/src/registry.js +1 -1
- package/build/src/rules/index.js +2 -0
- package/build/src/rules/no_chained_assignment.js +52 -0
- package/build/src/rules/prefer_inline.js +3 -2
- package/build/src/rules/unnecessary_chaining.js +58 -0
- package/build/src/rules/unreachable_code.js +4 -0
- package/package.json +5 -4
package/build/abaplint.d.ts
CHANGED
|
@@ -999,6 +999,8 @@ export declare class CurrentScope {
|
|
|
999
999
|
private constructor();
|
|
1000
1000
|
addType(type: TypedIdentifier | undefined): void;
|
|
1001
1001
|
addTypeNamed(name: string, type: TypedIdentifier | undefined): void;
|
|
1002
|
+
addExtraLikeType(type: TypedIdentifier | undefined): void;
|
|
1003
|
+
addExtraLikeTypeNamed(name: string, type: TypedIdentifier | undefined): void;
|
|
1002
1004
|
addClassDefinition(c: IClassDefinition): void;
|
|
1003
1005
|
addFormDefinitions(f: readonly IFormDefinition[]): void;
|
|
1004
1006
|
addInterfaceDefinition(i: IInterfaceDefinition): void;
|
|
@@ -1024,6 +1026,7 @@ export declare class CurrentScope {
|
|
|
1024
1026
|
findInterfaceDefinition(name: string): IInterfaceDefinition | undefined;
|
|
1025
1027
|
findFormDefinition(name: string): IFormDefinition | undefined;
|
|
1026
1028
|
findType(name: string | undefined): TypedIdentifier | undefined;
|
|
1029
|
+
findExtraLikeType(name: string | undefined): TypedIdentifier | undefined;
|
|
1027
1030
|
findVariable(name: string | undefined): TypedIdentifier | undefined;
|
|
1028
1031
|
getDDIC(): DDIC;
|
|
1029
1032
|
getDDICReferences(): IDDICReferences;
|
|
@@ -3067,6 +3070,9 @@ declare interface IScopeData {
|
|
|
3067
3070
|
types: {
|
|
3068
3071
|
[name: string]: TypedIdentifier;
|
|
3069
3072
|
};
|
|
3073
|
+
extraLikeTypes: {
|
|
3074
|
+
[name: string]: TypedIdentifier;
|
|
3075
|
+
};
|
|
3070
3076
|
deferred: Token[];
|
|
3071
3077
|
cdefs: IClassDefinition[];
|
|
3072
3078
|
idefs: IInterfaceDefinition[];
|
|
@@ -4312,6 +4318,7 @@ export declare enum ScopeType {
|
|
|
4312
4318
|
Form = "form",
|
|
4313
4319
|
FunctionModule = "function",
|
|
4314
4320
|
Method = "method",
|
|
4321
|
+
MethodInstance = "method_instance",
|
|
4315
4322
|
For = "for",
|
|
4316
4323
|
OpenSQL = "open_sql"
|
|
4317
4324
|
}
|
|
@@ -4595,6 +4602,7 @@ export declare class SpaghettiScopeNode extends ScopeData implements ISpaghettiS
|
|
|
4595
4602
|
listFormDefinitions(): IFormDefinition[];
|
|
4596
4603
|
findInterfaceDefinition(name: string): IInterfaceDefinition | undefined;
|
|
4597
4604
|
findType(name: string): TypedIdentifier | undefined;
|
|
4605
|
+
findExtraLikeType(name: string): TypedIdentifier | undefined;
|
|
4598
4606
|
findVariable(name: string): TypedIdentifier | undefined;
|
|
4599
4607
|
findWriteReference(pos: Position): TypedIdentifier | undefined;
|
|
4600
4608
|
findTableReference(pos: Position): string | undefined;
|
|
@@ -7,7 +7,8 @@ const tokens_1 = require("../../1_lexer/tokens");
|
|
|
7
7
|
class SQLArithmetics extends combi_1.Expression {
|
|
8
8
|
getRunnable() {
|
|
9
9
|
const operator = (0, combi_1.altPrio)((0, combi_1.tok)(tokens_1.WPlusW), (0, combi_1.tok)(tokens_1.WDashW), "*", "/");
|
|
10
|
-
|
|
10
|
+
const field = (0, combi_1.alt)(_1.SQLFieldName, _1.SQLFunction);
|
|
11
|
+
return (0, combi_1.seq)(field, (0, combi_1.starPrio)((0, combi_1.seq)(operator, field)));
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
exports.SQLArithmetics = SQLArithmetics;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SQLFunction = void 0;
|
|
4
|
+
const constant_1 = require("./constant");
|
|
4
5
|
const version_1 = require("../../../version");
|
|
5
6
|
const tokens_1 = require("../../1_lexer/tokens");
|
|
6
7
|
const combi_1 = require("../combi");
|
|
@@ -9,10 +10,20 @@ const sql_alias_field_1 = require("./sql_alias_field");
|
|
|
9
10
|
const sql_field_name_1 = require("./sql_field_name");
|
|
10
11
|
class SQLFunction extends combi_1.Expression {
|
|
11
12
|
getRunnable() {
|
|
13
|
+
const param = (0, combi_1.alt)(sql_field_name_1.SQLFieldName, sql_alias_field_1.SQLAliasField, SQLFunction, constant_1.Constant);
|
|
14
|
+
const castTypes = (0, combi_1.altPrio)((0, combi_1.seq)("CHAR", (0, combi_1.tok)(tokens_1.ParenLeftW), integer_1.Integer, (0, combi_1.tok)(tokens_1.WParenRightW)), "FLTP");
|
|
15
|
+
const abs = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("abs", (0, combi_1.tok)(tokens_1.ParenLeftW), param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
16
|
+
const cast = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("cast", (0, combi_1.tok)(tokens_1.ParenLeftW), param, "AS", castTypes, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
17
|
+
const ceil = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("ceil", (0, combi_1.tok)(tokens_1.ParenLeftW), param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
18
|
+
const coalesce = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("coalesce", (0, combi_1.tok)(tokens_1.ParenLeftW), param, ",", param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
19
|
+
const concat = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("concat", (0, combi_1.tok)(tokens_1.ParenLeftW), param, ",", param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
20
|
+
const div = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("div", (0, combi_1.tok)(tokens_1.ParenLeftW), param, ",", param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
21
|
+
const floor = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("floor", (0, combi_1.tok)(tokens_1.ParenLeftW), param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
22
|
+
const length = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("length", (0, combi_1.tok)(tokens_1.ParenLeftW), param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
23
|
+
const mod = (0, combi_1.ver)(version_1.Version.v740sp05, (0, combi_1.seq)("mod", (0, combi_1.tok)(tokens_1.ParenLeftW), param, ",", param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
24
|
+
const replace = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("replace", (0, combi_1.tok)(tokens_1.ParenLeftW), param, ",", param, ",", param, (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
12
25
|
const uuid = (0, combi_1.ver)(version_1.Version.v754, (0, combi_1.seq)("uuid", (0, combi_1.tok)(tokens_1.ParenLeftW), (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
13
|
-
|
|
14
|
-
const cast = (0, combi_1.ver)(version_1.Version.v750, (0, combi_1.seq)("cast", (0, combi_1.tok)(tokens_1.ParenLeftW), (0, combi_1.altPrio)(sql_field_name_1.SQLFieldName, sql_alias_field_1.SQLAliasField), "AS CHAR", (0, combi_1.tok)(tokens_1.ParenLeftW), integer_1.Integer, (0, combi_1.tok)(tokens_1.WParenRightW), (0, combi_1.tok)(tokens_1.WParenRightW)));
|
|
15
|
-
return (0, combi_1.altPrio)(uuid, abs, cast);
|
|
26
|
+
return (0, combi_1.altPrio)(uuid, abs, ceil, floor, cast, div, mod, coalesce, concat, replace, length);
|
|
16
27
|
}
|
|
17
28
|
}
|
|
18
29
|
exports.SQLFunction = SQLFunction;
|
|
@@ -10,9 +10,10 @@ class Move {
|
|
|
10
10
|
const mov = (0, combi_1.verNot)(version_1.Version.Cloud, "MOVE");
|
|
11
11
|
const move = (0, combi_1.seq)(mov, (0, combi_1.altPrio)((0, combi_1.seq)("EXACT", expressions_1.Source, "TO", expressions_1.Target), (0, combi_1.seq)(expressions_1.Source, (0, combi_1.altPrio)("?TO", "TO"), expressions_1.Target)));
|
|
12
12
|
const calcAssign = (0, combi_1.ver)(version_1.Version.v754, (0, combi_1.alt)((0, combi_1.seq)((0, combi_1.tok)(tokens_1.WPlus), "="), (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WDash), "="), "/=", "*=", "&&="));
|
|
13
|
-
const
|
|
13
|
+
const chained = (0, combi_1.seq)("=", (0, combi_1.star)((0, combi_1.seq)(expressions_1.Target, "=")));
|
|
14
|
+
const equals = (0, combi_1.altPrio)((0, combi_1.altPrio)(chained, "?="), calcAssign);
|
|
14
15
|
// todo, move "?=" to CAST?
|
|
15
|
-
const eq = (0, combi_1.seq)(
|
|
16
|
+
const eq = (0, combi_1.seq)(expressions_1.Target, equals, expressions_1.Source);
|
|
16
17
|
return (0, combi_1.altPrio)(move, eq);
|
|
17
18
|
}
|
|
18
19
|
}
|
|
@@ -9,7 +9,7 @@ class Normal {
|
|
|
9
9
|
getMatcher() {
|
|
10
10
|
// note that the sequence of alternatives here influences performance
|
|
11
11
|
return (0, _combi_1.alt)((0, _combi_1.sta)(Statements.Move), (0, _combi_1.sta)(Statements.Call), (0, _combi_1.sta)(Statements.Data), (0, _combi_1.sub)(Structures.If), (0, _combi_1.sta)(Statements.Clear), (0, _combi_1.sta)(Statements.FieldSymbol), (0, _combi_1.sta)(Statements.CreateObject), (0, _combi_1.sta)(Statements.CallFunction), (0, _combi_1.sta)(_statement_1.MacroCall), (0, _combi_1.sub)(Structures.Loop), (0, _combi_1.sta)(Statements.Append), (0, _combi_1.sub)(Structures.Try), (0, _combi_1.sta)(Statements.ReadTable), (0, _combi_1.sta)(Statements.Assert), (0, _combi_1.sta)(Statements.Return), (0, _combi_1.sta)(Statements.Select), (0, _combi_1.sta)(Statements.Assign), (0, _combi_1.sta)(Statements.InsertInternal), (0, _combi_1.sta)(Statements.DeleteInternal), (0, _combi_1.sta)(Statements.Concatenate), (0, _combi_1.sub)(Structures.Case), (0, _combi_1.sub)(Structures.CaseType), (0, _combi_1.sub)(Structures.Enhancement), (0, _combi_1.sub)(Structures.EnhancementSection), (0, _combi_1.sta)(Statements.AddCorresponding), (0, _combi_1.sta)(Statements.Add), (0, _combi_1.sta)(Statements.AssignLocalCopy), (0, _combi_1.sta)(Statements.AuthorityCheck), (0, _combi_1.sta)(Statements.Back), (0, _combi_1.sta)(Statements.Break), (0, _combi_1.sta)(Statements.BreakId), (0, _combi_1.sta)(Statements.CallDatabase), (0, _combi_1.sta)(Statements.CallDialog), (0, _combi_1.sta)(Statements.CallKernel), (0, _combi_1.sta)(Statements.CallOLE), (0, _combi_1.sta)(Statements.CallScreen), (0, _combi_1.sta)(Statements.ModifyScreen), (0, _combi_1.sta)(Statements.CallSelectionScreen), (0, _combi_1.sta)(Statements.CallTransaction), (0, _combi_1.sta)(Statements.CallTransformation), (0, _combi_1.sta)(Statements.Check), (0, _combi_1.sta)(Statements.ClassDefinitionLoad), (0, _combi_1.sta)(Statements.CloseCursor), (0, _combi_1.sta)(Statements.CloseDataset), (0, _combi_1.sta)(Statements.Collect), (0, _combi_1.sta)(Statements.Commit), (0, _combi_1.sta)(Statements.Communication), (0, _combi_1.sta)(Statements.Compute), (0, _combi_1.sta)(Statements.CallBadi), (0, _combi_1.sta)(Statements.Condense), (0, _combi_1.sta)(Statements.Constant), (0, _combi_1.sta)(Statements.Contexts), (0, _combi_1.sta)(Statements.Continue), (0, _combi_1.sta)(Statements.ConvertText), (0, _combi_1.sta)(Statements.Convert), (0, _combi_1.sta)(Statements.CreateData), (0, _combi_1.sta)(Statements.CreateOLE), (0, _combi_1.sta)(Statements.DeleteCluster), (0, _combi_1.sta)(Statements.DeleteDatabase), (0, _combi_1.sta)(Statements.DeleteDataset), (0, _combi_1.sta)(Statements.DeleteDynpro), (0, _combi_1.sta)(Statements.DeleteMemory), (0, _combi_1.sta)(Statements.DeleteReport), (0, _combi_1.sta)(Statements.DeleteTextpool), (0, _combi_1.sta)(Statements.Demand), (0, _combi_1.sta)(Statements.Describe), (0, _combi_1.sta)(Statements.Detail), (0, _combi_1.sta)(Statements.Divide), (0, _combi_1.sta)(Statements.EditorCall), (0, _combi_1.sta)(Statements.EnhancementPoint), (0, _combi_1.sta)(Statements.Exit), (0, _combi_1.sta)(Statements.ExportDynpro), (0, _combi_1.sta)(Statements.Export), (0, _combi_1.sta)(Statements.Extract), (0, _combi_1.sta)(Statements.FetchNextCursor), (0, _combi_1.sta)(Statements.FieldGroup), (0, _combi_1.sta)(Statements.Fields), (0, _combi_1.sta)(Statements.Find), (0, _combi_1.sta)(Statements.Format), (0, _combi_1.sta)(Statements.FreeMemory), (0, _combi_1.sta)(Statements.FreeObject), (0, _combi_1.sta)(Statements.Free), (0, _combi_1.sta)(Statements.GenerateDynpro), (0, _combi_1.sta)(Statements.GenerateReport), (0, _combi_1.sta)(Statements.GenerateSubroutine), (0, _combi_1.sta)(Statements.GetBadi), (0, _combi_1.sta)(Statements.GetBit), (0, _combi_1.sta)(Statements.GetCursor), (0, _combi_1.sta)(Statements.GetDataset), (0, _combi_1.sta)(Statements.GetLocale), (0, _combi_1.sta)(Statements.GetParameter), (0, _combi_1.sta)(Statements.GetPFStatus), (0, _combi_1.sta)(Statements.GetProperty), (0, _combi_1.sta)(Statements.GetReference), (0, _combi_1.sta)(Statements.GetRunTime), (0, _combi_1.sta)(Statements.GetTime), (0, _combi_1.sta)(Statements.Hide), (0, _combi_1.sta)(Statements.Nodes), (0, _combi_1.sta)(Statements.ImportDynpro), (0, _combi_1.sta)(Statements.ImportNametab), (0, _combi_1.sta)(Statements.MoveCorresponding), (0, _combi_1.sta)(Statements.Import), (0, _combi_1.sta)(Statements.Infotypes), (0, _combi_1.sta)(Statements.Include), // include does not have to be at top level
|
|
12
|
-
(0, _combi_1.sta)(Statements.InsertDatabase), (0, _combi_1.sta)(Statements.InsertReport), (0, _combi_1.sta)(Statements.InsertTextpool), (0, _combi_1.sta)(Statements.InsertFieldGroup), (0, _combi_1.sta)(Statements.InterfaceLoad), (0, _combi_1.sta)(Statements.Leave), (0, _combi_1.sta)(Statements.LoadReport), (0, _combi_1.sta)(Statements.Local), (0, _combi_1.sta)(Statements.LogPoint), (0, _combi_1.sta)(Statements.Message), (0, _combi_1.sta)(Statements.ModifyLine), (0, _combi_1.sta)(Statements.ModifyDatabase), (0, _combi_1.sta)(Statements.ModifyInternal), (0, _combi_1.sta)(Statements.Multiply), (0, _combi_1.sta)(Statements.NewLine), (0, _combi_1.sta)(Statements.NewPage), (0, _combi_1.sta)(Statements.OpenCursor), (0, _combi_1.sta)(Statements.OpenDataset), (0, _combi_1.sta)(Statements.Overlay), (0, _combi_1.sta)(Statements.Pack), (0, _combi_1.sta)(Statements.Perform), (0, _combi_1.sta)(Statements.Position), (0, _combi_1.sta)(Statements.Put), (0, _combi_1.sta)(Statements.PrintControl), (0, _combi_1.sta)(Statements.RaiseEvent), (0, _combi_1.sta)(Statements.Raise), (0, _combi_1.sta)(Statements.Ranges), (0, _combi_1.sta)(Statements.ReadDataset), (0, _combi_1.sta)(Statements.ReadLine), (0, _combi_1.sta)(Statements.ReadReport), (0, _combi_1.sta)(Statements.ReadTextpool), (0, _combi_1.sta)(Statements.Receive), (0, _combi_1.sta)(Statements.RefreshControl), (0, _combi_1.sta)(Statements.Refresh), (0, _combi_1.sta)(Statements.Reject), (0, _combi_1.sta)(Statements.Replace), (0, _combi_1.sta)(Statements.Reserve), (0, _combi_1.sta)(Statements.Resume), (0, _combi_1.sta)(Statements.Retry), (0, _combi_1.sta)(Statements.Rollback), (0, _combi_1.sta)(Statements.Scan), (0, _combi_1.sta)(Statements.ScrollList), (0, _combi_1.sta)(Statements.Search), (0, _combi_1.sta)(Statements.SetBit), (0, _combi_1.sta)(Statements.SetBlank), (0, _combi_1.sta)(Statements.SetCountry), (0, _combi_1.sta)(Statements.SetCursor), (0, _combi_1.sta)(Statements.SetDataset), (0, _combi_1.sta)(Statements.SetExtendedCheck), (0, _combi_1.sta)(Statements.SetHandler), (0, _combi_1.sta)(Statements.SetLanguage), (0, _combi_1.sta)(Statements.SetLeft), (0, _combi_1.sta)(Statements.SetLocale), (0, _combi_1.sta)(Statements.SetMargin), (0, _combi_1.sta)(Statements.SetParameter), (0, _combi_1.sta)(Statements.SetPFStatus), (0, _combi_1.sta)(Statements.SetProperty), (0, _combi_1.sta)(Statements.SetRunTime), (0, _combi_1.sta)(Statements.SetScreen), (0, _combi_1.sta)(Statements.SetTitlebar), (0, _combi_1.sta)(Statements.SetUserCommand), (0, _combi_1.sta)(Statements.SetUpdateTask), (0, _combi_1.sta)(Statements.Shift), (0, _combi_1.sta)(Statements.Skip), (0, _combi_1.sta)(Statements.SortDataset), (0, _combi_1.sta)(Statements.Sort), (0, _combi_1.sta)(Statements.Static), (0, _combi_1.sta)(Statements.Split), (0, _combi_1.sta)(Statements.Stop), (0, _combi_1.sta)(Statements.Submit), (0, _combi_1.sta)(Statements.Summary), (0, _combi_1.sta)(Statements.SubtractCorresponding), (0, _combi_1.sta)(Statements.Subtract), (0, _combi_1.sta)(Statements.SuppressDialog), (0, _combi_1.sta)(Statements.Supply), (0, _combi_1.sta)(Statements.Sum), (0, _combi_1.sta)(Statements.SyntaxCheck), (0, _combi_1.sta)(Statements.SystemCall), (0, _combi_1.sta)(Statements.Tables), (0, _combi_1.sta)(Statements.Transfer), (0, _combi_1.sta)(Statements.Translate), (0, _combi_1.sta)(Statements.Type), (0, _combi_1.sta)(Statements.TypePools), (0, _combi_1.sta)(Statements.Uline), (0, _combi_1.sta)(Statements.Unassign), (0, _combi_1.sta)(Statements.Unpack), (0, _combi_1.sta)(Statements.UpdateDatabase), (0, _combi_1.sta)(Statements.Wait), (0, _combi_1.sta)(Statements.Window), (0, _combi_1.sta)(Statements.Write), (0, _combi_1.sta)(Statements.CommitEntities), (0, _combi_1.sta)(Statements.ModifyEntities), (0, _combi_1.sta)(Statements.ReadEntities), (0, _combi_1.sta)(Statements.RollbackEntities), (0, _combi_1.sub)(Structures.Define), (0, _combi_1.sub)(Structures.TestInjection), (0, _combi_1.sub)(Structures.TestSeam), (0, _combi_1.sub)(Structures.Provide), (0, _combi_1.sub)(Structures.CatchSystemExceptions), (0, _combi_1.sub)(Structures.At), (0, _combi_1.sub)(Structures.Constants), (0, _combi_1.sub)(Structures.Types), (0, _combi_1.sub)(Structures.Statics), (0, _combi_1.sub)(Structures.Select), (0, _combi_1.sub)(Structures.Data), (0, _combi_1.sub)(Structures.TypeEnum), (0, _combi_1.sub)(Structures.While), (0, _combi_1.sub)(Structures.With), (0, _combi_1.sub)(Structures.Do), (0, _combi_1.sub)(Structures.ExecSQL));
|
|
12
|
+
(0, _combi_1.sta)(Statements.InsertDatabase), (0, _combi_1.sta)(Statements.InsertReport), (0, _combi_1.sta)(Statements.InsertTextpool), (0, _combi_1.sta)(Statements.InsertFieldGroup), (0, _combi_1.sta)(Statements.InterfaceLoad), (0, _combi_1.sta)(Statements.Leave), (0, _combi_1.sta)(Statements.LoadReport), (0, _combi_1.sta)(Statements.Local), (0, _combi_1.sta)(Statements.With), (0, _combi_1.sta)(Statements.LogPoint), (0, _combi_1.sta)(Statements.Message), (0, _combi_1.sta)(Statements.ModifyLine), (0, _combi_1.sta)(Statements.ModifyDatabase), (0, _combi_1.sta)(Statements.ModifyInternal), (0, _combi_1.sta)(Statements.Multiply), (0, _combi_1.sta)(Statements.NewLine), (0, _combi_1.sta)(Statements.NewPage), (0, _combi_1.sta)(Statements.OpenCursor), (0, _combi_1.sta)(Statements.OpenDataset), (0, _combi_1.sta)(Statements.Overlay), (0, _combi_1.sta)(Statements.Pack), (0, _combi_1.sta)(Statements.Perform), (0, _combi_1.sta)(Statements.Position), (0, _combi_1.sta)(Statements.Put), (0, _combi_1.sta)(Statements.PrintControl), (0, _combi_1.sta)(Statements.RaiseEvent), (0, _combi_1.sta)(Statements.Raise), (0, _combi_1.sta)(Statements.Ranges), (0, _combi_1.sta)(Statements.ReadDataset), (0, _combi_1.sta)(Statements.ReadLine), (0, _combi_1.sta)(Statements.ReadReport), (0, _combi_1.sta)(Statements.ReadTextpool), (0, _combi_1.sta)(Statements.Receive), (0, _combi_1.sta)(Statements.RefreshControl), (0, _combi_1.sta)(Statements.Refresh), (0, _combi_1.sta)(Statements.Reject), (0, _combi_1.sta)(Statements.Replace), (0, _combi_1.sta)(Statements.Reserve), (0, _combi_1.sta)(Statements.Resume), (0, _combi_1.sta)(Statements.Retry), (0, _combi_1.sta)(Statements.Rollback), (0, _combi_1.sta)(Statements.Scan), (0, _combi_1.sta)(Statements.ScrollList), (0, _combi_1.sta)(Statements.Search), (0, _combi_1.sta)(Statements.SetBit), (0, _combi_1.sta)(Statements.SetBlank), (0, _combi_1.sta)(Statements.SetCountry), (0, _combi_1.sta)(Statements.SetCursor), (0, _combi_1.sta)(Statements.SetDataset), (0, _combi_1.sta)(Statements.SetExtendedCheck), (0, _combi_1.sta)(Statements.SetHandler), (0, _combi_1.sta)(Statements.SetLanguage), (0, _combi_1.sta)(Statements.SetLeft), (0, _combi_1.sta)(Statements.SetLocale), (0, _combi_1.sta)(Statements.SetMargin), (0, _combi_1.sta)(Statements.SetParameter), (0, _combi_1.sta)(Statements.SetPFStatus), (0, _combi_1.sta)(Statements.SetProperty), (0, _combi_1.sta)(Statements.SetRunTime), (0, _combi_1.sta)(Statements.SetScreen), (0, _combi_1.sta)(Statements.SetTitlebar), (0, _combi_1.sta)(Statements.SetUserCommand), (0, _combi_1.sta)(Statements.SetUpdateTask), (0, _combi_1.sta)(Statements.Shift), (0, _combi_1.sta)(Statements.Skip), (0, _combi_1.sta)(Statements.SortDataset), (0, _combi_1.sta)(Statements.Sort), (0, _combi_1.sta)(Statements.Static), (0, _combi_1.sta)(Statements.Split), (0, _combi_1.sta)(Statements.Stop), (0, _combi_1.sta)(Statements.Submit), (0, _combi_1.sta)(Statements.Summary), (0, _combi_1.sta)(Statements.SubtractCorresponding), (0, _combi_1.sta)(Statements.Subtract), (0, _combi_1.sta)(Statements.SuppressDialog), (0, _combi_1.sta)(Statements.Supply), (0, _combi_1.sta)(Statements.Sum), (0, _combi_1.sta)(Statements.SyntaxCheck), (0, _combi_1.sta)(Statements.SystemCall), (0, _combi_1.sta)(Statements.Tables), (0, _combi_1.sta)(Statements.Transfer), (0, _combi_1.sta)(Statements.Translate), (0, _combi_1.sta)(Statements.Type), (0, _combi_1.sta)(Statements.TypePools), (0, _combi_1.sta)(Statements.Uline), (0, _combi_1.sta)(Statements.Unassign), (0, _combi_1.sta)(Statements.Unpack), (0, _combi_1.sta)(Statements.UpdateDatabase), (0, _combi_1.sta)(Statements.Wait), (0, _combi_1.sta)(Statements.Window), (0, _combi_1.sta)(Statements.Write), (0, _combi_1.sta)(Statements.CommitEntities), (0, _combi_1.sta)(Statements.ModifyEntities), (0, _combi_1.sta)(Statements.ReadEntities), (0, _combi_1.sta)(Statements.RollbackEntities), (0, _combi_1.sub)(Structures.Define), (0, _combi_1.sub)(Structures.TestInjection), (0, _combi_1.sub)(Structures.TestSeam), (0, _combi_1.sub)(Structures.Provide), (0, _combi_1.sub)(Structures.CatchSystemExceptions), (0, _combi_1.sub)(Structures.At), (0, _combi_1.sub)(Structures.Constants), (0, _combi_1.sub)(Structures.Types), (0, _combi_1.sub)(Structures.Statics), (0, _combi_1.sub)(Structures.Select), (0, _combi_1.sub)(Structures.Data), (0, _combi_1.sub)(Structures.TypeEnum), (0, _combi_1.sub)(Structures.While), (0, _combi_1.sub)(Structures.With), (0, _combi_1.sub)(Structures.Do), (0, _combi_1.sub)(Structures.ExecSQL));
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
exports.Normal = Normal;
|
|
@@ -54,6 +54,25 @@ class CurrentScope {
|
|
|
54
54
|
}
|
|
55
55
|
this.current.getData().types[upper] = type;
|
|
56
56
|
}
|
|
57
|
+
addExtraLikeType(type) {
|
|
58
|
+
if (type === undefined) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this.addExtraLikeTypeNamed(type.getName(), type);
|
|
62
|
+
}
|
|
63
|
+
addExtraLikeTypeNamed(name, type) {
|
|
64
|
+
if (type === undefined) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (this.current === undefined) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const upper = name.toUpperCase();
|
|
71
|
+
if (this.current.getData().extraLikeTypes[upper] !== undefined) {
|
|
72
|
+
throw new Error(`Type name "${name}" already defined`);
|
|
73
|
+
}
|
|
74
|
+
this.current.getData().extraLikeTypes[upper] = type;
|
|
75
|
+
}
|
|
57
76
|
addClassDefinition(c) {
|
|
58
77
|
var _a;
|
|
59
78
|
(_a = this.current) === null || _a === void 0 ? void 0 : _a.getData().cdefs.push(c);
|
|
@@ -231,6 +250,13 @@ class CurrentScope {
|
|
|
231
250
|
}
|
|
232
251
|
return (_a = this.current) === null || _a === void 0 ? void 0 : _a.findType(name);
|
|
233
252
|
}
|
|
253
|
+
findExtraLikeType(name) {
|
|
254
|
+
var _a;
|
|
255
|
+
if (name === undefined) {
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
return (_a = this.current) === null || _a === void 0 ? void 0 : _a.findExtraLikeType(name);
|
|
259
|
+
}
|
|
234
260
|
findVariable(name) {
|
|
235
261
|
var _a;
|
|
236
262
|
if (name === undefined) {
|
|
@@ -14,6 +14,7 @@ var ScopeType;
|
|
|
14
14
|
ScopeType["Form"] = "form";
|
|
15
15
|
ScopeType["FunctionModule"] = "function";
|
|
16
16
|
ScopeType["Method"] = "method";
|
|
17
|
+
ScopeType["MethodInstance"] = "method_instance";
|
|
17
18
|
ScopeType["For"] = "for";
|
|
18
19
|
ScopeType["OpenSQL"] = "open_sql";
|
|
19
20
|
})(ScopeType = exports.ScopeType || (exports.ScopeType = {}));
|
|
@@ -79,8 +79,12 @@ class BasicTypes {
|
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
81
|
const name = children.shift().getFirstToken().getStr();
|
|
82
|
-
|
|
82
|
+
let found = this.scope.findVariable(name);
|
|
83
83
|
type = found === null || found === void 0 ? void 0 : found.getType();
|
|
84
|
+
if (found === undefined) {
|
|
85
|
+
found = this.scope.findExtraLikeType(name);
|
|
86
|
+
type = found === null || found === void 0 ? void 0 : found.getType();
|
|
87
|
+
}
|
|
84
88
|
if (found) {
|
|
85
89
|
this.scope.addReference(chain === null || chain === void 0 ? void 0 : chain.getFirstToken(), found, _reference_1.ReferenceType.TypeReference, this.filename);
|
|
86
90
|
}
|
|
@@ -12,6 +12,7 @@ class ScopeData {
|
|
|
12
12
|
idefs: [],
|
|
13
13
|
forms: [],
|
|
14
14
|
types: {},
|
|
15
|
+
extraLikeTypes: {},
|
|
15
16
|
deferred: [],
|
|
16
17
|
references: [],
|
|
17
18
|
};
|
|
@@ -126,6 +127,18 @@ class SpaghettiScopeNode extends ScopeData {
|
|
|
126
127
|
}
|
|
127
128
|
return undefined;
|
|
128
129
|
}
|
|
130
|
+
findExtraLikeType(name) {
|
|
131
|
+
let search = this;
|
|
132
|
+
const upper = name.toUpperCase();
|
|
133
|
+
while (search !== undefined) {
|
|
134
|
+
const data = search.getData();
|
|
135
|
+
if (data.extraLikeTypes[upper]) {
|
|
136
|
+
return data.extraLikeTypes[upper];
|
|
137
|
+
}
|
|
138
|
+
search = search.getParent();
|
|
139
|
+
}
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
129
142
|
findVariable(name) {
|
|
130
143
|
let search = this;
|
|
131
144
|
const upper = name.toUpperCase();
|
|
@@ -28,8 +28,10 @@ class ClassImplementation {
|
|
|
28
28
|
scope.addIdentifier(new _typed_identifier_1.TypedIdentifier(new tokens_1.Identifier(new position_1.Position(1, 1), "me"), _builtin_1.BuiltIn.filename, new basic_1.ObjectReferenceType(classDefinition)));
|
|
29
29
|
helper.addAliasedAttributes(classDefinition); // todo, this is not correct, take care of instance vs static
|
|
30
30
|
scope.addList(classAttributes.getConstants());
|
|
31
|
-
scope.addList(classAttributes.
|
|
32
|
-
|
|
31
|
+
scope.addList(classAttributes.getStatic());
|
|
32
|
+
for (const i of classAttributes.getInstance()) {
|
|
33
|
+
scope.addExtraLikeType(i);
|
|
34
|
+
}
|
|
33
35
|
const implemented = helper.fromSuperClass(classDefinition);
|
|
34
36
|
helper.fromInterfaces(classDefinition, implemented);
|
|
35
37
|
}
|
|
@@ -11,17 +11,21 @@ class MethodImplementation {
|
|
|
11
11
|
const className = scope.getName();
|
|
12
12
|
const methodToken = node.findFirstExpression(Expressions.MethodName).getFirstToken();
|
|
13
13
|
const methodName = methodToken === null || methodToken === void 0 ? void 0 : methodToken.getStr();
|
|
14
|
-
scope.push(_scope_type_1.ScopeType.Method, methodName, node.getFirstToken().getStart(), filename);
|
|
15
14
|
const classDefinition = scope.findClassDefinition(className);
|
|
16
15
|
if (classDefinition === undefined) {
|
|
17
|
-
scope.pop(node.getLastToken().getEnd());
|
|
16
|
+
// scope.pop(node.getLastToken().getEnd());
|
|
18
17
|
throw new Error("Class definition for \"" + className + "\" not found");
|
|
19
18
|
}
|
|
20
19
|
const { method: methodDefinition } = helper.searchMethodName(classDefinition, methodName);
|
|
21
20
|
if (methodDefinition === undefined) {
|
|
22
|
-
scope.pop(node.getLastToken().getEnd());
|
|
21
|
+
// scope.pop(node.getLastToken().getEnd());
|
|
23
22
|
throw new Error("Method definition \"" + methodName + "\" not found");
|
|
24
23
|
}
|
|
24
|
+
if (methodDefinition.isStatic() === false) {
|
|
25
|
+
scope.push(_scope_type_1.ScopeType.MethodInstance, methodName, node.getFirstToken().getStart(), filename);
|
|
26
|
+
scope.addList(classDefinition.getAttributes().getInstance());
|
|
27
|
+
}
|
|
28
|
+
scope.push(_scope_type_1.ScopeType.Method, methodName, node.getFirstToken().getStart(), filename);
|
|
25
29
|
scope.addReference(methodToken, methodDefinition, _reference_1.ReferenceType.MethodImplementationReference, filename);
|
|
26
30
|
scope.addList(methodDefinition.getParameters().getAll());
|
|
27
31
|
for (const i of helper.findInterfaces(classDefinition)) {
|
|
@@ -11,6 +11,7 @@ const component_compare_simple_1 = require("../expressions/component_compare_sim
|
|
|
11
11
|
const _type_utils_1 = require("../_type_utils");
|
|
12
12
|
class ReadTable {
|
|
13
13
|
runSyntax(node, scope, filename) {
|
|
14
|
+
const concat = node.concatTokens().toUpperCase();
|
|
14
15
|
const sources = node.findDirectExpressions(Expressions.Source);
|
|
15
16
|
let firstSource = node.findDirectExpression(Expressions.SimpleSource2);
|
|
16
17
|
if (firstSource === undefined) {
|
|
@@ -53,6 +54,9 @@ class ReadTable {
|
|
|
53
54
|
}
|
|
54
55
|
const target = node.findDirectExpression(Expressions.ReadTableTarget);
|
|
55
56
|
if (target) {
|
|
57
|
+
if (concat.includes(" REFERENCE INTO ")) {
|
|
58
|
+
rowType = new basic_1.DataReference(rowType);
|
|
59
|
+
}
|
|
56
60
|
const inline = target.findFirstExpression(Expressions.InlineData);
|
|
57
61
|
if (inline) {
|
|
58
62
|
new inline_data_1.InlineData().runSyntax(inline, scope, filename, rowType);
|
|
@@ -76,7 +80,6 @@ class ReadTable {
|
|
|
76
80
|
return;
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
|
-
const concat = node.concatTokens().toUpperCase();
|
|
80
83
|
if (target === undefined && concat.includes(" TRANSPORTING NO FIELDS ") === false) {
|
|
81
84
|
// if sourceType is void, assume its with header
|
|
82
85
|
if (sourceType instanceof basic_1.TableType && sourceType.isWithHeader() === false) {
|
|
@@ -412,11 +412,16 @@ class SyntaxLogic {
|
|
|
412
412
|
}
|
|
413
413
|
else if (s instanceof Statements.EndForm
|
|
414
414
|
|| s instanceof Statements.EndFunction
|
|
415
|
-
|| s instanceof Statements.EndMethod
|
|
416
415
|
|| s instanceof Statements.EndClass
|
|
417
416
|
|| s instanceof Statements.EndInterface) {
|
|
418
417
|
this.scope.pop(node.getLastToken().getEnd());
|
|
419
418
|
}
|
|
419
|
+
else if (s instanceof Statements.EndMethod) {
|
|
420
|
+
this.scope.pop(node.getLastToken().getEnd());
|
|
421
|
+
if (this.scope.getType() === _scope_type_1.ScopeType.MethodInstance) {
|
|
422
|
+
this.scope.pop(node.getLastToken().getEnd());
|
|
423
|
+
}
|
|
424
|
+
}
|
|
420
425
|
}
|
|
421
426
|
}
|
|
422
427
|
exports.SyntaxLogic = SyntaxLogic;
|
package/build/src/edit_helper.js
CHANGED
|
@@ -97,11 +97,12 @@ class EditHelper {
|
|
|
97
97
|
if (scolon === undefined) {
|
|
98
98
|
return EditHelper.deleteRange(file, statement.getFirstToken().getStart(), statement.getLastToken().getEnd());
|
|
99
99
|
}
|
|
100
|
-
// find statements part of chain
|
|
101
|
-
let chainCount = 0;
|
|
102
100
|
let setPrevious = true;
|
|
101
|
+
let setNext = true;
|
|
103
102
|
/** previous statement in the chain */
|
|
104
103
|
let previousStatement = undefined;
|
|
104
|
+
/** next statement in the chain */
|
|
105
|
+
let nextStatement = undefined;
|
|
105
106
|
for (const s of file.getStatements()) {
|
|
106
107
|
const colon = s.getColon();
|
|
107
108
|
if (colon === undefined) {
|
|
@@ -109,16 +110,18 @@ class EditHelper {
|
|
|
109
110
|
}
|
|
110
111
|
else if (s === statement) {
|
|
111
112
|
setPrevious = false;
|
|
113
|
+
setNext = true;
|
|
112
114
|
continue;
|
|
113
115
|
}
|
|
114
|
-
else if (
|
|
115
|
-
chainCount = chainCount + 1;
|
|
116
|
-
}
|
|
117
|
-
if (setPrevious === true) {
|
|
116
|
+
else if (setPrevious === true) {
|
|
118
117
|
previousStatement = s;
|
|
119
118
|
}
|
|
119
|
+
else if (setNext === true) {
|
|
120
|
+
nextStatement = s;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
120
123
|
}
|
|
121
|
-
if (
|
|
124
|
+
if (previousStatement === undefined && nextStatement === undefined) {
|
|
122
125
|
// the statement to be deleted is the only one in the chain
|
|
123
126
|
return EditHelper.deleteRange(file, statement.getFirstToken().getStart(), statement.getLastToken().getEnd());
|
|
124
127
|
}
|
|
@@ -130,14 +133,30 @@ class EditHelper {
|
|
|
130
133
|
break;
|
|
131
134
|
}
|
|
132
135
|
}
|
|
136
|
+
const colon = statement.getColon();
|
|
133
137
|
if (statement.getLastToken().getStr() === "." && previousStatement) {
|
|
138
|
+
// last statement in chain
|
|
134
139
|
const edit1 = EditHelper.replaceToken(file, previousStatement.getLastToken(), ".");
|
|
135
|
-
const edit2 = EditHelper.deleteRange(file,
|
|
140
|
+
const edit2 = EditHelper.deleteRange(file, previousStatement.getLastToken().getEnd(), statement.getLastToken().getEnd());
|
|
136
141
|
return EditHelper.merge(edit1, edit2);
|
|
137
142
|
}
|
|
143
|
+
else if (previousStatement === undefined && colon && nextStatement) {
|
|
144
|
+
// first statement in chain
|
|
145
|
+
return EditHelper.deleteRange(file, this.firstAfterColon(statement), this.firstAfterColon(nextStatement));
|
|
146
|
+
}
|
|
138
147
|
else {
|
|
139
|
-
|
|
148
|
+
// middle statement
|
|
149
|
+
return EditHelper.deleteRange(file, startDelete, this.firstAfterColon(nextStatement));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
static firstAfterColon(statement) {
|
|
153
|
+
const colon = statement.getColon().getStart();
|
|
154
|
+
for (const t of statement.getTokens()) {
|
|
155
|
+
if (t.getStart().isAfter(colon)) {
|
|
156
|
+
return t.getStart();
|
|
157
|
+
}
|
|
140
158
|
}
|
|
159
|
+
throw new Error("firstAfterColon, emtpy statement?");
|
|
141
160
|
}
|
|
142
161
|
static deleteToken(file, token) {
|
|
143
162
|
const filename = file.getFilename();
|
package/build/src/registry.js
CHANGED
package/build/src/rules/index.js
CHANGED
|
@@ -92,6 +92,7 @@ __exportStar(require("./msag_consistency"), exports);
|
|
|
92
92
|
__exportStar(require("./names_no_dash"), exports);
|
|
93
93
|
__exportStar(require("./nesting"), exports);
|
|
94
94
|
__exportStar(require("./newline_between_methods"), exports);
|
|
95
|
+
__exportStar(require("./no_chained_assignment"), exports);
|
|
95
96
|
__exportStar(require("./no_public_attributes"), exports);
|
|
96
97
|
__exportStar(require("./no_yoda_conditions"), exports);
|
|
97
98
|
__exportStar(require("./object_naming"), exports);
|
|
@@ -131,6 +132,7 @@ __exportStar(require("./type_form_parameters"), exports);
|
|
|
131
132
|
__exportStar(require("./types_naming"), exports);
|
|
132
133
|
__exportStar(require("./uncaught_exception"), exports);
|
|
133
134
|
__exportStar(require("./unknown_types"), exports);
|
|
135
|
+
__exportStar(require("./unnecessary_chaining"), exports);
|
|
134
136
|
__exportStar(require("./unreachable_code"), exports);
|
|
135
137
|
__exportStar(require("./unsecure_fae"), exports);
|
|
136
138
|
__exportStar(require("./unused_ddic"), exports);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NoChainedAssignment = exports.NoChainedAssignmentConf = void 0;
|
|
4
|
+
const Expressions = require("../abap/2_statements/expressions");
|
|
5
|
+
const Statements = require("../abap/2_statements/statements");
|
|
6
|
+
const issue_1 = require("../issue");
|
|
7
|
+
const _abap_rule_1 = require("./_abap_rule");
|
|
8
|
+
const _basic_rule_config_1 = require("./_basic_rule_config");
|
|
9
|
+
const _irule_1 = require("./_irule");
|
|
10
|
+
class NoChainedAssignmentConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
11
|
+
}
|
|
12
|
+
exports.NoChainedAssignmentConf = NoChainedAssignmentConf;
|
|
13
|
+
class NoChainedAssignment extends _abap_rule_1.ABAPRule {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.conf = new NoChainedAssignmentConf();
|
|
17
|
+
}
|
|
18
|
+
getMetadata() {
|
|
19
|
+
return {
|
|
20
|
+
key: "no_chained_assignment",
|
|
21
|
+
title: "No chained assignment",
|
|
22
|
+
shortDescription: `Find chained assingments and reports issues`,
|
|
23
|
+
extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#dont-chain-assignments`,
|
|
24
|
+
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Styleguide],
|
|
25
|
+
badExample: `var1 = var2 = var3.`,
|
|
26
|
+
goodExample: `var2 = var3.
|
|
27
|
+
var1 = var2.`,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
getConfig() {
|
|
31
|
+
return this.conf;
|
|
32
|
+
}
|
|
33
|
+
setConfig(conf) {
|
|
34
|
+
this.conf = conf;
|
|
35
|
+
}
|
|
36
|
+
runParsed(file) {
|
|
37
|
+
const issues = [];
|
|
38
|
+
for (const s of file.getStatements()) {
|
|
39
|
+
if (!(s.get() instanceof Statements.Move)) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (s.findDirectExpressions(Expressions.Target).length >= 2) {
|
|
43
|
+
const message = "No chained assignment";
|
|
44
|
+
const issue = issue_1.Issue.atStatement(file, s, message, this.getMetadata().key);
|
|
45
|
+
issues.push(issue);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return issues;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.NoChainedAssignment = NoChainedAssignment;
|
|
52
|
+
//# sourceMappingURL=no_chained_assignment.js.map
|
|
@@ -74,7 +74,7 @@ DATA(percentage) = CONV decfloat34( comment_number / abs_statement_number ) * 10
|
|
|
74
74
|
}
|
|
75
75
|
///////////////////////////
|
|
76
76
|
analyzeScope(node, obj) {
|
|
77
|
-
var _a;
|
|
77
|
+
var _a, _b;
|
|
78
78
|
const ret = [];
|
|
79
79
|
const vars = node.getData().vars;
|
|
80
80
|
for (const name in vars) {
|
|
@@ -113,7 +113,8 @@ DATA(percentage) = CONV decfloat34( comment_number / abs_statement_number ) * 10
|
|
|
113
113
|
|| statementType instanceof Statements.Catch
|
|
114
114
|
|| statementType instanceof Statements.ReadTable
|
|
115
115
|
|| statementType instanceof Statements.Loop)
|
|
116
|
-
|| ((_a = writeStatement === null || writeStatement === void 0 ? void 0 : writeStatement.concatTokens()) === null || _a === void 0 ? void 0 : _a.includes("?="))
|
|
116
|
+
|| ((_a = writeStatement === null || writeStatement === void 0 ? void 0 : writeStatement.concatTokens()) === null || _a === void 0 ? void 0 : _a.includes("?="))
|
|
117
|
+
|| ((_b = writeStatement === null || writeStatement === void 0 ? void 0 : writeStatement.concatTokens()) === null || _b === void 0 ? void 0 : _b.includes(" #("))) {
|
|
117
118
|
continue;
|
|
118
119
|
}
|
|
119
120
|
const statement = edit_helper_1.EditHelper.findStatement(identifier.getToken(), file);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnnecessaryChaining = exports.UnnecessaryChainingConf = 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
|
+
class UnnecessaryChainingConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
9
|
+
}
|
|
10
|
+
exports.UnnecessaryChainingConf = UnnecessaryChainingConf;
|
|
11
|
+
class UnnecessaryChaining extends _abap_rule_1.ABAPRule {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.conf = new UnnecessaryChainingConf();
|
|
15
|
+
}
|
|
16
|
+
getMetadata() {
|
|
17
|
+
return {
|
|
18
|
+
key: "unnecessary_chaining",
|
|
19
|
+
title: "Unnecessary Chaining",
|
|
20
|
+
shortDescription: `Find unnecessary chaining, all statements are checked`,
|
|
21
|
+
extendedInformation: ``,
|
|
22
|
+
tags: [_irule_1.RuleTag.SingleFile],
|
|
23
|
+
badExample: `WRITE: bar.`,
|
|
24
|
+
goodExample: `WRITE bar.`,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
getConfig() {
|
|
28
|
+
return this.conf;
|
|
29
|
+
}
|
|
30
|
+
setConfig(conf) {
|
|
31
|
+
this.conf = conf;
|
|
32
|
+
}
|
|
33
|
+
runParsed(file) {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
const issues = [];
|
|
36
|
+
const statements = file.getStatements();
|
|
37
|
+
for (let i = 0; i < statements.length; i++) {
|
|
38
|
+
const colon = statements[i].getColon();
|
|
39
|
+
if (colon === undefined) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const next = (_a = statements[i + 1]) === null || _a === void 0 ? void 0 : _a.getColon();
|
|
43
|
+
const prev = (_b = statements[i - 1]) === null || _b === void 0 ? void 0 : _b.getColon();
|
|
44
|
+
if (next !== undefined && colon.getStart().equals(next.getStart())) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
else if (prev !== undefined && colon.getStart().equals(prev.getStart())) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const message = "Unnecessary chaining";
|
|
51
|
+
const issue = issue_1.Issue.atStatement(file, statements[i], message, this.getMetadata().key);
|
|
52
|
+
issues.push(issue);
|
|
53
|
+
}
|
|
54
|
+
return issues;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.UnnecessaryChaining = UnnecessaryChaining;
|
|
58
|
+
//# sourceMappingURL=unnecessary_chaining.js.map
|
|
@@ -67,6 +67,10 @@ class UnreachableCode extends _abap_rule_1.ABAPRule {
|
|
|
67
67
|
return true;
|
|
68
68
|
}
|
|
69
69
|
else if (s instanceof Statements.Leave && n.findFirstExpression(Expressions.AndReturn) === undefined) {
|
|
70
|
+
const concat = n.concatTokens();
|
|
71
|
+
if (concat.includes(" TO LIST-PROCESSING")) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
70
74
|
return true;
|
|
71
75
|
}
|
|
72
76
|
else if (s instanceof Statements.Return
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.81.2",
|
|
4
4
|
"description": "abaplint - Core API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/abaplint.d.ts",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"test:parallel": "npm run compile && mocha --timeout 1000 --parallel --reporter dot",
|
|
14
14
|
"coverage": "npm run compile && c8 mocha && c8 report --reporter=html",
|
|
15
15
|
"schema": "node scripts/schema.js > scripts/schema.ts && ts-json-schema-generator --tsconfig tsconfig_schema.json --jsDoc extended --path scripts/schema.ts > scripts/schema.json && node scripts/schema_post.js",
|
|
16
|
+
"publish:minor": "npm --no-git-tag-version version minor && rm -rf build && npm install && npm run test && npm publish --access public",
|
|
16
17
|
"publish:patch": "npm --no-git-tag-version version patch && rm -rf build && npm install && npm run test && npm publish --access public"
|
|
17
18
|
},
|
|
18
19
|
"mocha": {
|
|
@@ -47,14 +48,14 @@
|
|
|
47
48
|
"@microsoft/api-extractor": "^7.18.19",
|
|
48
49
|
"@types/chai": "^4.2.22",
|
|
49
50
|
"@types/mocha": "^9.0.0",
|
|
50
|
-
"@types/node": "^16.11.
|
|
51
|
+
"@types/node": "^16.11.9",
|
|
51
52
|
"chai": "^4.3.4",
|
|
52
53
|
"eslint": "^8.2.0",
|
|
53
54
|
"mocha": "^9.1.3",
|
|
54
55
|
"c8": "^7.10.0",
|
|
55
|
-
"source-map-support": "^0.5.
|
|
56
|
+
"source-map-support": "^0.5.21",
|
|
56
57
|
"ts-json-schema-generator": "^0.97.0",
|
|
57
|
-
"typescript": "^4.
|
|
58
|
+
"typescript": "^4.5.2"
|
|
58
59
|
},
|
|
59
60
|
"dependencies": {
|
|
60
61
|
"fast-xml-parser": "^3.21.1",
|