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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11149x 11149x 11149x 11149x 11149x 33307x 33307x 33307x 33307x 33307x 33307x 33307x 33307x 33307x 33307x 33307x 33307x 33307x 33307x 33307x 33307x 33307x 33307x 33307x 33307x 33307x 11149x 11149x 10626x 10626x 11149x 11149x 246x 246x 11149x 11149x 269x 269x 269x 269x 127x 127x 269x 269x 54x 2x 2x 2x 54x 269x 269x 269x 11149x | import {InfoMethodDefinition} from "../abap/4_file_information/_abap_file_information";
import {BuiltIn} from "../abap/5_syntax/_builtin";
import {ABAPFile} from "../abap/abap_file";
import {Issue} from "../issue";
import {ABAPRule} from "./_abap_rule";
import {BasicRuleConfig} from "./_basic_rule_config";
import {IRuleMetadata, RuleTag} from "./_irule";
export class MethodOverwritesBuiltInConf extends BasicRuleConfig {
}
export class MethodOverwritesBuiltIn extends ABAPRule {
private conf = new MethodOverwritesBuiltInConf();
public getMetadata(): IRuleMetadata {
return {
key: "method_overwrites_builtin",
title: "Method name overwrites builtin function",
shortDescription: `Checks Method names that overwrite builtin SAP functions`,
extendedInformation: `https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-us/abenbuilt_in_functions_overview.html
https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#avoid-obscuring-built-in-functions
Interface method names are ignored`,
tags: [RuleTag.Naming, RuleTag.SingleFile, RuleTag.Styleguide],
badExample: `CLASS lcl DEFINITION.
PUBLIC SECTION.
METHODS matches.
ENDCLASS.
CLASS lcl IMPLEMENTATION.
METHOD matches.
ENDMETHOD.
ENDCLASS.`,
};
}
public getConfig() {
return this.conf;
}
public setConfig(conf: MethodOverwritesBuiltInConf) {
this.conf = conf;
}
public runParsed(file: ABAPFile): Issue[] {
const issues: Issue[] = [];
let methods: InfoMethodDefinition[] = [];
for (const classDef of file.getInfo().listClassDefinitions()) {
methods = methods.concat(classDef.methods);
}
for (const method of methods) {
if (BuiltIn.searchBuiltin(method.name.toUpperCase())) {
const message = `Method name "${method.name}" overwrites built-in SAP function name`;
issues.push(Issue.atIdentifier(method.identifier, message, this.getMetadata().key));
}
}
return issues;
}
} |