kleros/kleros-v2

View on GitHub

Showing 142 of 1,394 total issues

Function Stats has a Cognitive Complexity of 11 (exceeds 5 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: Minor
Found in web/src/pages/Courts/CourtDetails/Stats.tsx - About 1 hr 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 updateJurorEffectiveStake has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export function updateJurorEffectiveStake(jurorAddress: string, courtID: string): void {
  let court = Court.load(courtID);
  if (!court) {
    return;
  }
Severity: Minor
Found in subgraph/core/src/entities/JurorTokensPerCourt.ts - About 1 hr 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 uploadToIpfs has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function uploadToIpfs(config: Config, payload: IpfsUploadPayload): Promise<string | null> {
  const formData = new FormData();
  formData.append("file", payload.file, payload.name);
  formData.append("name", payload.name);
  formData.append("product", payload.product);
Severity: Minor
Found in web/src/utils/atlas/uploadToIpfs.ts - About 1 hr to fix

Function General has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const General: React.FC = () => {
  const { address, chain } = useAccount();

  const addressExplorerLink = useMemo(() => {
    return `${chain?.blockExplorers?.default.url}/address/${address}`;
Severity: Minor
Found in web/src/layout/Header/navbar/Menu/Settings/General.tsx - About 1 hr to fix

Function deployResolver has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const deployResolver: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
  const { ethers } = hre;

  const template = `{
    "$schema": "../NewDisputeTemplate.schema.json",
Severity: Minor
Found in contracts/deploy/05-arbitrable-dispute-template.ts - About 1 hr to fix

Function deployForeignGateway has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

Severity: Minor
Found in contracts/deploy/01-foreign-gateway-on-gnosis.ts - About 1 hr to fix

Function Court has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Court: React.FC = () => {
  const { disputeData, setDisputeData } = useNewDisputeContext();
  const { data } = useCourtTree();
  const items = useMemo(() => !isUndefined(data) && [rootCourtToItems(data.court)], [data]);

Severity: Minor
Found in web/src/pages/Resolver/Parameters/Court.tsx - About 1 hr to fix

Function Policy has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Policy: React.FC = () => {
  const { disputeData, setDisputeData, setIsPolicyUploading } = useNewDisputeContext();
  const { uploadFile } = useAtlasProvider();

  const handleFileUpload = (file: File) => {
Severity: Minor
Found in web/src/pages/Resolver/Policy/index.tsx - About 1 hr to fix

Function ExtraStats has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ExtraStats = () => {
  const [selectedRange, setSelectedRange] = useState(timeRanges[0].value);
  const data = useHomePageExtraStats(selectedRange);

  const handleTimeRangeChange = (value: string | number) => {
Severity: Minor
Found in web/src/pages/Home/CourtOverview/ExtraStats.tsx - About 1 hr to fix

Function deployForeignGateway has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
  const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
  const { execute } = deployments;
  const { zeroPadValue, toBeHex } = ethers;

Severity: Minor
Found in contracts/deploy/01-foreign-gateway-on-ethereum.ts - About 1 hr to fix

Function updateDisputeRequestData has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const updateDisputeRequestData = (event: DisputeCreation): void => {
  const dispute = Dispute.load(event.params._disputeID.toString());
  if (!dispute) return;

  const receipt = event.receipt;
Severity: Minor
Found in subgraph/core/src/entities/Dispute.ts - About 1 hr to fix

Function handleSubmit has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
    e.preventDefault();
    if (!address) {
      return;
    }

Function getCourtsPath has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export const getCourtsPath = (
  node: CourtTreeQuery["court"],
  id: string | undefined,
  path: IItem[] = []
): IItem[] | null => {
Severity: Minor
Found in web/src/pages/Courts/CourtDetails/index.tsx - About 1 hr 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 processData has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const processData = (data: HomePageBlockQuery, allTime: boolean) => {
  const presentCourts = data.presentCourts;
  const pastCourts = data.pastCourts;
  const processedCourts: CourtWithTree[] = Array(presentCourts.length);
  const processed = new Set();
Severity: Minor
Found in web/src/hooks/queries/useHomePageBlockQuery.ts - About 1 hr 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 QuantityToSimulate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const QuantityToSimulate: React.FC<IQuantityToSimulate> = ({
  isStaking,
  jurorCurrentEffectiveStake,
  jurorCurrentSpecificStake,
  amountToStake,

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 getFormattedRewards has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export const getFormattedRewards = (data: any, pricesData: any) => {
  return rewards.map(({ token, coinId, getValue, getAmount }) => {
    const coinPrice = !isUndefined(pricesData) ? pricesData[CoinIds[token]]?.price : undefined;

    const totalReward = data && calculateTotalJurorReward(coinId, data);
Severity: Minor
Found in web/src/utils/jurorRewardConfig.ts - About 1 hr 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 isRngReady has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const isRngReady = async () => {
  const { randomizerRng, blockHashRNG, sortition } = await getContracts();
  const currentRng = await sortition.rng();
  if (currentRng === randomizerRng?.target) {
    const requesterID = await randomizerRng.requesterToID(sortition.target);
Severity: Minor
Found in contracts/scripts/keeperBot.ts - About 1 hr to fix

Function executeDelayedStakes has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const executeDelayedStakes = async () => {
  const { sortition } = await getContracts();

  // delayedStakes = 1 + delayedStakeWriteIndex - delayedStakeReadIndex
  const delayedStakesRemaining =
Severity: Minor
Found in contracts/scripts/keeperBot.ts - About 1 hr to fix

Function accordionItems has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const accordionItems = useMemo(() => {
    return drawnJurors
      .map((drawnJuror) =>
        !isUndefined(drawnJuror.vote?.justification?.choice)
          ? {
Severity: Minor
Found in web/src/pages/Cases/CaseDetails/Voting/VotesDetails/index.tsx - About 1 hr to fix

Function updateCountsAndGetCurrentRuling has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function updateCountsAndGetCurrentRuling(id: string, choice: BigInt, delta: BigInt): CurrentRulingInfo {
  const round = ClassicRound.load(id);
  if (!round) return { ruling: ZERO, tied: false };
  const choiceNum = choice.toI32();
  const newChoiceCount = round.counts[choiceNum].plus(delta);
Severity: Minor
Found in subgraph/core/src/entities/ClassicRound.ts - About 1 hr to fix
Severity
Category
Status
Source
Language