Skip to content

Commit

Permalink
fix codehealth can be full green
Browse files Browse the repository at this point in the history
  • Loading branch information
rrd108 committed Sep 3, 2024
1 parent bb30dfd commit a565310
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/vue-mess-detector.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -3456,7 +3456,7 @@ const fi = (t) => {
}, di = 1.5, In = 75, kn = 85, Pn = 95, ds = [...on, ...Object.values(fe).flat()], mi = (t, e, n) => {
const { errors: s, warnings: u } = t.reduce((y, { errors: E, warnings: C }) => ({ errors: y.errors + E, warnings: y.warnings + C }), { errors: 0, warnings: 0 }), o = [];
o.push({ info: `Found ${q}${Intl.NumberFormat("en-US").format(s)} errors${b}, and ${R}${Intl.NumberFormat("en-US").format(u)} warnings${b}, ${X}${Intl.NumberFormat("en-US").format(e)} lines${b} of code in ${X}${Intl.NumberFormat("en-US").format(n)} files${b}` });
const r = Math.ceil((1 - (s * di + u) / e) * 100), c = 60, h = Math.max(1, Math.ceil(u / e * c)), p = Math.max(1, c - Math.ceil(r * c / 100) - h), d = c - p - h, A = `${dt}${" ".repeat(d)}${R}${" ".repeat(h)}${q}${" ".repeat(p)}${b}`;
const r = Math.ceil((1 - (s * di + u) / e) * 100), c = 60, h = u ? Math.max(1, Math.ceil(u / e * c)) : 0, p = s ? Math.max(1, c - Math.ceil(r * c / 100) - h) : 0, d = c - p - h, A = `${dt}${" ".repeat(d)}${R}${" ".repeat(h)}${q}${" ".repeat(p)}${b}`;
return o.push({ info: `Code Health: [${A}] ${r}%
` }), r < In && o.push({ info: `${q}Code health is LOW: ${r}%${b}
` }), r >= In && r < kn && o.push({ info: `${R}Code health is MEDIUM ${r}%${b}
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/calculateCodeHealth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export const calculateCodeHealth = (health: Health[], linesCount: number, filesC
const codeHealth = Math.ceil((1 - (errors * ERROR_WEIGHT + warnings) / linesCount) * 100)

const BAR_WIDTH = 60
const yellowLength = Math.max(1, Math.ceil(warnings / linesCount * BAR_WIDTH))
const redLength = Math.max(1, BAR_WIDTH - Math.ceil(codeHealth * BAR_WIDTH / 100) - yellowLength)
const yellowLength = !warnings ? 0 : Math.max(1, Math.ceil(warnings / linesCount * BAR_WIDTH))
const redLength = !errors ? 0 : Math.max(1, BAR_WIDTH - Math.ceil(codeHealth * BAR_WIDTH / 100) - yellowLength)
const greenLength = BAR_WIDTH - redLength - yellowLength

const healthBar = `${BG_OK}${' '.repeat(greenLength)}${BG_WARN}${' '.repeat(yellowLength)}${BG_ERR}${' '.repeat(redLength)}${BG_RESET}`
Expand Down

0 comments on commit a565310

Please sign in to comment.