codehygiene / web /src /labels.js
brianbellx's picture
Deploy scoring-only Space: remove edit model and fix features
a1415e8 verified
Raw History Blame Contribute Delete
1.8 kB
export const NOTES = {
deep_nesting: "deeply nested",
poor_naming: "unclear name or magic number",
noisy_comment: "redundant comment",
swallowed_error: "error silently ignored",
dense_line: "overlong line",
special_casing: "stacked special cases",
duplicate_block: "duplicated block",
cramped_layout: "dense block",
};
export const SOURCE_ERRORS = {
invalid: "Not a GitHub link",
not_found: "Repo not found",
rate_limited: "GitHub rate limit, try later",
no_files: "No code files found",
offline: "Offline",
};
export const RANK_ERRORS = {
too_small: "Too small to rank",
too_large: "Too large to rank",
fork: "Forks aren't ranked",
not_found: "Repo not found",
busy: "Busy, try later",
failed: "Rank failed",
};
export const LANGUAGES = {
py: "Python",
pyi: "Python",
ts: "TypeScript",
tsx: "TypeScript",
js: "JavaScript",
jsx: "JavaScript",
mjs: "JavaScript",
cjs: "JavaScript",
go: "Go",
rs: "Rust",
c: "C",
h: "C",
cc: "C++",
cpp: "C++",
cxx: "C++",
hpp: "C++",
zig: "Zig",
java: "Java",
cs: "C#",
lua: "Lua",
rb: "Ruby",
php: "PHP",
swift: "Swift",
kt: "Kotlin",
scala: "Scala",
sh: "Shell",
};
export function sentenceCase(text) {
return text.charAt(0).toUpperCase() + text.slice(1);
}
export function plural(count, noun) {
return count === 1 ? `1 ${noun}` : `${count} ${noun}s`;
}
export function issuesText(count) {
return count === 0 ? "No issues" : plural(count, "issue");
}
export function toHundred(score) {
return Math.round(score * 100);
}
export function scoreWord(points) {
if (points < 50) {
return { word: "poor", className: "is-sloppy" };
}
if (points < 75) {
return { word: "fair", className: "" };
}
return { word: "good", className: "is-clean" };
}