UNPKG

@abaplint/core

Version:
60 lines (58 loc) 2.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CDSCommentStyle = exports.CDSCommentStyleConf = void 0; const issue_1 = require("../issue"); const _irule_1 = require("./_irule"); const _basic_rule_config_1 = require("./_basic_rule_config"); const objects_1 = require("../objects"); const cds_lexer_1 = require("../cds/cds_lexer"); const tokens_1 = require("../abap/1_lexer/tokens"); class CDSCommentStyleConf extends _basic_rule_config_1.BasicRuleConfig { } exports.CDSCommentStyleConf = CDSCommentStyleConf; class CDSCommentStyle { constructor() { this.conf = new CDSCommentStyleConf(); } getMetadata() { 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_752_index_htm/7.52/en-us/abencds_general_syntax_rules.htm`, tags: [_irule_1.RuleTag.SingleFile], badExample: "-- this is a comment", goodExample: "// this is a comment", }; } getConfig() { return this.conf; } setConfig(conf) { this.conf = conf; } initialize(_reg) { return this; } run(object) { const issues = []; if ((object.getType() === "DDLS" && object instanceof objects_1.DataDefinition) || (object.getType() === "DDLX" && object instanceof objects_1.CDSMetadataExtension)) { const file = object.findSourceFile(); if (file === undefined) { return issues; } const tokens = cds_lexer_1.CDSLexer.run(file); for (const t of tokens) { if (t instanceof tokens_1.Comment && t.getStr().startsWith("--")) { issues.push(issue_1.Issue.atToken(file, t, `Use "//" for comments instead of "--"`, this.getMetadata().key, this.getConfig().severity)); } } } return issues; } } exports.CDSCommentStyle = CDSCommentStyle; //# sourceMappingURL=cds_comment_style.js.map