Skip to content

Commit

Permalink
fix add missing points property
Browse files Browse the repository at this point in the history
  • Loading branch information
rrd108 committed Sep 23, 2024
1 parent d777885 commit 85bd679
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions dist/vue-mess-detector.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -3169,9 +3169,11 @@ const Zo = (t) => {
maxScriptLength: 100,
maxFileSize: 300
}, Qo = (t, e, n) => {
const { errors: s, warnings: r } = t.reduce((g, { errors: E, warnings: d }) => ({ errors: g.errors + E, warnings: g.warnings + d }), { errors: 0, warnings: 0 }), i = [], o = { errors: s, warnings: r, linesCount: e, filesCount: n };
const { errors: s, warnings: r } = t.reduce((g, { errors: E, warnings: d }) => ({ errors: g.errors + E, warnings: g.warnings + d }), { errors: 0, warnings: 0 }), i = [], o = { errors: s, warnings: r, linesCount: e, filesCount: n, points: 0 };
i.push({ info: `Found <bg_err>${Intl.NumberFormat("en-US").format(s)} errors</bg_err>, and <bg_warn>${Intl.NumberFormat("en-US").format(r)} warnings</bg_warn>, <bg_info>${Intl.NumberFormat("en-US").format(e)} lines</bg_info> of code in <bg_info>${Intl.NumberFormat("en-US").format(n)} files</bg_info>` });
const u = Math.ceil((1 - (s * Ko + r) / e) * 100), a = 60, h = r ? Math.max(1, Math.ceil(r / e * a)) : 0, f = s ? Math.max(1, a - Math.ceil(u * a / 100) - h) : 0, C = a - f - h, m = `<bg_ok>${"_".repeat(C)}</bg_ok><bg_warn>${"_".repeat(h)}</bg_warn><bg_err>${"_".repeat(f)}</bg_err>`;
const u = Math.ceil((1 - (s * Ko + r) / e) * 100);
o.points = u;
const a = 60, h = r ? Math.max(1, Math.ceil(r / e * a)) : 0, f = s ? Math.max(1, a - Math.ceil(u * a / 100) - h) : 0, C = a - f - h, m = `<bg_ok>${"_".repeat(C)}</bg_ok><bg_warn>${"_".repeat(h)}</bg_warn><bg_err>${"_".repeat(f)}</bg_err>`;
return i.push({ info: `Code Health: [${m}] ${u}%
` }), u < ns && i.push({ info: `<bg_err>Code health is LOW: ${u}%</bg_err>
` }), u >= ns && u < ss && i.push({ info: `<bg_warn>Code health is MEDIUM ${u}%$</bg_warn>
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/calculateCodeHealth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ export const calculateCodeHealth = (health: Health[], linesCount: number, filesC
const { errors, warnings } = health.reduce((acc, { errors, warnings }) => ({ errors: acc.errors + errors, warnings: acc.warnings + warnings }), { errors: 0, warnings: 0 })

const output: { info: string }[] = []
const codeHealth = { errors, warnings, linesCount, filesCount }
const codeHealth = { errors, warnings, linesCount, filesCount, points: 0 }

output.push({ info: `Found <bg_err>${Intl.NumberFormat('en-US').format(errors)} errors</bg_err>, and <bg_warn>${Intl.NumberFormat('en-US').format(warnings)} warnings</bg_warn>, <bg_info>${Intl.NumberFormat('en-US').format(linesCount)} lines</bg_info> of code in <bg_info>${Intl.NumberFormat('en-US').format(filesCount)} files</bg_info>` })

const codeHealthPoints = Math.ceil((1 - (errors * ERROR_WEIGHT + warnings) / linesCount) * 100)
codeHealth.points = codeHealthPoints

const BAR_WIDTH = 60
const yellowLength = !warnings ? 0 : Math.max(1, Math.ceil(warnings / linesCount * BAR_WIDTH))
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface CodeHealth {
warnings: number
linesCount: number
filesCount: number
points: number
}

export interface CodeHealthResponse {
Expand Down

0 comments on commit 85bd679

Please sign in to comment.