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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 21100x 21100x 21100x 21100x 21100x 83256x 83256x 83256x 83256x 83256x 83256x 83256x 83256x 83256x 83256x 83256x 83256x 83256x 83256x 83256x 83256x 83256x 83256x 83256x 83256x 83256x 21100x 21100x 20205x 20205x 21100x 21100x 374x 374x 21100x 21100x 388x 388x 388x 306x 388x 7x 7x 75x 75x 75x 388x 459x 459x 72x 459x 146x 387x 23x 241x 23x 218x 1x 1x 459x 75x 75x 75x 21100x 21100x | 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: `It's not possible to have comments between methods in global classes.`,
tags: [RuleTag.SingleFile, RuleTag.Syntax],
badExample: `CLASS zcl_foo IMPLEMENTATION.
METHOD first.
ENDMETHOD.
" comment
METHOD second.
ENDMETHOD.
ENDCLASS.`,
goodExample: `CLASS zcl_foo IMPLEMENTATION.
METHOD first.
ENDMETHOD.
METHOD second.
ENDMETHOD.
ENDCLASS.`,
};
}
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;
}
}
|