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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 8922x 8922x 8922x 8922x 8922x 26610x 26610x 26610x 26610x 26610x 26610x 26610x 26610x 26610x 8922x 8922x 8487x 8487x 8922x 8922x 202x 202x 8922x 8922x 223x 223x 223x 38x 38x 38x 2x 2x 2x 2x 38x 223x 223x 223x 8922x 8922x | import {ABAPRule} from "./_abap_rule"; import {BasicRuleConfig} from "./_basic_rule_config"; import {Issue} from "../issue"; import * as Expressions from "../abap/2_statements/expressions"; import {IRuleMetadata, RuleTag} from "./_irule"; import {ABAPFile} from "../abap/abap_file"; export class OmitPrecedingZerosConf extends BasicRuleConfig { } export class OmitPrecedingZeros extends ABAPRule { private conf = new OmitPrecedingZerosConf(); public getMetadata(): IRuleMetadata { return { key: "omit_preceding_zeros", title: "Omit preceding zeros", shortDescription: `Omit preceding zeros from integer constants`, tags: [RuleTag.SingleFile], badExample: `int = -001.`, goodExample: `int = -1.`, }; } public getConfig() { return this.conf; } public setConfig(conf: OmitPrecedingZerosConf): void { this.conf = conf; } public runParsed(file: ABAPFile) { const issues: Issue[] = []; for (const i of file.getStructure()?.findAllExpressions(Expressions.Integer) || []) { const token = i.getLastToken(); const str = token.getStr(); if (str.length > 1 && str.startsWith("0")) { const message = "Omit preceding zeros"; const issue = Issue.atToken(file, token, message, this.getMetadata().key, this.getConfig().severity); issues.push(issue); } } return issues; } } |