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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11279x 11279x 11279x 11279x 11279x 33678x 33678x 33678x 33678x 33678x 33678x 33678x 33678x 33678x 33678x 33678x 33678x 11279x 11279x 10789x 10789x 11279x 11279x 229x 229x 11279x 11279x 244x 244x 244x 244x 244x 37x 35x 35x 2x 2x 2x 2x 2x 2x 244x 244x 244x 11279x 11279x | import {Issue} from "../issue";
import {ABAPRule} from "./_abap_rule";
import * as Expressions from "../abap/2_statements/expressions";
import {BasicRuleConfig} from "./_basic_rule_config";
import {IRuleMetadata, RuleTag} from "./_irule";
import {Version} from "../version";
import {EditHelper} from "../edit_helper";
import {ABAPFile} from "../abap/abap_file";
export class PreferXsdboolConf extends BasicRuleConfig {
}
export class PreferXsdbool extends ABAPRule {
private conf = new PreferXsdboolConf();
public getMetadata(): IRuleMetadata {
return {
key: "prefer_xsdbool",
title: "Prefer xsdbool over boolc",
shortDescription: `Prefer xsdbool over boolc`,
extendedInformation: `Activates if language version is v740sp08 or above.
https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#use-xsdbool-to-set-boolean-variables`,
tags: [RuleTag.Styleguide, RuleTag.Upport, RuleTag.Quickfix, RuleTag.SingleFile],
badExample: `DATA(sdf) = boolc( 1 = 2 ).`,
goodExample: `DATA(sdf) = xsdbool( 1 = 2 ).`,
};
}
public getConfig() {
return this.conf;
}
public setConfig(conf: PreferXsdboolConf) {
this.conf = conf;
}
public runParsed(file: ABAPFile): Issue[] {
const issues: Issue[] = [];
if (this.reg.getConfig().getVersion() < Version.v740sp08 && this.reg.getConfig().getVersion() !== Version.Cloud) {
return [];
}
for (const s of file.getStructure()?.findAllExpressions(Expressions.Source) || []) {
if (s.concatTokens().toUpperCase().startsWith("BOOLC( ") === false) {
continue;
}
const token = s.getFirstToken();
const message = "Prefer xsdbool over boolc";
const fix = EditHelper.replaceToken(file, token, "xsdbool");
issues.push(Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity, fix));
}
return issues;
}
}
|