All files / src/rules fm_global_parameters_obsolete.ts

79.36% Statements 50/63
88.88% Branches 8/9
100% Functions 6/6
79.36% Lines 50/63

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 55 56 57 58 59 60 61 62 631x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 15469x 15469x 15469x 15469x 180443x 180443x 180443x 180443x 180443x 180443x 180443x 180443x 15469x 15469x 264x 264x 15469x 15469x 14908x 14908x 15469x 15469x 264x 264x 15469x 15469x 361x 359x 359x 2x 2x 2x 2x                           2x 2x 2x 2x 15469x 15469x
import {IRule, IRuleMetadata} from "./_irule";
import {Issue} from "../issue";
import * as Objects from "../objects";
import {IObject} from "../objects/_iobject";
import {IRegistry} from "../_iregistry";
import {BasicRuleConfig} from "./_basic_rule_config";
import {Position} from "../position";
 
export class FMGlobalParametersObsoleteConf extends BasicRuleConfig {
}
 
export class FMGlobalParametersObsolete implements IRule {
  private conf = new FMGlobalParametersObsoleteConf();
 
  public getMetadata(): IRuleMetadata {
    return {
      key: "fm_global_parameters_obsolete",
      title: "FM Global Parameters Obsolete",
      shortDescription: `Check for function modules with global parameters`,
      extendedInformation: `https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenglobal_parameters_obsolete.html`,
      tags: [],
    };
  }
 
  public initialize(_reg: IRegistry) {
    return this;
  }
 
  public getConfig() {
    return this.conf;
  }
 
  public setConfig(conf: FMGlobalParametersObsoleteConf) {
    this.conf = conf;
  }
 
  public run(obj: IObject): Issue[] {
    if (!(obj instanceof Objects.FunctionGroup)) {
      return [];
    }
 
    const issues: Issue[] = [];
    for (const module of obj.getModules()) {
      if (module.isGlobalParameters() === true) {
        const file = obj.getMainABAPFile();
        if (file === undefined) {
          continue;
        }
        const message = `Function Module "${module.getName()}" uses obsolete global parameters`;
        issues.push(Issue.atPosition(
          file,
          new Position(1, 1),
          message,
          this.getMetadata().key,
          this.conf.severity,
        ));
      }
    }
 
    return issues;
  }
 
}