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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11714x 11714x 11714x 11714x 11714x 34998x 34998x 34998x 34998x 34998x 34998x 34998x 34998x 34998x 34998x 34998x 11714x 11714x 11175x 11175x 11714x 11714x 253x 253x 11714x 11714x 274x 274x 274x 1573x 1573x 11x 11x 11x 2x 2x 2x 11x 1573x 274x 274x 274x 11714x 11714x | import * as Statements from "../abap/2_statements/statements";
import * as Expressions from "../abap/2_statements/expressions";
import {Issue} from "../issue";
import {ABAPRule} from "./_abap_rule";
import {BasicRuleConfig} from "./_basic_rule_config";
import {IObject} from "../objects/_iobject";
import {IRuleMetadata, RuleTag} from "./_irule";
import {ABAPFile} from "../abap/abap_file";
export class IdenticalMoveConf extends BasicRuleConfig {
}
export class IdenticalMove extends ABAPRule {
private conf = new IdenticalMoveConf();
public getMetadata(): IRuleMetadata {
return {
key: "identical_move",
title: "Identical move",
shortDescription: `Moving the same value from left to right or right to left is redundant.`,
tags: [RuleTag.SingleFile],
badExample: `DATA lv_value TYPE i.
lv_value = lv_value.`,
goodExample: `DATA lv_value TYPE i.
lv_value = 5.`,
};
}
public getConfig() {
return this.conf;
}
public setConfig(conf: IdenticalMoveConf) {
this.conf = conf;
}
public runParsed(file: ABAPFile, _obj: IObject) {
const issues: Issue[] = [];
for (const statement of file.getStatements()) {
const statementType = statement.get();
if (statementType instanceof Statements.Move) {
const source = statement.findDirectExpression(Expressions.Source)?.concatTokens().toUpperCase();
const target = statement.findDirectExpression(Expressions.Target)?.concatTokens().toUpperCase();
if (source === target && source !== undefined) {
const message = `Identical MOVE from "${source}" to "${target}"`;
issues.push(Issue.atStatement(file, statement, message, this.getMetadata().key, this.conf.severity));
}
}
}
return issues;
}
} |