@abaplint/core
Version:
abaplint - Core API
61 lines (59 loc) • 2.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SyModification = exports.SyModificationConf = void 0;
const issue_1 = require("../issue");
const Expressions = require("../abap/2_statements/expressions");
const _abap_rule_1 = require("./_abap_rule");
const _basic_rule_config_1 = require("./_basic_rule_config");
const _irule_1 = require("./_irule");
class SyModificationConf extends _basic_rule_config_1.BasicRuleConfig {
}
exports.SyModificationConf = SyModificationConf;
class SyModification extends _abap_rule_1.ABAPRule {
constructor() {
super(...arguments);
this.conf = new SyModificationConf();
}
getMetadata() {
return {
key: "sy_modification",
title: "Modification of SY fields",
shortDescription: `Finds modification of sy fields`,
extendedInformation: `https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abensystem_fields.htm
Changes to SY-TVAR* fields are not reported
Modification of SY fields is not allwed in ABAP Cloud language version,
https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/ABENSYSTEM_FIELDS.html`,
tags: [_irule_1.RuleTag.SingleFile],
badExample: `sy-uname = 2.
sy = sy.`,
};
}
getConfig() {
return this.conf;
}
setConfig(conf) {
this.conf = conf;
}
runParsed(file, obj) {
var _a;
const issues = [];
if (obj.getType() === "INTF") {
return [];
}
for (const t of ((_a = file.getStructure()) === null || _a === void 0 ? void 0 : _a.findAllExpressions(Expressions.Target)) || []) {
const firstChild = t.getChildren()[0];
if (firstChild.get() instanceof Expressions.TargetField
&& firstChild.getFirstToken().getStr().toUpperCase() === "SY") {
if (t.concatTokens().toUpperCase().startsWith("SY-TVAR")) {
continue;
}
const message = "Modification of SY field";
const issue = issue_1.Issue.atToken(file, firstChild.getFirstToken(), message, this.getMetadata().key, this.conf.severity);
issues.push(issue);
}
}
return issues;
}
}
exports.SyModification = SyModification;
//# sourceMappingURL=sy_modification.js.map