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 11089x 11089x 11089x 11089x 11089x 33122x 33122x 33122x 33122x 33122x 33122x 33122x 33122x 33122x 33122x 33122x 11089x 11089x 10568x 10568x 11089x 11089x 244x 244x 11089x 11089x 266x 266x 266x 1492x 1492x 10x 10x 10x 2x 2x 2x 10x 1492x 266x 266x 266x 11089x 11089x | 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;
}
} |