kleros/kleros-v2

View on GitHub

Showing 113 of 1,343 total issues

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

import { ethers, getNamedAccounts, network, deployments } from "hardhat";
const { anyValue } = require("@nomicfoundation/hardhat-chai-matchers/withArgs");
import { BigNumber } from "ethers";
import {
  PNK,
Severity: Major
Found in contracts/test/arbitration/staking-neo.ts - About 1 day to fix

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

import { DisputeKitClassic, KlerosCore, PNK, RandomizerRNG, BlockHashRNG, SortitionModule } from "../typechain-types";
import request from "graphql-request";
import env from "./utils/env";
import loggerFactory from "./utils/logger";
import { BigNumber } from "ethers";
Severity: Major
Found in contracts/scripts/keeperBot.ts - About 1 day to fix

Function main has a Cognitive Complexity of 58 (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 458 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

Function main has 166 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

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

import { describe, expect, it, vi } from "vitest";
import { populateTemplate } from "src/dataMappings/utils/populateTemplate";
import { jsonAction } from "src/dataMappings/actions/jsonAction";
import { subgraphAction } from "src/dataMappings/actions/subgraphAction";
import { callAction } from "src/dataMappings/actions/callAction";
Severity: Minor
Found in kleros-sdk/test/dataMappings.test.ts - About 5 hrs to fix

File draw.ts has 356 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 { BigNumber, ContractReceipt, ContractTransaction, Wallet } 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 100 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 { AddressZero } = hre.ethers.constants;
  const RNG_LOOKAHEAD = 20;
Severity: Major
Found in contracts/deploy/00-home-chain-arbitration-neo.ts - About 4 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 authUser has 80 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const authUser = async (event) => {
  try {
    if (!event.body) {
      throw new Error("No body provided");
    }
Severity: Major
Found in web/netlify/functions/authUser.ts - About 3 hrs to fix

File supabase-datalake.ts has 295 lines of code (exceeds 250 allowed). Consider refactoring.
Open

export type Json = string | number | boolean | null | { [key: string]: Json | undefined } | Json[];

export interface Database {
  public: {
    Tables: {
Severity: Minor
Found in web/src/types/supabase-datalake.ts - About 3 hrs to fix

Function App has 75 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 authUser has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

const authUser = async (event) => {
  try {
    if (!event.body) {
      throw new Error("No body provided");
    }
Severity: Minor
Found in web/netlify/functions/authUser.ts - 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

Function deployArbitration has 70 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 { AddressZero } = hre.ethers.constants;

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

Function SubmitDisputeButton has 63 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 2 hrs to fix

Function deployHomeGateway has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
  const { ethers, deployments, getNamedAccounts } = hre;
  const { deploy, execute } = deployments;
  const { hexZeroPad, hexlify } = ethers.utils;

Severity: Major
Found in contracts/deploy/03-vea-mock.ts - About 2 hrs to fix
Severity
Category
Status
Source
Language