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 63 64 65 66 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11256x 11256x 11256x 11256x 11256x 33628x 33628x 33628x 33628x 33628x 33628x 33628x 33628x 33628x 33628x 11256x 11256x 10734x 10734x 11256x 11256x 246x 246x 11256x 11256x 246x 246x 246x 11256x 11256x 329x 329x 329x 329x 329x 11256x 11256x | import {IRule, IRuleMetadata, RuleTag} 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";
export class NROBConsistencyConf extends BasicRuleConfig {
}
export class NROBConsistency implements IRule {
private reg: IRegistry;
private conf = new NROBConsistencyConf();
public getMetadata(): IRuleMetadata {
return {
key: "nrob_consistency",
title: "Number range consistency",
shortDescription: `Consistency checks for number ranges`,
extendedInformation: `Issue reported if percentage warning is over 50%
Issue reported if the referenced domain is not found(taking error namespace into account)`,
tags: [RuleTag.SingleFile],
};
}
public getConfig() {
return this.conf;
}
public setConfig(conf: NROBConsistencyConf) {
this.conf = conf;
}
public initialize(reg: IRegistry) {
this.reg = reg;
return this;
}
public run(obj: IObject): Issue[] {
if (!(obj instanceof Objects.NumberRange)) {
return [];
}
const issues: Issue[] = [];
const id = obj.getIdentifier();
if (id === undefined) {
return [];
}
if (obj.getPercentage() || 0 > 50) {
const message = "Percentage more than 50";
issues.push(Issue.atIdentifier(id, message, this.getMetadata().key, this.getConfig().severity));
}
const domain = obj.getDomain();
if (domain
&& this.reg.getObject("DOMA", domain) === undefined
&& this.reg.inErrorNamespace(domain) === true) {
const message = "Domain " + domain + " not found";
issues.push(Issue.atIdentifier(id, message, this.getMetadata().key, this.getConfig().severity));
}
return [];
}
} |