@abaplint/core
Version:
abaplint - Core API
98 lines (95 loc) • 3.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.IdenticalDescriptions = exports.IdenticalDescriptionsConf = void 0;
const issue_1 = require("../issue");
const _basic_rule_config_1 = require("./_basic_rule_config");
const objects_1 = require("../objects");
class IdenticalDescriptionsConf extends _basic_rule_config_1.BasicRuleConfig {
}
exports.IdenticalDescriptionsConf = IdenticalDescriptionsConf;
class IdenticalDescriptions {
constructor() {
this.conf = new IdenticalDescriptionsConf();
}
getMetadata() {
return {
key: "identical_descriptions",
title: "Identical descriptions",
shortDescription: `Searches for objects with the same type and same description`,
extendedInformation: `Case insensitive
Only checks the master language descriptions
Dependencies are skipped
Works for: INTF, CLAS, DOMA, DTEL, FUNC in same FUGR`,
tags: [],
};
}
getConfig() {
return this.conf;
}
setConfig(conf) {
this.conf = conf;
}
initialize(reg) {
var _a;
this.descriptions = {};
this.types = ["INTF", "CLAS", "DOMA", "DTEL"];
for (const o of reg.getObjects()) {
if (reg.isDependency(o)) {
continue;
}
const type = o.getType();
if (this.types.includes(type)) {
const description = (_a = o.getDescription()) === null || _a === void 0 ? void 0 : _a.toUpperCase();
if (description === undefined || description === "") {
continue;
}
if (this.descriptions[type] === undefined) {
this.descriptions[type] = {};
}
if (this.descriptions[type][description] === undefined) {
this.descriptions[type][description] = [];
}
this.descriptions[type][description].push(o.getName());
}
}
return this;
}
run(o) {
var _a;
const issues = [];
const type = o.getType();
if (this.types.includes(type)) {
const description = (_a = o.getDescription()) === null || _a === void 0 ? void 0 : _a.toUpperCase();
if (description === undefined || description === "") {
return issues;
}
const found = this.descriptions[type][description].filter(a => a !== o.getName());
if (found.length > 0) {
const message = "Identical description: " + found[0];
issues.push(issue_1.Issue.atRow(o.getXMLFile(), 1, message, this.getMetadata().key, this.getConfig().severity));
}
}
if (o instanceof objects_1.FunctionGroup) {
issues.push(...this.checkFunctionModules(o));
}
return issues;
}
checkFunctionModules(fugr) {
var _a;
const descriptions = {};
for (const fm of fugr.getModules()) {
const d = (_a = fm.getDescription()) === null || _a === void 0 ? void 0 : _a.toUpperCase();
if (d === undefined || d === "") {
continue;
}
if (descriptions[d] !== undefined) {
const message = "FUGR " + fugr.getName() + " contains function modules with identical descriptions";
return [issue_1.Issue.atRow(fugr.getXMLFile(), 1, message, this.getMetadata().key, this.getConfig().severity)];
}
descriptions[d] = true;
}
return [];
}
}
exports.IdenticalDescriptions = IdenticalDescriptions;
//# sourceMappingURL=identical_descriptions.js.map