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 11714x 11714x 11714x 11714x 57347x 57347x 57347x 57347x 57347x 57347x 57347x 57347x 57347x 57347x 57347x 57347x 57347x 57347x 11714x 11714x 11176x 11176x 11714x 11714x 253x 253x 11714x 11714x 256x 256x 11714x 11714x 344x 344x 344x 344x 7x 7x 7x 7x 105x 1x 1x 105x 7x 344x 344x 344x 11714x 11714x | import {Issue} from "../issue";
import {IRule, IRuleMetadata, RuleTag} from "./_irule";
import {IObject} from "../objects/_iobject";
import {IRegistry} from "../_iregistry";
import {BasicRuleConfig} from "./_basic_rule_config";
import {CDSMetadataExtension, DataDefinition} from "../objects";
import {CDSLexer} from "../cds/cds_lexer";
import {Comment} from "../abap/1_lexer/tokens";
export class CDSCommentStyleConf extends BasicRuleConfig {
}
export class CDSCommentStyle implements IRule {
private conf = new CDSCommentStyleConf();
public getMetadata(): IRuleMetadata {
return {
key: "cds_comment_style",
title: "CDS Comment Style",
shortDescription: `Check for obsolete comment style`,
extendedInformation: `Check for obsolete comment style
Comments starting with "--" are considered obsolete
https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-us/abencds_general_syntax_rules.html`,
tags: [RuleTag.SingleFile],
badExample: "-- this is a comment",
goodExample: "// this is a comment",
};
}
public getConfig() {
return this.conf;
}
public setConfig(conf: CDSCommentStyleConf) {
this.conf = conf;
}
public initialize(_reg: IRegistry): IRule {
return this;
}
public run(object: IObject): Issue[] {
const issues: Issue[] = [];
if ((object.getType() === "DDLS" && object instanceof DataDefinition) ||
(object.getType() === "DDLX" && object instanceof CDSMetadataExtension)) {
const file = object.findSourceFile();
if (file === undefined) {
return issues;
}
const tokens = CDSLexer.run(file);
for (const t of tokens) {
if (t instanceof Comment && t.getStr().startsWith("--")) {
issues.push(Issue.atToken(file, t, `Use "//" for comments instead of "--"`, this.getMetadata().key, this.getConfig().severity));
}
}
}
return issues;
}
} |