All files / src/rules tabl_enhancement_category.ts

100% Statements 19/19
100% Branches 4/4
100% Functions 7/7
100% Lines 19/19

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 591x 1x   1x     1x   1x     1x 7271x     21681x                 2x       7015x       114x       114x       132x 128x     4x 2x 2x           2x     2x      
import {Issue} from "../issue";
import {BasicRuleConfig} from "./_basic_rule_config";
import {IRegistry} from "../_iregistry";
import {Table, EnhancementCategory} from "../objects";
import {IRule} 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() {
    return {
      key: "tabl_enhancement_category",
      title: "TABL enhancement category must be set",
      shortDescription: `Checks that tables do not have the enhancement category 'not classified'. 
You may use standard report RS_DDIC_CLASSIFICATION_FINAL for adjustment.`,
    };
  }
 
  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 [];
  }
}