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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 11323x 11323x 11323x 11323x 11323x 33809x 33809x 33809x 33809x 33809x 33809x 33809x 11323x 11323x 10825x 10825x 11323x 11323x 233x 233x 11323x 11323x 244x 244x 244x 189x 244x 5x 5x 50x 50x 50x 244x 354x 354x 48x 354x 96x 306x 22x 210x 22x 188x 1x 1x 354x 50x 50x 50x 11323x 11323x | import * as Statements from "../abap/2_statements/statements";
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";
import {Class} from "../objects";
import {Comment} from "../abap/2_statements/statements/_statement";
export class NoCommentsBetweenMethodsConf extends BasicRuleConfig {
}
export class NoCommentsBetweenMethods extends ABAPRule {
private conf = new NoCommentsBetweenMethodsConf();
public getMetadata(): IRuleMetadata {
return {
key: "no_comments_between_methods",
title: "No comments between methods in global classes",
shortDescription: `Its not possible to have comments between methods in global classes.`,
tags: [RuleTag.SingleFile, RuleTag.Syntax],
};
}
public getConfig() {
return this.conf;
}
public setConfig(conf: NoCommentsBetweenMethodsConf) {
this.conf = conf;
}
public runParsed(file: ABAPFile, obj: IObject) {
const issues: Issue[] = [];
if (!(obj instanceof Class)) {
return [];
} else if (file !== obj.getMainABAPFile()) {
return [];
}
let inMethod = false;
let inClassImpl = false;
for (const statement of file.getStatements()) {
const statementType = statement.get();
if (statementType instanceof Statements.ClassImplementation) {
inClassImpl = true;
} else if (statementType instanceof Statements.EndClass) {
inClassImpl = false;
} else if (statementType instanceof Statements.MethodImplementation) {
inMethod = true;
} else if (statementType instanceof Statements.EndMethod) {
inMethod = false;
} else if (inClassImpl === true && inMethod === false && statementType instanceof Comment) {
issues.push(Issue.atStatement(file, statement, "Comment between methods in global class implementation", this.getMetadata().key, this.conf.severity));
}
}
return issues;
}
} |