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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 14682x 14682x 14682x 14682x 14682x 58040x 58040x 58040x 58040x 58040x 58040x 58040x 58040x 58040x 58040x 58040x 58040x 58040x 58040x 14682x 14682x 14120x 14120x 14682x 14682x 264x 264x 14682x 14682x 295x 295x 295x 1657x 12x 12x 1657x 295x 295x 295x 14682x 14682x | import {Issue} from "../issue";
import {ABAPRule} from "./_abap_rule";
import * as Statements from "../abap/2_statements/statements";
import {BasicRuleConfig} from "./_basic_rule_config";
import {IRuleMetadata, RuleTag} from "./_irule";
import {ABAPFile} from "../abap/abap_file";
export class NoMacrosConf extends BasicRuleConfig {
}
export class NoMacros extends ABAPRule {
private conf = new NoMacrosConf();
public getMetadata(): IRuleMetadata {
return {
key: "no_macros",
title: "No macros",
shortDescription: `Checks that macros are not used`,
extendedInformation: `Macros reduce readability and are difficult to debug, use methods or form routines instead.
https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abenmacros_guidl.html`,
tags: [RuleTag.SingleFile],
badExample: `DEFINE _macro.
WRITE 'hello'.
END-OF-DEFINITION.`,
goodExample: `WRITE 'hello'.`,
};
}
public getConfig(): NoMacrosConf {
return this.conf;
}
public setConfig(conf: NoMacrosConf) {
this.conf = conf;
}
public runParsed(file: ABAPFile) {
const issues: Issue[] = [];
for (const stat of file.getStatements()) {
if (stat.get() instanceof Statements.Define) {
issues.push(Issue.atStatement(file, stat, "Do not define macros", this.getMetadata().key, this.conf.severity));
}
}
return issues;
}
}
|