UNPKG

@abaplint/core

Version:
57 lines 2.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LineLength = exports.LineLengthConf = void 0; const issue_1 = require("../issue"); const _abap_rule_1 = require("./_abap_rule"); const _basic_rule_config_1 = require("./_basic_rule_config"); const _irule_1 = require("./_irule"); class LineLengthConf extends _basic_rule_config_1.BasicRuleConfig { constructor() { super(...arguments); /** Maximum line length in characters, trailing whitespace ignored */ this.length = 120; } } exports.LineLengthConf = LineLengthConf; class LineLength extends _abap_rule_1.ABAPRule { constructor() { super(...arguments); this.conf = new LineLengthConf(); } getMetadata() { return { key: "line_length", title: "Line length", shortDescription: `Detects lines exceeding the provided maximum length.`, extendedInformation: `https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md#stick-to-a-reasonable-line-length https://docs.abapopenchecks.org/checks/04/`, tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile], }; } getConfig() { return this.conf; } setConfig(conf) { this.conf = conf; } runParsed(file) { const issues = []; // maximum line length in abap files const maxLineLength = 255; const array = file.getRawRows(); for (let rowIndex = 0; rowIndex < array.length; rowIndex++) { const row = array[rowIndex].replace("\r", ""); if (row.length > maxLineLength) { const message = `Maximum allowed line length of ${maxLineLength} exceeded, currently ${row.length}`; issues.push(issue_1.Issue.atRow(file, rowIndex + 1, message, this.getMetadata().key, this.conf.severity)); } else if (row.length > this.conf.length) { const message = `Reduce line length to max ${this.conf.length}, currently ${row.length}`; issues.push(issue_1.Issue.atRow(file, rowIndex + 1, message, this.getMetadata().key, this.conf.severity)); } } return issues; } } exports.LineLength = LineLength; //# sourceMappingURL=line_length.js.map