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 10995x 10995x 10995x 10995x 10995x 32796x 32796x 32796x 32796x 32796x 32796x 32796x 32796x 32796x 32796x 32796x 10995x 10995x 10444x 10444x 10995x 10995x 260x 260x 10995x 10995x 273x 273x 273x 1539x 1524x 1524x 15x 1539x 1x 1x 1x 1x 1539x 273x 273x 273x 10995x 10995x | 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; } } |