@abaplint/core
Version:
abaplint - Core API
57 lines • 1.92 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AFFAndXML = exports.AFFAndXMLConf = void 0;
const issue_1 = require("../issue");
const _irule_1 = require("./_irule");
const _basic_rule_config_1 = require("./_basic_rule_config");
class AFFAndXMLConf extends _basic_rule_config_1.BasicRuleConfig {
}
exports.AFFAndXMLConf = AFFAndXMLConf;
class AFFAndXML {
constructor() {
this.conf = new AFFAndXMLConf();
}
getMetadata() {
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: [_irule_1.RuleTag.Syntax],
};
}
getConfig() {
return this.conf;
}
setConfig(conf) {
this.conf = conf;
}
initialize(_reg) {
return this;
}
run(obj) {
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_1.Issue.atRow(xmlFile, 1, message, this.getMetadata().key, this.conf.severity)];
}
}
return [];
}
}
exports.AFFAndXML = AFFAndXML;
//# sourceMappingURL=aff_and_xml.js.map