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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11713x 11713x 11713x 11713x 202631x 202631x 202631x 202631x 202631x 202631x 202631x 202631x 202631x 202631x 202631x 11713x 11713x 11175x 11175x 11713x 11713x 253x 253x 11713x 11713x 282x 282x 282x 6632x 4803x 4803x 8x 8x 8x 8x 4803x 6632x 282x 282x 282x 11713x | import {Issue} from "../issue";
import {ABAPRule} from "./_abap_rule";
import {BasicRuleConfig} from "./_basic_rule_config";
import {IRuleMetadata, RuleTag} from "./_irule";
import {ABAPFile} from "../abap/abap_file";
import {EditHelper} from "../edit_helper";
import {Identifier} from "../abap/1_lexer/tokens";
export class NoExclamationEscapeConf extends BasicRuleConfig {
}
export class NoExclamationEscape extends ABAPRule {
private conf = new NoExclamationEscapeConf();
public getMetadata(): IRuleMetadata {
return {
key: "no_exclamation_escape",
title: "No exclamation escape",
shortDescription: `Detects and removes exclamation marks (!) used to escape identifiers`,
// eslint-disable-next-line max-len
extendedInformation: `Exclamation marks are not needed when the identifier is not a reserved keyword, or could be avoided by renaming.`,
tags: [RuleTag.SingleFile, RuleTag.Quickfix],
badExample: "methods CONVERT changing !CO_sdf type ref to ZCL_sdf optional.",
goodExample: "methods CONVERT changing CO_sdf type ref to ZCL_sdf optional.",
};
}
public getConfig() {
return this.conf;
}
public setConfig(conf: NoExclamationEscapeConf) {
this.conf = conf;
}
public runParsed(file: ABAPFile): Issue[] {
const issues: Issue[] = [];
for (const token of file.getTokens()) {
if (token instanceof Identifier) {
const str = token.getStr();
if (str.startsWith("!")) {
const replacement = str.substring(1);
const fix = EditHelper.replaceToken(file, token, replacement);
issues.push(Issue.atToken(file, token, "Do not use exclamation mark to escape identifiers", this.getMetadata().key, this.conf.severity, fix));
}
}
}
return issues;
}
}
|