{"version":3,"sources":["../src/linter/summary.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AAO3C,qBAAa,aAAa;IACzB,SAAgB,MAAM,EAAE,YAAY,CAAC;IACrC,SAAgB,MAAM,EAAE,YAAY,CAAC;IACrC,SAAgB,QAAQ,EAAE,YAAY,CAAC;IAChC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,SAAgB,WAAW,EAAE,gBAAgB,EAAE,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC;IACzB,SAAgB,MAAM,EAAE;QACvB,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,KAAK,EAAE,CAAC;KAChB,CAAC;gBAEU,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC;IAenC,QAAQ,IAAI,YAAY;IAQxB,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY;IA0CjD,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI;IA6B5C,IAAI,IAAI,IAAI;CAsCnB","file":"summary.d.ts","sourcesContent":["/**\n *\tMIT License\n *\n *\tCopyright (c) 2019 - 2022 Toreda, Inc.\n *\n *\tPermission is hereby granted, free of charge, to any person obtaining a copy\n *\tof this software and associated documentation files (the \"Software\"), to deal\n *\tin the Software without restriction, including without limitation the rights\n *\tto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n *\tcopies of the Software, and to permit persons to whom the Software is\n *\tfurnished to do so, subject to the following conditions:\n\n * \tThe above copyright notice and this permission notice shall be included in all\n * \tcopies or substantial portions of the Software.\n *\n * \tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n *\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n *\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * \tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n *\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n *\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * \tSOFTWARE.\n *\n */\n\nimport type {LinterFileResult} from './file/result';\nimport type {LinterLimits} from './limits';\nimport type {LinterTotals} from './totals';\n\n/**\n * Contains relevant summary data for a lint operation.\n *\n * @category Linter\n */\nexport class LinterSummary {\n\tpublic readonly limits: LinterLimits;\n\tpublic readonly errors: LinterTotals;\n\tpublic readonly warnings: LinterTotals;\n\tpublic resultText: string | null;\n\tpublic readonly fileResults: LinterFileResult[];\n\tpublic errorCode: string;\n\tpublic readonly status: {\n\t\tsuccess: boolean;\n\t\tcode: string;\n\t\tdescription: string;\n\t\terrors: Error[];\n\t};\n\n\tconstructor(limits?: Partial<LinterLimits>) {\n\t\tthis.errors = this.mkTotals();\n\t\tthis.warnings = this.mkTotals();\n\t\tthis.limits = this.mkLimits(limits);\n\n\t\tthis.fileResults = [];\n\t\tthis.resultText = null;\n\t\tthis.status = {\n\t\t\tsuccess: false,\n\t\t\terrors: [],\n\t\t\tcode: '',\n\t\t\tdescription: ''\n\t\t};\n\t}\n\n\tpublic mkTotals(): LinterTotals {\n\t\treturn {\n\t\t\tfatal: 0,\n\t\t\tfixable: 0,\n\t\t\ttotal: 0\n\t\t};\n\t}\n\n\tpublic mkLimits(o?: Partial<LinterLimits>): LinterLimits {\n\t\tconst limits: LinterLimits = {\n\t\t\terrors: {\n\t\t\t\ttotal: 0,\n\t\t\t\tfixable: 0,\n\t\t\t\tfatal: 0\n\t\t\t},\n\t\t\twarn: {\n\t\t\t\ttotal: 0,\n\t\t\t\tfixable: 0\n\t\t\t}\n\t\t};\n\n\t\tif (o) {\n\t\t\tif (o.errors) {\n\t\t\t\tif (typeof o.errors.total === 'number') {\n\t\t\t\t\tlimits.errors.total = o.errors.total;\n\t\t\t\t}\n\n\t\t\t\tif (typeof o.errors.fatal === 'number') {\n\t\t\t\t\tlimits.errors.fatal = o.errors.fatal;\n\t\t\t\t}\n\n\t\t\t\tif (typeof o.errors.fixable === 'number') {\n\t\t\t\t\tlimits.errors.fixable = o.errors.fixable;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (o.warn) {\n\t\t\t\tif (typeof o.warn.fixable === 'number') {\n\t\t\t\t\tlimits.warn.fixable = o.warn.fixable;\n\t\t\t\t}\n\n\t\t\t\tif (typeof o.warn.total === 'number') {\n\t\t\t\t\tlimits.warn.total = o.warn.total;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn limits;\n\t}\n\n\tpublic add(result: Partial<LinterFileResult>): void {\n\t\tif (!result) {\n\t\t\tthrow new Error(`add:result:arg:missing`);\n\t\t}\n\n\t\tif (typeof result.errorCount === 'number') {\n\t\t\tthis.errors.total += result.errorCount;\n\t\t}\n\n\t\tif (typeof result.fixableErrorCount === 'number') {\n\t\t\tthis.errors.fixable += result.fixableErrorCount;\n\t\t\tthis.errors.total += result.fixableErrorCount;\n\t\t}\n\n\t\tif (typeof result.fatalErrorCount === 'number') {\n\t\t\tthis.errors.fatal += result.fatalErrorCount;\n\t\t\tthis.errors.total += result.fatalErrorCount;\n\t\t}\n\n\t\tif (typeof result.warningCount === 'number') {\n\t\t\tthis.warnings.total += result.warningCount;\n\t\t}\n\n\t\tif (typeof result.fixableWarningCount === 'number') {\n\t\t\tthis.warnings.fixable += result.fixableWarningCount;\n\t\t\tthis.warnings.total += result.fixableWarningCount;\n\t\t}\n\t}\n\n\tpublic done(): void {\n\t\tif (this.limits.errors.total !== 0 && this.errors.total > this.limits.errors.total) {\n\t\t\tthis.status.code = 'ERROR_LIMIT_EXCEEDED';\n\t\t\tthis.status.description = `Too many total errors detected. Total error count of '${this.errors.total}' exceeded limit '${this.limits.errors.total}'`;\n\t\t\tthis.status.success = false;\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.errors.fixable !== 0 && this.errors.fixable > this.limits.errors.fixable) {\n\t\t\tthis.status.success = false;\n\t\t\tthis.status.code = 'FIXABLE_ERROR_LIMIT_EXCEEDED';\n\t\t\tthis.status.description = `Too many fixable errors detected. Fixable error count '${this.errors.fixable}' exceeds the configured limit '${this.limits.errors.fixable}'.`;\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.errors.fatal !== 0 && this.errors.fatal > this.limits.errors.fatal) {\n\t\t\tthis.status.success = false;\n\t\t\tthis.status.code = 'FATAL_ERROR_LIMIT_EXCEEDED';\n\t\t\tthis.status.description = `Too many fatal errors detected. Fatal error count '${this.errors.fatal}' exceeds configured limit '${this.limits.errors.fatal}.`;\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.warnings.fixable !== 0 && this.warnings.fixable > this.limits.warn.fixable) {\n\t\t\tthis.status.success = false;\n\t\t\tthis.status.code = 'FIXABLE_WARN_LIMIT_EXCEEDED';\n\t\t\tthis.status.description = `Too many fixable warnings detected. Fixable warning count '${this.warnings.fixable}' exceeds configured limit '${this.limits.warn.fixable}'.`;\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.warnings.total !== 0 && this.warnings.total > this.limits.warn.total) {\n\t\t\tthis.status.success = false;\n\t\t\tthis.status.code = 'WARN_LIMIT_EXCEEDED';\n\t\t\tthis.status.description = `Too many warnings detected. Total warning count '${this.warnings.total}' exceeds configured limit '${this.limits.warn.total}'`;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.status.success = true;\n\t}\n}\n"]}