Showing 7 of 13 total issues
Function LeaderBoard
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const LeaderBoard = () => {
const { data, isLoading, error } = useQuery({
queryKey: ["top-scores"],
queryFn: async () => {
const res = await axios.get<TScore[]>("/api/top-scores");
- Create a ticketCreate a ticket
Function POST
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function POST(req: NextRequest) {
const headersList = headers();
const ip = headersList.get("x-forwarded-for") ?? "127.0.0.1";
const { success, reset } = await ratelimit.limit(ip);
- Create a ticketCreate a ticket
Function handleSubmit
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const handleSubmit = (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();
if (name.length === 0) {
toast({ title: "Missing Name", variant: "error" });
- Create a ticketCreate a ticket
Function POST
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
export async function POST(req: NextRequest) {
const headersList = headers();
const ip = headersList.get("x-forwarded-for") ?? "127.0.0.1";
const { success, reset } = await ratelimit.limit(ip);
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this function. Open
Open
return NextResponse.json(error, { status: 500 });
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
Open
return NextResponse.json(dbEntry, { status: 200, statusText: "OK" });
- Create a ticketCreate a ticket
Function EndGameInput
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
const EndGameInput: React.FC<TEndGameInput> = ({
final_score,
gameStartTime,
gameEndTime,
}) => {
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"