All files / src/rules tabl_enhancement_category.ts

100% Statements 61/61
100% Branches 11/11
100% Functions 7/7
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 11650x 11650x 11650x 11650x 34801x 34801x 34801x 34801x 34801x 34801x 34801x 34801x 34801x 34801x 11650x 11650x 2x 2x 11650x 11650x 11142x 11142x 11650x 11650x 239x 239x 11650x 11650x 239x 239x 11650x 11650x 313x 292x 292x 21x 313x 2x 2x 2x 2x 2x 2x 2x 2x 2x 19x 19x 19x 11650x  
import {Issue} from "../issue";
import {BasicRuleConfig} from "./_basic_rule_config";
import {IRegistry} from "../_iregistry";
import {Table, EnhancementCategory} from "../objects";
import {IRule, IRuleMetadata} from "./_irule";
import {IObject} from "../objects/_iobject";
import {Position} from "../position";
 
export class TABLEnhancementCategoryConf extends BasicRuleConfig {
}
 
export class TABLEnhancementCategory implements IRule {
  private conf = new TABLEnhancementCategoryConf();
 
  public getMetadata(): IRuleMetadata {
    return {
      key: "tabl_enhancement_category",
      title: "TABL enhancement category must be set",
      shortDescription: `Checks that tables do not have the enhancement category 'not classified'.`,
      extendedInformation: `SAP note 3063227 changes the default to 'Cannot be enhanced'.
 
You may use standard report RS_DDIC_CLASSIFICATION_FINAL for adjustment.`,
      tags: [],
    };
  }
 
  private getDescription(name: string): string {
    return "TABL enhancement category not classified in " + name;
  }
 
  public getConfig() {
    return this.conf;
  }
 
  public setConfig(conf: TABLEnhancementCategoryConf) {
    this.conf = conf;
  }
 
  public initialize(_reg: IRegistry) {
    return this;
  }
 
  public run(obj: IObject): Issue[] {
    if (!(obj instanceof Table)) {
      return [];
    }
 
    if (obj.getEnhancementCategory() === EnhancementCategory.NotClassified) {
      const position = new Position(1, 1);
      const issue = Issue.atPosition(
        obj.getFiles()[0],
        position,
        this.getDescription(obj.getName()),
        this.getMetadata().key,
        this.conf.severity);
      return [issue];
    }
 
    return [];
  }
}