|
| 1 | +var __create = Object.create; |
| 2 | +var __defProp = Object.defineProperty; |
| 3 | +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
| 4 | +var __getOwnPropNames = Object.getOwnPropertyNames; |
| 5 | +var __getProtoOf = Object.getPrototypeOf; |
| 6 | +var __hasOwnProp = Object.prototype.hasOwnProperty; |
| 7 | +var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); |
| 8 | +var __reExport = (target, module2, copyDefault, desc) => { |
| 9 | + if (module2 && typeof module2 === "object" || typeof module2 === "function") { |
| 10 | + for (let key of __getOwnPropNames(module2)) |
| 11 | + if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default")) |
| 12 | + __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable }); |
| 13 | + } |
| 14 | + return target; |
| 15 | +}; |
| 16 | +var __toESM = (module2, isNodeMode) => { |
| 17 | + return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2); |
| 18 | +}; |
| 19 | + |
| 20 | +// src/index.ts |
| 21 | +var import_path = __toESM(require("path"), 1); |
| 22 | +var SONARQUBE_SEVERITY = { |
| 23 | + "-1": "INFO", |
| 24 | + 1: "MINOR", |
| 25 | + 2: "CRITICAL" |
| 26 | +}; |
| 27 | +var SONARQUBE_TYPE = { |
| 28 | + "-1": "CODE_SMELL", |
| 29 | + 1: "CODE_SMELL", |
| 30 | + 2: "BUG" |
| 31 | +}; |
| 32 | +module.exports = class SonarQubeFormatter { |
| 33 | + constructor(options) { |
| 34 | + this.defaultFileExtension = "json"; |
| 35 | + this.options = options; |
| 36 | + } |
| 37 | + format(results) { |
| 38 | + const issues = []; |
| 39 | + if (this.options.hasResultData) { |
| 40 | + for (const filePath of Object.keys(results.files)) { |
| 41 | + let result = results.files[filePath]; |
| 42 | + let relativePath = import_path.default.relative(this.options.workingDirectory, result.filePath); |
| 43 | + for (const message of result.messages) { |
| 44 | + issues.push({ |
| 45 | + engineId: "ember-template-lint", |
| 46 | + ruleId: message.rule, |
| 47 | + severity: SONARQUBE_SEVERITY[message.severity], |
| 48 | + type: SONARQUBE_TYPE[message.severity], |
| 49 | + primaryLocation: { |
| 50 | + message: message.message, |
| 51 | + filePath: relativePath, |
| 52 | + textRange: { |
| 53 | + startLine: message.line, |
| 54 | + startColumn: message.column, |
| 55 | + endLine: message.endLine, |
| 56 | + endColumn: message.endColumn |
| 57 | + } |
| 58 | + } |
| 59 | + }); |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | + return JSON.stringify({ issues }, null, 2); |
| 64 | + } |
| 65 | +}; |
0 commit comments