Spaces:
Sleeping
Sleeping
File size: 1,795 Bytes
161cb23 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | 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" };
}
|