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 | 1x 1x 1x 1x 1x 1x 1x 1x 26973x 26973x 26973x 26973x 1x 13487x 13487x 13487x 13487x 40320x 40320x 40320x 40320x 40320x 40320x 40320x 13487x 13487x 12977x 12977x 13487x 13487x 240x 240x 13487x 13487x 257x 257x 257x 257x 129x 12x 2x 2x 10x 10x 129x 257x 257x 57x 5x 5x 57x 257x 257x 257x 13487x 13487x 12x 12x 13487x 13487x | import {Issue} from "../issue";
import {BasicRuleConfig} from "./_basic_rule_config";
import {ABAPRule} from "./_abap_rule";
import {IRuleMetadata, RuleTag} from "./_irule";
import {ABAPFile} from "../abap/abap_file";
import {InfoAlias} from "../abap/4_file_information/_abap_file_information";
import {Visibility} from "../abap/4_file_information/visibility";
export class NoAliasesConf extends BasicRuleConfig {
/** Skip reporting aliases in private sections. */
public ignorePrivate: boolean = false;
}
export class NoAliases extends ABAPRule {
private conf = new NoAliasesConf();
public getMetadata(): IRuleMetadata {
return {
key: "no_aliases",
title: "No ALIASES",
shortDescription: `Detects use of the ALIAS statement`,
tags: [RuleTag.SingleFile],
};
}
public getConfig() {
return this.conf;
}
public setConfig(conf: NoAliasesConf) {
this.conf = conf;
}
public runParsed(file: ABAPFile) {
const issues: Issue[] = [];
const message = "Do not use ALIASES";
for (const classDef of file.getInfo().listClassDefinitions()) {
for (const alias of classDef.aliases) {
if (this.skipAlias(alias)) {
continue;
}
issues.push(Issue.atIdentifier(alias.identifier, message, this.getMetadata().key, this.conf.severity));
}
}
for (const interfaceDef of file.getInfo().listInterfaceDefinitions()) {
for (const alias of interfaceDef.aliases) {
issues.push(Issue.atIdentifier(alias.identifier, message, this.getMetadata().key, this.conf.severity));
}
}
return issues;
}
private skipAlias(alias: InfoAlias): boolean {
return this.conf.ignorePrivate === true && alias.visibility === Visibility.Private;
}
}
|