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 65 66 67 68 | 1x 1x 1x 1x 1x 1x 1x 1x 23249x 23249x 23249x 23249x 1x 11625x 11625x 11625x 11625x 45838x 45838x 45838x 45838x 45838x 45838x 45838x 45838x 45838x 45838x 45838x 45838x 45838x 45838x 11625x 11625x 11089x 11089x 11625x 11625x 253x 253x 11625x 11625x 278x 278x 278x 278x 136x 12x 2x 2x 10x 10x 136x 278x 278x 58x 5x 5x 58x 278x 278x 278x 11625x 11625x 12x 12x 11625x 11625x | 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],
badExample: `INTERFACE lif_foo.
METHODS long_method_name.
ALIASES short FOR long_method_name.
ENDINTERFACE.`,
goodExample: `INTERFACE lif_foo.
METHODS long_method_name.
ENDINTERFACE.`,
};
}
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;
}
}
|