All files / src/rules prefer_corresponding.ts

96.15% Statements 50/52
88.88% Branches 8/9
100% Functions 5/5
96.15% Lines 50/52

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 521x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 9361x 9361x 9361x 9361x 27925x 27925x 27925x 27925x 27925x 27925x 27925x 27925x 27925x 9361x 9361x 8898x 8898x 9361x 9361x 216x 216x 9361x 9361x 234x 234x 234x     234x 234x 234x 1348x 1348x 2x 2x 1348x 234x 234x 234x 9361x 9361x
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`,
      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],
    };
  }
 
  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;
  }
 
}