UNPKG

@abaplint/core

Version:
51 lines 2.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PreferCorresponding = exports.PreferCorrespondingConf = void 0; const issue_1 = require("../issue"); const _basic_rule_config_1 = require("./_basic_rule_config"); const _abap_rule_1 = require("./_abap_rule"); const Statements = require("../abap/2_statements/statements"); const _irule_1 = require("./_irule"); const version_1 = require("../version"); class PreferCorrespondingConf extends _basic_rule_config_1.BasicRuleConfig { } exports.PreferCorrespondingConf = PreferCorrespondingConf; class PreferCorresponding extends _abap_rule_1.ABAPRule { constructor() { super(...arguments); this.conf = new PreferCorrespondingConf(); } getMetadata() { return { key: "prefer_corresponding", title: "Prefer corresponding( ) to MOVE-CORRESPONDING", shortDescription: `Prefer corresponding( ) to MOVE-CORRESPONDING, from v740sp05 and up`, extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#prefer-functional-to-procedural-language-constructs`, tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Upport, _irule_1.RuleTag.Styleguide], badExample: `MOVE-CORRESPONDING foo TO bar.`, goodExample: `bar = CORRESPONDING #( foo ).`, }; } getConfig() { return this.conf; } setConfig(conf) { this.conf = conf; } runParsed(file) { const issues = []; if (this.reg.getConfig().getVersion() < version_1.Version.v740sp05) { return issues; } const message = "Use CORRESPONDING type( ... ) instead of MOVE-CORRESPONDING"; for (const stat of file.getStatements()) { if (stat.get() instanceof Statements.MoveCorresponding && stat.getChildren().length === 7) { issues.push(issue_1.Issue.atStatement(file, stat, message, this.getMetadata().key, this.conf.severity)); } } return issues; } } exports.PreferCorresponding = PreferCorresponding; //# sourceMappingURL=prefer_corresponding.js.map