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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 21102x 21102x 21102x 21102x 21102x 63051x 63051x 63051x 63051x 63051x 63051x 63051x 63051x 21102x 21102x 20205x 20205x 21102x 21102x 374x 374x 21102x 21102x 378x 378x 21102x 21102x 588x 588x 588x 588x 588x 588x 588x 645x 645x 6x 645x 227x 227x 645x 588x 588x 1x 1x 1x 1x 1x 1x 587x 587x 587x 21102x 21102x | import {Issue} from "../issue";
import {IRule, IRuleMetadata, RuleTag} from "./_irule";
import {IObject} from "../objects/_iobject";
import {IRegistry} from "../_iregistry";
import {BasicRuleConfig} from "./_basic_rule_config";
export class AFFAndXMLConf extends BasicRuleConfig {
}
export class AFFAndXML implements IRule {
private conf = new AFFAndXMLConf();
public getMetadata(): IRuleMetadata {
return {
key: "aff_and_xml",
title: "AFF and XML",
shortDescription: `Checks for objects that have both AFF (.json) and XML (.xml) files`,
extendedInformation: `If an object has both an ABAP file format JSON file and an XML file, the XML file should be removed`,
tags: [RuleTag.Syntax],
};
}
public getConfig() {
return this.conf;
}
public setConfig(conf: AFFAndXMLConf) {
this.conf = conf;
}
public initialize(_reg: IRegistry) {
return this;
}
public run(obj: IObject): Issue[] {
const files = obj.getFiles();
let hasJSON = false;
let hasXML = false;
const type = obj.getType().toLowerCase();
for (const file of files) {
const filename = file.getFilename().toLowerCase();
if (filename.endsWith("." + type + ".json")) {
hasJSON = true;
} else if (filename.endsWith("." + type + ".xml")) {
hasXML = true;
}
}
if (hasJSON && hasXML) {
const xmlFile = obj.getXMLFile();
if (xmlFile) {
const message = "Object has both AFF JSON and XML files, remove the XML";
return [Issue.atRow(xmlFile, 1, message, this.getMetadata().key, this.conf.severity)];
}
}
return [];
}
}
|