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 10058x 10058x 10058x 10058x 10058x 30003x 30003x 30003x 30003x 30003x 30003x 30003x 30003x 30003x 30003x 30003x 10058x 10058x 9559x 9559x 10058x 10058x 234x 234x 10058x 10058x 248x 248x 248x 1413x 1402x 1402x 11x 1413x 1x 1x 1x 1x 1413x 248x 248x 248x 10058x 10058x | import * as Expressions from "../abap/2_statements/expressions"; import * as Statements from "../abap/2_statements/statements"; import {Issue} from "../issue"; import {ABAPRule} from "./_abap_rule"; import {BasicRuleConfig} from "./_basic_rule_config"; import {IRuleMetadata, RuleTag} from "./_irule"; import {ABAPFile} from "../abap/abap_file"; export class NoChainedAssignmentConf extends BasicRuleConfig { } export class NoChainedAssignment extends ABAPRule { private conf = new NoChainedAssignmentConf(); public getMetadata(): IRuleMetadata { return { key: "no_chained_assignment", title: "No chained assignment", shortDescription: `Find chained assingments and reports issues`, extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#dont-chain-assignments`, tags: [RuleTag.SingleFile, RuleTag.Styleguide], badExample: `var1 = var2 = var3.`, goodExample: `var2 = var3. var1 = var2.`, }; } public getConfig() { return this.conf; } public setConfig(conf: NoChainedAssignmentConf) { this.conf = conf; } public runParsed(file: ABAPFile) { const issues: Issue[] = []; for (const s of file.getStatements()) { if (!(s.get() instanceof Statements.Move)) { continue; } if (s.findDirectExpressions(Expressions.Target).length >= 2) { const message = "No chained assignment"; const issue = Issue.atStatement(file, s, message, this.getMetadata().key); issues.push(issue); } } return issues; } } |