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 11753x 11753x 11753x 11753x 11753x 46338x 46338x 46338x 46338x 46338x 46338x 46338x 46338x 11753x 11753x 11241x 11241x 11753x 11753x 239x 239x 11753x 11753x 243x 243x 11753x 11753x 317x 317x 317x 317x 317x 317x 317x 340x 340x 2x 340x 82x 82x 340x 317x 317x 1x 1x 1x 1x 1x 1x 316x 316x 316x 11753x 11753x | 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 [];
}
}
|