@abaplint/cli 2.120.77 → 2.120.78
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/cli.js +449 -5
- package/package.json +2 -2
package/build/cli.js
CHANGED
|
@@ -71373,7 +71373,7 @@ class Registry {
|
|
|
71373
71373
|
}
|
|
71374
71374
|
static abaplintVersion() {
|
|
71375
71375
|
// magic, see build script "version.js"
|
|
71376
|
-
return "2.120.
|
|
71376
|
+
return "2.120.78";
|
|
71377
71377
|
}
|
|
71378
71378
|
getDDICReferences() {
|
|
71379
71379
|
return this.ddicReferences;
|
|
@@ -87122,6 +87122,7 @@ __exportStar(__webpack_require__(/*! ./inline_data_old_versions */ "../core/buil
|
|
|
87122
87122
|
__exportStar(__webpack_require__(/*! ./inline_packed_computation */ "../core/build/src/rules/inline_packed_computation.js"), exports);
|
|
87123
87123
|
__exportStar(__webpack_require__(/*! ./intf_referencing_clas */ "../core/build/src/rules/intf_referencing_clas.js"), exports);
|
|
87124
87124
|
__exportStar(__webpack_require__(/*! ./invalid_table_index */ "../core/build/src/rules/invalid_table_index.js"), exports);
|
|
87125
|
+
__exportStar(__webpack_require__(/*! ./is_assigned_in_loop */ "../core/build/src/rules/is_assigned_in_loop.js"), exports);
|
|
87125
87126
|
__exportStar(__webpack_require__(/*! ./keep_single_parameter_on_one_line */ "../core/build/src/rules/keep_single_parameter_on_one_line.js"), exports);
|
|
87126
87127
|
__exportStar(__webpack_require__(/*! ./keyword_case */ "../core/build/src/rules/keyword_case.js"), exports);
|
|
87127
87128
|
__exportStar(__webpack_require__(/*! ./line_break_multiple_parameters */ "../core/build/src/rules/line_break_multiple_parameters.js"), exports);
|
|
@@ -87187,6 +87188,7 @@ __exportStar(__webpack_require__(/*! ./prefix_is_current_class */ "../core/build
|
|
|
87187
87188
|
__exportStar(__webpack_require__(/*! ./range_row_values */ "../core/build/src/rules/range_row_values.js"), exports);
|
|
87188
87189
|
__exportStar(__webpack_require__(/*! ./reduce_procedural_code */ "../core/build/src/rules/reduce_procedural_code.js"), exports);
|
|
87189
87190
|
__exportStar(__webpack_require__(/*! ./reduce_string_templates */ "../core/build/src/rules/reduce_string_templates.js"), exports);
|
|
87191
|
+
__exportStar(__webpack_require__(/*! ./redundant_cast */ "../core/build/src/rules/redundant_cast.js"), exports);
|
|
87190
87192
|
__exportStar(__webpack_require__(/*! ./redundant_conversion */ "../core/build/src/rules/redundant_conversion.js"), exports);
|
|
87191
87193
|
__exportStar(__webpack_require__(/*! ./release_idoc */ "../core/build/src/rules/release_idoc.js"), exports);
|
|
87192
87194
|
__exportStar(__webpack_require__(/*! ./remove_descriptions */ "../core/build/src/rules/remove_descriptions.js"), exports);
|
|
@@ -87871,6 +87873,258 @@ exports.InvalidTableIndex = InvalidTableIndex;
|
|
|
87871
87873
|
|
|
87872
87874
|
/***/ },
|
|
87873
87875
|
|
|
87876
|
+
/***/ "../core/build/src/rules/is_assigned_in_loop.js"
|
|
87877
|
+
/*!******************************************************!*\
|
|
87878
|
+
!*** ../core/build/src/rules/is_assigned_in_loop.js ***!
|
|
87879
|
+
\******************************************************/
|
|
87880
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
87881
|
+
|
|
87882
|
+
"use strict";
|
|
87883
|
+
|
|
87884
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
87885
|
+
if (k2 === undefined) k2 = k;
|
|
87886
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
87887
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
87888
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
87889
|
+
}
|
|
87890
|
+
Object.defineProperty(o, k2, desc);
|
|
87891
|
+
}) : (function(o, m, k, k2) {
|
|
87892
|
+
if (k2 === undefined) k2 = k;
|
|
87893
|
+
o[k2] = m[k];
|
|
87894
|
+
}));
|
|
87895
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
87896
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
87897
|
+
}) : function(o, v) {
|
|
87898
|
+
o["default"] = v;
|
|
87899
|
+
});
|
|
87900
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
87901
|
+
var ownKeys = function(o) {
|
|
87902
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
87903
|
+
var ar = [];
|
|
87904
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
87905
|
+
return ar;
|
|
87906
|
+
};
|
|
87907
|
+
return ownKeys(o);
|
|
87908
|
+
};
|
|
87909
|
+
return function (mod) {
|
|
87910
|
+
if (mod && mod.__esModule) return mod;
|
|
87911
|
+
var result = {};
|
|
87912
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
87913
|
+
__setModuleDefault(result, mod);
|
|
87914
|
+
return result;
|
|
87915
|
+
};
|
|
87916
|
+
})();
|
|
87917
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
87918
|
+
exports.IsAssignedInLoop = exports.IsAssignedInLoopConf = void 0;
|
|
87919
|
+
const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
|
|
87920
|
+
const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
|
|
87921
|
+
const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
|
|
87922
|
+
const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
|
|
87923
|
+
const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
|
|
87924
|
+
const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
|
|
87925
|
+
const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
|
|
87926
|
+
const severity_1 = __webpack_require__(/*! ../severity */ "../core/build/src/severity.js");
|
|
87927
|
+
class IsAssignedInLoopConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
87928
|
+
constructor() {
|
|
87929
|
+
super(...arguments);
|
|
87930
|
+
this.severity = severity_1.Severity.Warning;
|
|
87931
|
+
}
|
|
87932
|
+
}
|
|
87933
|
+
exports.IsAssignedInLoopConf = IsAssignedInLoopConf;
|
|
87934
|
+
class IsAssignedInLoop extends _abap_rule_1.ABAPRule {
|
|
87935
|
+
constructor() {
|
|
87936
|
+
super(...arguments);
|
|
87937
|
+
this.conf = new IsAssignedInLoopConf();
|
|
87938
|
+
}
|
|
87939
|
+
getMetadata() {
|
|
87940
|
+
return {
|
|
87941
|
+
key: "is_assigned_in_loop",
|
|
87942
|
+
title: "IS ASSIGNED after READ TABLE or ASSIGN in a loop",
|
|
87943
|
+
shortDescription: `Reports IS [NOT] ASSIGNED after a READ TABLE ... ASSIGNING or ASSIGN inside a loop, without UNASSIGN before it`,
|
|
87944
|
+
extendedInformation: `A failed READ TABLE ... ASSIGNING or ASSIGN keeps the previous binding of the field symbol. Inside a
|
|
87945
|
+
loop, the field symbol still points to the row of an earlier iteration, so IS ASSIGNED is true
|
|
87946
|
+
although the statement failed, and the code goes on with the wrong row.
|
|
87947
|
+
|
|
87948
|
+
Add UNASSIGN <fs> before the statement, inside the loop, or check sy-subrc after a READ TABLE.
|
|
87949
|
+
The quick fix inserts the UNASSIGN; it is not offered for a field symbol declared inline in
|
|
87950
|
+
the statement, or for a chained statement.
|
|
87951
|
+
|
|
87952
|
+
Not reported: a check that also reads sy-subrc, an ASSIGN that cannot fail (a static source
|
|
87953
|
+
without dereference, table expression or dynamic part), and loops outside of the
|
|
87954
|
+
method, form or function module of the statement. See also subrc_after_assign.`,
|
|
87955
|
+
tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
|
|
87956
|
+
badExample: `LOOP AT lt_cells INTO ls_cell.
|
|
87957
|
+
READ TABLE lt_styles ASSIGNING <style> WITH KEY id = ls_cell-style.
|
|
87958
|
+
IF <style> IS ASSIGNED.
|
|
87959
|
+
ls_cell-format = <style>-format.
|
|
87960
|
+
ENDIF.
|
|
87961
|
+
ENDLOOP.`,
|
|
87962
|
+
goodExample: `LOOP AT lt_cells INTO ls_cell.
|
|
87963
|
+
UNASSIGN <style>.
|
|
87964
|
+
READ TABLE lt_styles ASSIGNING <style> WITH KEY id = ls_cell-style.
|
|
87965
|
+
IF <style> IS ASSIGNED.
|
|
87966
|
+
ls_cell-format = <style>-format.
|
|
87967
|
+
ENDIF.
|
|
87968
|
+
ENDLOOP.`,
|
|
87969
|
+
};
|
|
87970
|
+
}
|
|
87971
|
+
getConfig() {
|
|
87972
|
+
return this.conf;
|
|
87973
|
+
}
|
|
87974
|
+
setConfig(conf) {
|
|
87975
|
+
this.conf = conf;
|
|
87976
|
+
}
|
|
87977
|
+
runParsed(file) {
|
|
87978
|
+
const issues = [];
|
|
87979
|
+
const statements = file.getStatements();
|
|
87980
|
+
for (let i = 0; i < statements.length; i++) {
|
|
87981
|
+
const statement = statements[i];
|
|
87982
|
+
const name = this.boundByFailable(statement);
|
|
87983
|
+
if (name === undefined) {
|
|
87984
|
+
continue;
|
|
87985
|
+
}
|
|
87986
|
+
const fs = name.toUpperCase();
|
|
87987
|
+
const loop = this.innermostLoop(i, statements);
|
|
87988
|
+
if (loop === undefined || this.unassignedBefore(loop, i, statements, fs) === true) {
|
|
87989
|
+
continue;
|
|
87990
|
+
}
|
|
87991
|
+
const check = this.nextCheck(i, statements, fs);
|
|
87992
|
+
if (check === undefined) {
|
|
87993
|
+
continue;
|
|
87994
|
+
}
|
|
87995
|
+
const read = statement.get() instanceof Statements.ReadTable;
|
|
87996
|
+
const message = `${read ? "READ TABLE" : "ASSIGN"} in a loop keeps the previous binding of ${name} when it fails, `
|
|
87997
|
+
+ `UNASSIGN ${name} before it` + (read ? " or check sy-subrc" : "");
|
|
87998
|
+
const fix = this.buildFix(file, statement, name);
|
|
87999
|
+
issues.push(issue_1.Issue.atStatement(file, check, message, this.getMetadata().key, this.conf.severity, fix));
|
|
88000
|
+
}
|
|
88001
|
+
return issues;
|
|
88002
|
+
}
|
|
88003
|
+
////////////////
|
|
88004
|
+
/** the field symbol bound by a READ TABLE ... ASSIGNING or an ASSIGN that can fail */
|
|
88005
|
+
boundByFailable(statement) {
|
|
88006
|
+
var _a, _b, _c;
|
|
88007
|
+
const s = statement.get();
|
|
88008
|
+
if (s instanceof Statements.ReadTable) {
|
|
88009
|
+
const target = (_a = statement.findDirectExpression(Expressions.ReadTableTarget)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.FSTarget);
|
|
88010
|
+
return (_b = target === null || target === void 0 ? void 0 : target.findFirstExpression(Expressions.FieldSymbol)) === null || _b === void 0 ? void 0 : _b.concatTokens();
|
|
88011
|
+
}
|
|
88012
|
+
else if (s instanceof Statements.Assign) {
|
|
88013
|
+
const source = statement.findDirectExpression(Expressions.AssignSource);
|
|
88014
|
+
if (source === undefined) {
|
|
88015
|
+
return undefined;
|
|
88016
|
+
}
|
|
88017
|
+
const first = source.getFirstToken().getStr().toUpperCase();
|
|
88018
|
+
const failable = first === "COMPONENT"
|
|
88019
|
+
|| first === "TABLE"
|
|
88020
|
+
|| source.findFirstExpression(Expressions.Dynamic) !== undefined
|
|
88021
|
+
|| source.findFirstExpression(Expressions.Dereference) !== undefined
|
|
88022
|
+
|| source.findFirstExpression(Expressions.TableExpression) !== undefined
|
|
88023
|
+
|| statement.findDirectTokenByText("INCREMENT") !== undefined;
|
|
88024
|
+
if (failable === false) {
|
|
88025
|
+
return undefined;
|
|
88026
|
+
}
|
|
88027
|
+
const target = statement.findDirectExpression(Expressions.FSTarget);
|
|
88028
|
+
return (_c = target === null || target === void 0 ? void 0 : target.findFirstExpression(Expressions.FieldSymbol)) === null || _c === void 0 ? void 0 : _c.concatTokens();
|
|
88029
|
+
}
|
|
88030
|
+
return undefined;
|
|
88031
|
+
}
|
|
88032
|
+
/** index of the innermost LOOP, DO, WHILE or SELECT loop around the statement, in the same block */
|
|
88033
|
+
innermostLoop(index, statements) {
|
|
88034
|
+
let depth = 0;
|
|
88035
|
+
for (let i = index - 1; i >= 0 && this.startsBlock(statements[i]) === false; i--) {
|
|
88036
|
+
if (this.endsLoop(statements[i])) {
|
|
88037
|
+
depth++;
|
|
88038
|
+
}
|
|
88039
|
+
else if (this.startsLoop(statements[i])) {
|
|
88040
|
+
if (depth === 0) {
|
|
88041
|
+
return i;
|
|
88042
|
+
}
|
|
88043
|
+
depth--;
|
|
88044
|
+
}
|
|
88045
|
+
}
|
|
88046
|
+
return undefined;
|
|
88047
|
+
}
|
|
88048
|
+
unassignedBefore(loop, index, statements, fs) {
|
|
88049
|
+
for (let i = loop + 1; i < index; i++) {
|
|
88050
|
+
if (statements[i].get() instanceof Statements.Unassign && this.mentions(statements[i], fs)) {
|
|
88051
|
+
return true;
|
|
88052
|
+
}
|
|
88053
|
+
}
|
|
88054
|
+
return false;
|
|
88055
|
+
}
|
|
88056
|
+
/** the first IS [NOT] ASSIGNED of the field symbol after the statement, before the end of the loop
|
|
88057
|
+
* or another UNASSIGN or binding of it; a check that also reads sy-subrc is fine */
|
|
88058
|
+
nextCheck(index, statements, fs) {
|
|
88059
|
+
let depth = 0;
|
|
88060
|
+
for (let i = index + 1; i < statements.length && this.startsBlock(statements[i]) === false; i++) {
|
|
88061
|
+
const statement = statements[i];
|
|
88062
|
+
if (this.startsLoop(statement)) {
|
|
88063
|
+
depth++;
|
|
88064
|
+
}
|
|
88065
|
+
else if (this.endsLoop(statement)) {
|
|
88066
|
+
if (depth === 0) {
|
|
88067
|
+
return undefined;
|
|
88068
|
+
}
|
|
88069
|
+
depth--;
|
|
88070
|
+
}
|
|
88071
|
+
const concat = statement.concatTokens().toUpperCase();
|
|
88072
|
+
if (concat.includes(fs + " IS ASSIGNED") || concat.includes(fs + " IS NOT ASSIGNED")) {
|
|
88073
|
+
return concat.includes("SY-SUBRC") ? undefined : statement;
|
|
88074
|
+
}
|
|
88075
|
+
if ((statement.get() instanceof Statements.Unassign && this.mentions(statement, fs))
|
|
88076
|
+
|| this.binds(statement, fs)) {
|
|
88077
|
+
return undefined;
|
|
88078
|
+
}
|
|
88079
|
+
}
|
|
88080
|
+
return undefined;
|
|
88081
|
+
}
|
|
88082
|
+
mentions(statement, fs) {
|
|
88083
|
+
return statement.findAllExpressions(Expressions.FieldSymbol).some(e => e.concatTokens().toUpperCase() === fs);
|
|
88084
|
+
}
|
|
88085
|
+
binds(statement, fs) {
|
|
88086
|
+
return statement.findAllExpressions(Expressions.FSTarget)
|
|
88087
|
+
.some(t => { var _a; return ((_a = t.findFirstExpression(Expressions.FieldSymbol)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase()) === fs; });
|
|
88088
|
+
}
|
|
88089
|
+
startsLoop(statement) {
|
|
88090
|
+
const s = statement.get();
|
|
88091
|
+
return s instanceof Statements.Loop
|
|
88092
|
+
|| s instanceof Statements.Do
|
|
88093
|
+
|| s instanceof Statements.While
|
|
88094
|
+
|| s instanceof Statements.SelectLoop;
|
|
88095
|
+
}
|
|
88096
|
+
endsLoop(statement) {
|
|
88097
|
+
const s = statement.get();
|
|
88098
|
+
return s instanceof Statements.EndLoop
|
|
88099
|
+
|| s instanceof Statements.EndDo
|
|
88100
|
+
|| s instanceof Statements.EndWhile
|
|
88101
|
+
|| s instanceof Statements.EndSelect;
|
|
88102
|
+
}
|
|
88103
|
+
startsBlock(statement) {
|
|
88104
|
+
const s = statement.get();
|
|
88105
|
+
return s instanceof Statements.MethodImplementation
|
|
88106
|
+
|| s instanceof Statements.Form
|
|
88107
|
+
|| s instanceof Statements.FunctionModule
|
|
88108
|
+
|| s instanceof Statements.Module
|
|
88109
|
+
|| s instanceof Statements.EndMethod
|
|
88110
|
+
|| s instanceof Statements.EndForm
|
|
88111
|
+
|| s instanceof Statements.EndFunction
|
|
88112
|
+
|| s instanceof Statements.EndModule;
|
|
88113
|
+
}
|
|
88114
|
+
/** UNASSIGN on a line of its own before the statement, with the same indentation */
|
|
88115
|
+
buildFix(file, statement, name) {
|
|
88116
|
+
if (statement.getColon() !== undefined || statement.findFirstExpression(Expressions.InlineFS) !== undefined) {
|
|
88117
|
+
return undefined;
|
|
88118
|
+
}
|
|
88119
|
+
const start = statement.getStart();
|
|
88120
|
+
return edit_helper_1.EditHelper.insertAt(file, start, `UNASSIGN ${name}.\n` + " ".repeat(start.getCol() - 1));
|
|
88121
|
+
}
|
|
88122
|
+
}
|
|
88123
|
+
exports.IsAssignedInLoop = IsAssignedInLoop;
|
|
88124
|
+
//# sourceMappingURL=is_assigned_in_loop.js.map
|
|
88125
|
+
|
|
88126
|
+
/***/ },
|
|
88127
|
+
|
|
87874
88128
|
/***/ "../core/build/src/rules/keep_single_parameter_on_one_line.js"
|
|
87875
88129
|
/*!********************************************************************!*\
|
|
87876
88130
|
!*** ../core/build/src/rules/keep_single_parameter_on_one_line.js ***!
|
|
@@ -89570,7 +89824,11 @@ ENDIF.
|
|
|
89570
89824
|
&& lastChildren[1].getChildren().length === 1
|
|
89571
89825
|
&& lastChildren[1].getFirstToken().getStr().startsWith("-") === false
|
|
89572
89826
|
&& lastChildren[2].getFirstToken().getStr() === ")") {
|
|
89573
|
-
const
|
|
89827
|
+
const fixText = lastChildren[1].concatTokens();
|
|
89828
|
+
const start = lastChildren[0].getFirstToken().getStart();
|
|
89829
|
+
const end = lastChildren[2].getLastToken().getEnd();
|
|
89830
|
+
const fix = edit_helper_1.EditHelper.replaceRange(file, start, end, fixText);
|
|
89831
|
+
const issue = issue_1.Issue.atToken(file, lastChildren[0].getFirstToken(), "Too many parentheses", this.getMetadata().key, this.conf.severity, fix);
|
|
89574
89832
|
issues.push(issue);
|
|
89575
89833
|
}
|
|
89576
89834
|
}
|
|
@@ -91162,6 +91420,8 @@ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/
|
|
|
91162
91420
|
const sequential_blank_1 = __webpack_require__(/*! ./sequential_blank */ "../core/build/src/rules/sequential_blank.js");
|
|
91163
91421
|
const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
|
|
91164
91422
|
const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
|
|
91423
|
+
const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
|
|
91424
|
+
const position_1 = __webpack_require__(/*! ../position */ "../core/build/src/position.js");
|
|
91165
91425
|
var NewlineLogic;
|
|
91166
91426
|
(function (NewlineLogic) {
|
|
91167
91427
|
NewlineLogic["Exact"] = "exact";
|
|
@@ -91191,7 +91451,7 @@ class NewlineBetweenMethods extends _abap_rule_1.ABAPRule {
|
|
|
91191
91451
|
key: "newline_between_methods",
|
|
91192
91452
|
title: "New line between methods",
|
|
91193
91453
|
shortDescription: `Checks for newlines between method implementations.`,
|
|
91194
|
-
tags: [_irule_1.RuleTag.Whitespace, _irule_1.RuleTag.SingleFile],
|
|
91454
|
+
tags: [_irule_1.RuleTag.Whitespace, _irule_1.RuleTag.Quickfix, _irule_1.RuleTag.SingleFile],
|
|
91195
91455
|
};
|
|
91196
91456
|
}
|
|
91197
91457
|
getMessage() {
|
|
@@ -91220,18 +91480,35 @@ class NewlineBetweenMethods extends _abap_rule_1.ABAPRule {
|
|
|
91220
91480
|
continue;
|
|
91221
91481
|
}
|
|
91222
91482
|
let counter = 0;
|
|
91223
|
-
while (sequential_blank_1.SequentialBlank.isBlankOrWhitespace(rows[nextRow])
|
|
91483
|
+
while (sequential_blank_1.SequentialBlank.isBlankOrWhitespace(rows[nextRow])) {
|
|
91224
91484
|
counter++;
|
|
91225
91485
|
nextRow++;
|
|
91226
91486
|
}
|
|
91227
91487
|
if ((counter !== this.conf.count && this.conf.logic === NewlineLogic.Exact)
|
|
91228
91488
|
|| (counter >= this.conf.count && this.conf.logic === NewlineLogic.Less)
|
|
91229
91489
|
|| counter === 0) {
|
|
91230
|
-
|
|
91490
|
+
const fix = this.buildFix(file, rows, statement.getStart().getRow(), counter);
|
|
91491
|
+
issues.push(issue_1.Issue.atStatement(file, statement, this.getMessage(), this.getMetadata().key, this.conf.severity, fix));
|
|
91231
91492
|
}
|
|
91232
91493
|
}
|
|
91233
91494
|
return issues;
|
|
91234
91495
|
}
|
|
91496
|
+
buildFix(file, rows, row, blanks) {
|
|
91497
|
+
let target = this.conf.count;
|
|
91498
|
+
if (this.conf.logic === NewlineLogic.Less) {
|
|
91499
|
+
target = blanks === 0 ? 1 : this.conf.count - 1;
|
|
91500
|
+
}
|
|
91501
|
+
if (blanks < target) {
|
|
91502
|
+
const end = new position_1.Position(row, rows[row - 1].length + 1);
|
|
91503
|
+
return edit_helper_1.EditHelper.insertAt(file, end, "\n".repeat(target - blanks));
|
|
91504
|
+
}
|
|
91505
|
+
else if (blanks > target) {
|
|
91506
|
+
const start = new position_1.Position(row + target, rows[row + target - 1].length + 1);
|
|
91507
|
+
const end = new position_1.Position(row + blanks, rows[row + blanks - 1].length + 1);
|
|
91508
|
+
return edit_helper_1.EditHelper.deleteRange(file, start, end);
|
|
91509
|
+
}
|
|
91510
|
+
return undefined;
|
|
91511
|
+
}
|
|
91235
91512
|
isConfigurationValid() {
|
|
91236
91513
|
if (this.conf.count < 1 || (this.conf.count === 1 && this.conf.logic === NewlineLogic.Less)) {
|
|
91237
91514
|
return false;
|
|
@@ -97673,6 +97950,173 @@ exports.ReduceStringTemplates = ReduceStringTemplates;
|
|
|
97673
97950
|
|
|
97674
97951
|
/***/ },
|
|
97675
97952
|
|
|
97953
|
+
/***/ "../core/build/src/rules/redundant_cast.js"
|
|
97954
|
+
/*!*************************************************!*\
|
|
97955
|
+
!*** ../core/build/src/rules/redundant_cast.js ***!
|
|
97956
|
+
\*************************************************/
|
|
97957
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
97958
|
+
|
|
97959
|
+
"use strict";
|
|
97960
|
+
|
|
97961
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
97962
|
+
if (k2 === undefined) k2 = k;
|
|
97963
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
97964
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
97965
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
97966
|
+
}
|
|
97967
|
+
Object.defineProperty(o, k2, desc);
|
|
97968
|
+
}) : (function(o, m, k, k2) {
|
|
97969
|
+
if (k2 === undefined) k2 = k;
|
|
97970
|
+
o[k2] = m[k];
|
|
97971
|
+
}));
|
|
97972
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
97973
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
97974
|
+
}) : function(o, v) {
|
|
97975
|
+
o["default"] = v;
|
|
97976
|
+
});
|
|
97977
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
97978
|
+
var ownKeys = function(o) {
|
|
97979
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
97980
|
+
var ar = [];
|
|
97981
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
97982
|
+
return ar;
|
|
97983
|
+
};
|
|
97984
|
+
return ownKeys(o);
|
|
97985
|
+
};
|
|
97986
|
+
return function (mod) {
|
|
97987
|
+
if (mod && mod.__esModule) return mod;
|
|
97988
|
+
var result = {};
|
|
97989
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
97990
|
+
__setModuleDefault(result, mod);
|
|
97991
|
+
return result;
|
|
97992
|
+
};
|
|
97993
|
+
})();
|
|
97994
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
97995
|
+
exports.RedundantCast = exports.RedundantCastConf = void 0;
|
|
97996
|
+
const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
|
|
97997
|
+
const _reference_1 = __webpack_require__(/*! ../abap/5_syntax/_reference */ "../core/build/src/abap/5_syntax/_reference.js");
|
|
97998
|
+
const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "../core/build/src/abap/5_syntax/syntax.js");
|
|
97999
|
+
const nodes_1 = __webpack_require__(/*! ../abap/nodes */ "../core/build/src/abap/nodes/index.js");
|
|
98000
|
+
const _typed_identifier_1 = __webpack_require__(/*! ../abap/types/_typed_identifier */ "../core/build/src/abap/types/_typed_identifier.js");
|
|
98001
|
+
const basic_1 = __webpack_require__(/*! ../abap/types/basic */ "../core/build/src/abap/types/basic/index.js");
|
|
98002
|
+
const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
|
|
98003
|
+
const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "../core/build/src/objects/_abap_object.js");
|
|
98004
|
+
const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
|
|
98005
|
+
const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
|
|
98006
|
+
const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
|
|
98007
|
+
const version_1 = __webpack_require__(/*! ../version */ "../core/build/src/version.js");
|
|
98008
|
+
class RedundantCastConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
98009
|
+
}
|
|
98010
|
+
exports.RedundantCastConf = RedundantCastConf;
|
|
98011
|
+
class RedundantCast {
|
|
98012
|
+
constructor() {
|
|
98013
|
+
this.conf = new RedundantCastConf();
|
|
98014
|
+
}
|
|
98015
|
+
getMetadata() {
|
|
98016
|
+
return {
|
|
98017
|
+
key: "redundant_cast",
|
|
98018
|
+
title: "Redundant Cast",
|
|
98019
|
+
shortDescription: `Find redundant CAST expressions`,
|
|
98020
|
+
extendedInformation: `Reports CAST expressions whose operand is already a reference to the cast's target class or interface.`,
|
|
98021
|
+
tags: [_irule_1.RuleTag.Quickfix],
|
|
98022
|
+
badExample: `DATA ref TYPE REF TO lcl.
|
|
98023
|
+
DATA(copy) = CAST lcl( ref ).`,
|
|
98024
|
+
goodExample: `DATA ref TYPE REF TO lcl.
|
|
98025
|
+
DATA(copy) = ref.`,
|
|
98026
|
+
};
|
|
98027
|
+
}
|
|
98028
|
+
getConfig() {
|
|
98029
|
+
return this.conf;
|
|
98030
|
+
}
|
|
98031
|
+
setConfig(conf) {
|
|
98032
|
+
this.conf = conf;
|
|
98033
|
+
}
|
|
98034
|
+
initialize(reg) {
|
|
98035
|
+
this.reg = reg;
|
|
98036
|
+
return this;
|
|
98037
|
+
}
|
|
98038
|
+
run(obj) {
|
|
98039
|
+
var _a;
|
|
98040
|
+
if (!(0, version_1.releaseAtLeast)(this.reg.getConfig().getRelease(), version_1.Release.v740sp02)
|
|
98041
|
+
&& !this.reg.getConfig().isOpenABAP()) {
|
|
98042
|
+
return [];
|
|
98043
|
+
}
|
|
98044
|
+
if (!(obj instanceof _abap_object_1.ABAPObject)) {
|
|
98045
|
+
return [];
|
|
98046
|
+
}
|
|
98047
|
+
const syntax = new syntax_1.SyntaxLogic(this.reg, obj).run();
|
|
98048
|
+
if (syntax.issues.length > 0) {
|
|
98049
|
+
return [];
|
|
98050
|
+
}
|
|
98051
|
+
const issues = [];
|
|
98052
|
+
for (const file of obj.getABAPFiles()) {
|
|
98053
|
+
const structure = file.getStructure();
|
|
98054
|
+
if (structure === undefined) {
|
|
98055
|
+
continue;
|
|
98056
|
+
}
|
|
98057
|
+
for (const cast of structure.findAllExpressionsRecursive(Expressions.Cast)) {
|
|
98058
|
+
const typeExpression = cast.findDirectExpression(Expressions.TypeNameOrInfer);
|
|
98059
|
+
const source = cast.findDirectExpression(Expressions.Source);
|
|
98060
|
+
if (typeExpression === undefined
|
|
98061
|
+
|| source === undefined
|
|
98062
|
+
|| cast.findDirectExpression(Expressions.Let) !== undefined) {
|
|
98063
|
+
continue;
|
|
98064
|
+
}
|
|
98065
|
+
const scope = syntax.spaghetti.lookupPosition(cast.getFirstToken().getStart(), file.getFilename());
|
|
98066
|
+
if (scope === undefined) {
|
|
98067
|
+
continue;
|
|
98068
|
+
}
|
|
98069
|
+
const target = (_a = scope.getData().references.find(reference => reference.referenceType === _reference_1.ReferenceType.InferredType
|
|
98070
|
+
&& reference.position.getStart().equals(typeExpression.getFirstToken().getStart()))) === null || _a === void 0 ? void 0 : _a.resolved;
|
|
98071
|
+
if (!(target instanceof _typed_identifier_1.TypedIdentifier)) {
|
|
98072
|
+
continue;
|
|
98073
|
+
}
|
|
98074
|
+
const operandType = this.sourceType(source, scope);
|
|
98075
|
+
if (operandType === undefined || this.sameType(target.getType(), operandType) === false) {
|
|
98076
|
+
continue;
|
|
98077
|
+
}
|
|
98078
|
+
const closingParen = cast.getDirectTokens().find(token => token.getStr() === ")" && token.getStart().isAfter(source.getLastToken().getStart()));
|
|
98079
|
+
if (closingParen === undefined) {
|
|
98080
|
+
continue;
|
|
98081
|
+
}
|
|
98082
|
+
const fix = edit_helper_1.EditHelper.replaceRange(file, cast.getFirstToken().getStart(), closingParen.getEnd(), source.concatTokens());
|
|
98083
|
+
issues.push(issue_1.Issue.atRange(file, cast.getFirstToken().getStart(), closingParen.getEnd(), "Redundant CAST expression", this.getMetadata().key, this.conf.severity, fix));
|
|
98084
|
+
}
|
|
98085
|
+
}
|
|
98086
|
+
return issues;
|
|
98087
|
+
}
|
|
98088
|
+
/** The type of a plain variable or attribute, undefined for anything more complex */
|
|
98089
|
+
sourceType(source, scope) {
|
|
98090
|
+
var _a;
|
|
98091
|
+
const children = source.getChildren();
|
|
98092
|
+
if (children.length !== 1 || !(children[0].get() instanceof Expressions.FieldChain)) {
|
|
98093
|
+
return undefined;
|
|
98094
|
+
}
|
|
98095
|
+
const fieldChain = children[0];
|
|
98096
|
+
const last = fieldChain.getLastChild();
|
|
98097
|
+
if (!(last instanceof nodes_1.ExpressionNode)
|
|
98098
|
+
|| !(last.get() instanceof Expressions.SourceField || last.get() instanceof Expressions.AttributeName)) {
|
|
98099
|
+
return undefined;
|
|
98100
|
+
}
|
|
98101
|
+
const operand = (_a = scope.getData().references.find(reference => reference.referenceType === _reference_1.ReferenceType.DataReadReference
|
|
98102
|
+
&& reference.position.getStart().equals(last.getFirstToken().getStart()))) === null || _a === void 0 ? void 0 : _a.resolved;
|
|
98103
|
+
if (!(operand instanceof _typed_identifier_1.TypedIdentifier)) {
|
|
98104
|
+
return undefined;
|
|
98105
|
+
}
|
|
98106
|
+
return operand.getType();
|
|
98107
|
+
}
|
|
98108
|
+
sameType(first, second) {
|
|
98109
|
+
if (!(first instanceof basic_1.ObjectReferenceType) || !(second instanceof basic_1.ObjectReferenceType)) {
|
|
98110
|
+
return false;
|
|
98111
|
+
}
|
|
98112
|
+
return first.getIdentifierName().toUpperCase() === second.getIdentifierName().toUpperCase();
|
|
98113
|
+
}
|
|
98114
|
+
}
|
|
98115
|
+
exports.RedundantCast = RedundantCast;
|
|
98116
|
+
//# sourceMappingURL=redundant_cast.js.map
|
|
98117
|
+
|
|
98118
|
+
/***/ },
|
|
98119
|
+
|
|
97676
98120
|
/***/ "../core/build/src/rules/redundant_conversion.js"
|
|
97677
98121
|
/*!*******************************************************!*\
|
|
97678
98122
|
!*** ../core/build/src/rules/redundant_conversion.js ***!
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/cli",
|
|
3
|
-
"version": "2.120.
|
|
3
|
+
"version": "2.120.78",
|
|
4
4
|
"description": "abaplint - Command Line Interface",
|
|
5
5
|
"funding": "https://github.com/sponsors/larshp",
|
|
6
6
|
"bin": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"homepage": "https://abaplint.org",
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@abaplint/core": "^2.120.
|
|
42
|
+
"@abaplint/core": "^2.120.78",
|
|
43
43
|
"@types/chai": "^4.3.20",
|
|
44
44
|
"@types/minimist": "^1.2.5",
|
|
45
45
|
"@types/mocha": "^10.0.10",
|