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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 10778x 10778x 10778x 10778x 32182x 32182x 32182x 32182x 32182x 32182x 32182x 32182x 32182x 32182x 32182x 32182x 32182x 32182x 32182x 32182x 10778x 10778x 10267x 10267x 10778x 10778x 240x 240x 10778x 10778x 255x 255x 255x 64x 64x 29x 24x 24x 24x 5x 29x 1x 1x 1x 5x 5x 5x 64x 255x 255x 255x 10778x 10778x | 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";
import {ExpressionNode} from "../abap/nodes/expression_node";
export class MaxOneMethodParameterPerLineConf extends BasicRuleConfig {
}
export class MaxOneMethodParameterPerLine extends ABAPRule {
private conf = new MaxOneMethodParameterPerLineConf();
public getMetadata(): IRuleMetadata {
return {
key: "max_one_method_parameter_per_line",
title: "Max one method parameter definition per line",
shortDescription: `Keep max one method parameter description per line`,
tags: [RuleTag.SingleFile, RuleTag.Whitespace],
badExample: `
METHODS apps_scope_token
IMPORTING
body TYPE bodyapps_scope_token client_id TYPE str.`,
goodExample: `
METHODS apps_scope_token
IMPORTING
body TYPE bodyapps_scope_token
client_id TYPE str.`,
};
}
public getConfig() {
return this.conf;
}
public setConfig(conf: MaxOneMethodParameterPerLineConf) {
this.conf = conf;
}
public runParsed(file: ABAPFile) {
const issues: Issue[] = [];
for (const statement of file.getStructure()?.findAllStatements(Statements.MethodDef) || []) {
let prev: ExpressionNode | undefined = undefined;
for (const p of statement.findAllExpressions(Expressions.MethodParam)) {
if (prev === undefined) {
prev = p;
continue;
}
if (prev.getFirstToken().getStart().getRow() === p.getFirstToken().getStart().getRow()) {
const issue = Issue.atToken(file, prev.getFirstToken(), this.getMetadata().title, this.getMetadata().key, this.conf.severity);
issues.push(issue);
}
prev = p;
}
}
return issues;
}
} |