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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 12357x 12357x 12357x 12357x 36925x 36925x 36925x 36925x 36925x 36925x 36925x 36925x 36925x 36925x 12357x 12357x 11813x 11813x 12357x 12357x 255x 255x 12357x 12357x 277x 277x 277x 277x 277x 277x 277x 12x 12x 265x 277x 13x 10x 10x 3x 3x 13x 3x 13x 13x 2x 2x 1x 1x 13x 1x 1x 1x 1x 1x 1x 13x 265x 265x 265x 12357x 12357x | import {Issue} from "../issue";
import {ABAPRule} from "./_abap_rule";
import {BasicRuleConfig} from "./_basic_rule_config";
import * as Expressions from "../abap/2_statements/expressions";
import * as Statements from "../abap/2_statements/statements";
import {IRuleMetadata, RuleTag} from "./_irule";
import {LanguageVersion, Release, releaseAtLeast} from "../version";
import {ABAPFile} from "../abap/abap_file";
export class SuperfluousValueConf extends BasicRuleConfig {
}
export class SuperfluousValue extends ABAPRule {
private conf = new SuperfluousValueConf();
public getMetadata(): IRuleMetadata {
return {
key: "superfluous_value",
title: "Superfluous VALUE",
shortDescription: `Find superfluous VALUE expressions`,
extendedInformation: `Left hand side is inline, VALUE is inferred, value body is simple, from v740sp02 and up`,
tags: [RuleTag.SingleFile],
badExample: `DATA(message_entry) = VALUE #( message_table[ msgno = msgno ] ).`,
goodExample: `DATA(message_entry) = message_table[ msgno = msgno ].`,
};
}
public getConfig() {
return this.conf;
}
public setConfig(conf: SuperfluousValueConf) {
this.conf = conf;
}
public runParsed(file: ABAPFile) {
const output: Issue[] = [];
if (!releaseAtLeast(this.reg.getConfig().getRelease(), Release.v740sp02)
&& this.reg.getConfig().getLanguageVersion() !== LanguageVersion.Cloud) {
return [];
}
const struc = file.getStructure();
if (struc === undefined) {
return []; // syntax error
}
for (const m of struc.findAllStatements(Statements.Move)) {
if (m.findDirectExpression(Expressions.Target)?.findDirectExpression(Expressions.InlineData) === undefined) {
continue;
}
const source = m.findDirectExpression(Expressions.Source);
if (source === undefined) {
continue;
}
const type = source.findDirectExpression(Expressions.TypeNameOrInfer)?.concatTokens();
if (type !== "#") {
continue;
}
const body = source.findDirectExpression(Expressions.ValueBody);
if (body === undefined) {
continue;
}
if (body.getChildren().length === 1) {
const message = "Superfluous VALUE expression";
const issue = Issue.atStatement(file, m, message, this.getMetadata().key, this.conf.severity);
output.push(issue);
}
}
return output;
}
} |