Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 15444x 15444x 15444x 15444x 90842x 90842x 90842x 90842x 90842x 90842x 90842x 90842x 90842x 90842x 90842x 15444x 15444x 14882x 14882x 15444x 15444x 264x 264x 15444x 15444x 295x 295x 295x 295x 295x 295x 1651x 1651x 2x 2x 1651x 295x 295x 295x 15444x 15444x | import {Issue} from "../issue";
import {BasicRuleConfig} from "./_basic_rule_config";
import {ABAPRule} from "./_abap_rule";
import * as Statements from "../abap/2_statements/statements";
import {IRuleMetadata, RuleTag} from "./_irule";
import {ABAPFile} from "../abap/abap_file";
import {Release, releaseAtLeast} from "../version";
export class PreferCorrespondingConf extends BasicRuleConfig {
}
export class PreferCorresponding extends ABAPRule {
private conf = new PreferCorrespondingConf();
public getMetadata(): IRuleMetadata {
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: [RuleTag.SingleFile, RuleTag.Upport, RuleTag.Styleguide],
badExample: `MOVE-CORRESPONDING foo TO bar.`,
goodExample: `bar = CORRESPONDING #( foo ).`,
};
}
public getConfig() {
return this.conf;
}
public setConfig(conf: PreferCorrespondingConf) {
this.conf = conf;
}
public runParsed(file: ABAPFile) {
const issues: Issue[] = [];
if (!releaseAtLeast(this.reg.getConfig().getRelease(), Release.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.atStatement(file, stat, message, this.getMetadata().key, this.conf.severity));
}
}
return issues;
}
} |