kleros/kleros-v2

View on GitHub

Showing 142 of 1,394 total issues

File staking-neo.ts has 625 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { ethers, getNamedAccounts, network, deployments } from "hardhat";
import {
  PNK,
  RandomizerRNG,
  RandomizerMock,
Severity: Major
Found in contracts/test/arbitration/staking-neo.ts - About 1 day to fix

File keeperBot.ts has 606 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  PNK,
  RandomizerRNG,
  BlockHashRNG,
  SortitionModule,
Severity: Major
Found in contracts/scripts/keeperBot.ts - About 1 day to fix

Function main has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

async function main() {
  const { core, sortition, disputeKitClassic } = await getContracts();

  const getBlockTime = async () => {
    return await ethers.provider.getBlock("latest").then((block) => {
Severity: Minor
Found in contracts/scripts/keeperBot.ts - About 1 day to fix

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

File tasks.ts has 474 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable promise/param-names */
import { toBigInt, BigNumberish, AddressLike } from "ethers";
import { ethers } from "ethers";
import { task } from "hardhat/config";
import {
Severity: Minor
Found in contracts/scripts/simulations/tasks.ts - About 7 hrs to fix

Function main has 167 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function main() {
  const { core, sortition, disputeKitClassic } = await getContracts();

  const getBlockTime = async () => {
    return await ethers.provider.getBlock("latest").then((block) => {
Severity: Major
Found in contracts/scripts/keeperBot.ts - About 6 hrs to fix

Function handleNewPeriod has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

export function handleNewPeriod(event: NewPeriod): void {
  const disputeID = event.params._disputeID;
  const dispute = Dispute.load(disputeID.toString());
  if (!dispute) return;
  const court = Court.load(dispute.court);
Severity: Minor
Found in subgraph/core/src/KlerosCore.ts - About 6 hrs to fix

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

File dataMappings.test.ts has 420 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { describe, expect, it, vi } from "vitest";
import { createResultObject } from "../src/dataMappings/utils/createResultObject";
import { executeActions, populateTemplate } from "../src";
import {
  AbiCallMapping,
Severity: Minor
Found in kleros-sdk/test/dataMappings.test.ts - About 6 hrs to fix

Function Stats has 130 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Stats = () => {
  const { id } = useParams();
  const { data } = useCourtDetails(id);
  const [selectedRange, setSelectedRange] = useState(timeRanges[0].value);
  const timeframedCourtData = useHomePageExtraStats(selectedRange);
Severity: Major
Found in web/src/pages/Courts/CourtDetails/Stats.tsx - About 5 hrs to fix

File draw.ts has 369 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { anyValue } from "@nomicfoundation/hardhat-chai-matchers/withArgs";
import { deployments, ethers, getNamedAccounts, network } from "hardhat";
import { toBigInt, ContractTransactionResponse, HDNodeWallet } from "ethers";
import {
  PNK,
Severity: Minor
Found in contracts/test/arbitration/draw.ts - About 4 hrs to fix

Function CardLabel has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

const CardLabel: React.FC<ICardLabels> = ({ disputeId, round, isList }) => {
  const { address } = useAccount();
  const { data: labelInfo, isLoading } = useLabelInfoQuery(address?.toLowerCase(), disputeId);
  const localRounds = getLocalRounds(labelInfo?.dispute?.disputeKitDispute);
  const rounds = labelInfo?.dispute?.rounds;
Severity: Minor
Found in web/src/components/DisputeView/CardLabels/index.tsx - About 4 hrs to fix

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

Function deployArbitration has 101 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
  const { ethers, deployments, getNamedAccounts, getChainId } = hre;
  const { deploy, execute } = deployments;
  const { ZeroAddress } = hre.ethers;
  const RNG_LOOKAHEAD = 20;
Severity: Major
Found in contracts/deploy/00-home-chain-arbitration-neo.ts - About 4 hrs to fix

File Stats.tsx has 319 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, { useMemo, useState } from "react";
import styled, { css } from "styled-components";
import { landscapeStyle } from "styles/landscapeStyle";
import { responsiveSize } from "styles/responsiveSize";

Severity: Minor
Found in web/src/pages/Courts/CourtDetails/Stats.tsx - About 3 hrs to fix

Function deployKlerosLiquid has 87 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const deployKlerosLiquid: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
  const { ethers, deployments, getNamedAccounts, getChainId } = hre;
  const { deploy, execute } = deployments;

  // fallback to hardhat node signers on local network
Severity: Major
Found in contracts/deploy/04-klerosliquid-to-v2-gnosis.ts - About 3 hrs to fix

Function StakeWithdrawButton has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

const StakeWithdrawButton: React.FC<IActionButton> = ({
  parsedAmount,
  action,
  isSending,
  setIsSending,
Severity: Minor
Found in web/src/pages/Courts/CourtDetails/StakePanel/StakeWithdrawButton.tsx - About 3 hrs to fix

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

Function App has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const App: React.FC = () => {
  return (
    <StyledComponentsProvider>
      <Web3Provider>
        <QueryClientProvider>
Severity: Major
Found in web/src/app.tsx - About 3 hrs to fix

Function SubmitDisputeButton has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const SubmitDisputeButton: React.FC = () => {
  const publicClient = usePublicClient();
  const [isPopupOpen, setIsPopupOpen] = useState(false);
  const [courtId, setCourtId] = useState("");
  const [disputeId, setDisputeId] = useState<number>();
Severity: Major
Found in web/src/pages/Resolver/NavigationButtons/SubmitDisputeButton.tsx - About 3 hrs to fix

Function handleNewPeriod has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function handleNewPeriod(event: NewPeriod): void {
  const disputeID = event.params._disputeID;
  const dispute = Dispute.load(disputeID.toString());
  if (!dispute) return;
  const court = Court.load(dispute.court);
Severity: Major
Found in subgraph/core/src/KlerosCore.ts - About 2 hrs to fix

Function deployArbitration has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
  const { ethers, deployments, getNamedAccounts, getChainId } = hre;
  const { deploy } = deployments;
  const { ZeroAddress } = hre.ethers;

Severity: Major
Found in contracts/deploy/00-home-chain-arbitration-university.ts - About 2 hrs to fix

Function MaintenanceButtons has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const MaintenanceButtons: React.FC = () => {
  const { id } = useParams();
  const [isOpen, setIsOpen] = useState(false);
  const [displayRipple, setDisplayRipple] = useState(false);

Severity: Major
Found in web/src/pages/Cases/CaseDetails/MaintenanceButtons/index.tsx - About 2 hrs to fix

Function main has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

def main():
    block_number = block
    tasks = ["Evidence"]
    contracts = get_contracts()
    while True:
Severity: Minor
Found in bot-pinner/src/add_hashes.py - About 2 hrs to fix

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

Severity
Category
Status
Source
Language