All files / src/rules prefer_corresponding.ts

96% Statements 48/50
88.88% Branches 8/9
100% Functions 5/5
96% Lines 48/50

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 501x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 8922x 8922x 8922x 8922x 26610x 26610x 26610x 26610x 26610x 26610x 26610x 8922x 8922x 8485x 8485x 8922x 8922x 202x 202x 8922x 8922x 216x 216x 216x     216x 216x 216x 1212x 1212x 2x 2x 1212x 216x 216x 216x 8922x 8922x
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 {Version} 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`,
      tags: [RuleTag.SingleFile, RuleTag.Upport],
    };
  }
 
  public getConfig() {
    return this.conf;
  }
 
  public setConfig(conf: PreferCorrespondingConf) {
    this.conf = conf;
  }
 
  public runParsed(file: ABAPFile) {
    const issues: Issue[] = [];
 
    if (this.reg.getConfig().getVersion() < Version.v740sp05) {
      return issues;
    }
 
    const message = "Use CORRESPONDING type( ... ) instead";
    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;
  }
 
}