All files / src/rules dynpro_checks.ts

100% Statements 61/61
100% Branches 15/15
100% Functions 6/6
100% Lines 61/61

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 621x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11297x 11297x 11297x 11297x 33735x 33735x 33735x 33735x 33735x 33735x 33735x 33735x 11297x 11297x 233x 233x 11297x 11297x 10803x 10803x 11297x 11297x 232x 232x 11297x 11297x 302x 302x 302x 138x 138x 164x 164x 302x 162x 162x 2x 302x 1x 2x 1x 1x 1x 2x 1x 2x 2x 2x 11297x 11297x  
import {Issue} from "../issue";
import {IObject} from "../objects/_iobject";
import {IRule, IRuleMetadata, RuleTag} from "./_irule";
import {BasicRuleConfig} from "./_basic_rule_config";
import {IRegistry} from "../_iregistry";
import {Program} from "../objects";
import {Position} from "../position";
 
export class DynproChecksConf extends BasicRuleConfig {
}
 
export class DynproChecks implements IRule {
  private conf = new DynproChecksConf();
 
  public getMetadata(): IRuleMetadata {
    return {
      key: "dynpro_checks",
      title: "Dynpro Checks",
      shortDescription: `Various Dynpro checks`,
      extendedInformation: `* Check length of PUSH elements less than 132`,
      tags: [RuleTag.Syntax],
    };
  }
 
  public initialize(_reg: IRegistry) {
    return this;
  }
 
  public getConfig(): DynproChecksConf {
    return this.conf;
  }
 
  public setConfig(conf: DynproChecksConf) {
    this.conf = conf;
  }
 
  public run(obj: IObject): Issue[] {
    const ret: Issue[] = [];
 
    if (!(obj instanceof Program)) {
      return [];
    }
 
    const file = obj.getXMLFile();
    if (file === undefined) {
      return [];
    }
 
    for (const dynpro of obj.getDynpros()) {
      for (const field of dynpro.fields) {
        if (field.type === "PUSH" && field.length > 132) {
          const message = `Screen ${dynpro.number}, field ${field.name} LENGTH longer than 132`;
          ret.push(Issue.atPosition(file, new Position(1, 1), message, this.getMetadata().key, this.getConfig().severity));
        }
      }
    }
 
    return ret;
  }
 
}