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 80 81 82 83 84 85 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 14684x 14684x 14684x 14684x 14684x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 72159x 14684x 14684x 14120x 14120x 14684x 14684x 264x 264x 14684x 14684x 311x 311x 311x 311x 1796x 1796x 208x 208x 1796x 355x 355x 1588x 1203x 1203x 30x 30x 1796x 6x 6x 24x 24x 1796x 13x 13x 11x 11x 11x 311x 311x 311x 14684x 14684x | 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 {Comment} from "../abap/2_statements/statements/_statement";
export class AbapdocLeadingAtConf extends BasicRuleConfig {
}
export class AbapdocLeadingAt extends ABAPRule {
private conf = new AbapdocLeadingAtConf();
public getMetadata(): IRuleMetadata {
return {
key: "abapdoc_leading_at",
title: "ABAP Doc line starting with @",
shortDescription: `Reports ABAP Doc lines starting with "@" which is not followed by a command.`,
extendedInformation: `In ABAP Doc, "@" at the start of a line introduces a command, the commands are
@parameter, @raising and @exception. Any other text after a leading "@", like a CDS annotation,
gives the syntax warning 'A command was expected after ABAP Doc symbol "@"'.
An "@" in the middle of a line is plain text and not reported.
Only checks ABAP Doc inside class definitions and interfaces.`,
tags: [RuleTag.SingleFile],
badExample: `CLASS zcl_foo DEFINITION PUBLIC.
PUBLIC SECTION.
"! the first of
"! @UI.presentationVariant sortOrder
DATA mv_sort_field TYPE string.
ENDCLASS.`,
goodExample: `CLASS zcl_foo DEFINITION PUBLIC.
PUBLIC SECTION.
"! the first of @UI.presentationVariant
"! sortOrder
DATA mv_sort_field TYPE string.
ENDCLASS.`,
};
}
public getConfig() {
return this.conf;
}
public setConfig(conf: AbapdocLeadingAtConf) {
this.conf = conf;
}
public runParsed(file: ABAPFile): Issue[] {
const issues: Issue[] = [];
let definition = false;
for (const statement of file.getStatements()) {
const type = statement.get();
if (type instanceof Statements.ClassDefinition || type instanceof Statements.Interface) {
definition = true;
continue;
} else if (type instanceof Statements.EndClass || type instanceof Statements.EndInterface) {
definition = false;
continue;
} else if (definition === false || !(type instanceof Comment)) {
continue;
}
const token = statement.getFirstToken();
const str = token.getStr();
if (str.startsWith(`"!`) === false) {
continue;
}
const text = str.substring(2).trimStart();
if (text.startsWith("@") === false
|| text.match(/^@(parameter|raising|exception)(\s|$)/i) !== null) {
continue;
}
const message = `A command was expected after ABAP Doc symbol "@", move the "@" away from the start of the line`;
issues.push(Issue.atToken(file, token, message, this.getMetadata().key, this.conf.severity));
}
return issues;
}
}
|