kleros/kleros-v2

View on GitHub

Showing 142 of 1,394 total issues

Avoid deeply nested control flow statements.
Open

        if (vote.choice!.equals(dispute.currentRuling)) {
          juror.totalCoherentVotes = juror.totalCoherentVotes.plus(ONE);
        }
Severity: Major
Found in subgraph/core/src/KlerosCore.ts - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

        if (juror.totalResolvedVotes.gt(ZERO)) {
          juror.coherenceScore = computeCoherenceScore(juror.totalCoherentVotes, juror.totalResolvedVotes);
        }
Severity: Major
Found in subgraph/core/src/KlerosCore.ts - About 45 mins to fix

Function deployArbitration has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

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

Severity: Minor
Found in contracts/deploy/00-home-chain-arbitration.ts - About 45 mins 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

Avoid deeply nested control flow statements.
Open

        if (!vote) continue;
Severity: Major
Found in subgraph/core/src/KlerosCore.ts - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

          if (!(await drawJurors(dispute, drawIterations))) {
            logger.info(`Failed to draw jurors for dispute #${dispute.id}, skipping it`);
            break;
          }
Severity: Major
Found in contracts/scripts/keeperBot.ts - About 45 mins to fix

Function PassPhaseButton has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const PassPhaseButton: React.FC<IPassPhaseButton> = ({ setIsOpen }) => {
  const [isSending, setIsSending] = useState(false);
  const publicClient = usePublicClient();
  const { data: phase } = useSortitionModulePhase();
  const { data: lastPhaseChange } = useReadSortitionModuleLastPhaseChange();
Severity: Minor
Found in web/src/pages/Courts/StakeMaintenanceButton/PassPhaseButton.tsx - About 45 mins 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 PassPeriodButton has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const PassPeriodButton: React.FC<IPassPeriodButton> = ({ id, setIsOpen, period }) => {
  const [isSending, setIsSending] = useState(false);
  const publicClient = usePublicClient();
  const { data: maintenanceData } = useDisputeMaintenanceQuery(id);

Severity: Minor
Found in web/src/pages/Cases/CaseDetails/MaintenanceButtons/PassPeriodButton.tsx - About 45 mins 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

Avoid deeply nested control flow statements.
Open

        if (!draw) continue;
Severity: Major
Found in subgraph/core/src/KlerosCore.ts - About 45 mins to fix

Function StageTwo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const StageTwo: React.FC<IStageTwo> = ({ setAmount }) => {
  const { paidFees, winningChoice, winnerRequiredFunding, fundedChoices } = useFundingContext();
  const { winnerSideCountdown } = useCountdownContext();
  const options = useOptionsContext();
  const { selectedOption, setSelectedOption } = useSelectedOptionContext();
Severity: Minor
Found in web/src/pages/Cases/CaseDetails/Appeal/Classic/Options/StageTwo.tsx - About 45 mins 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 createClassicVote has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  id: string,
  juror: string,
  voteID: BigInt,
  localRoundID: string,
  coreDispute: Dispute
Severity: Minor
Found in subgraph/core/src/entities/ClassicVote.ts - About 35 mins to fix

Function DisputeInfo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const DisputeInfo: React.FC<IDisputeInfo> = ({
  disputeID,
  courtId,
  court,
  category,
Severity: Minor
Found in web/src/components/DisputeView/DisputeInfo/index.tsx - About 35 mins 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 NumberInputField has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const NumberInputField: React.FC<INumberInputField> = ({
  placeholder,
  message,
  value,
  onChange,
Severity: Minor
Found in web/src/components/NumberInputField.tsx - About 35 mins 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 DisputeContext has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const DisputeContext: React.FC<IDisputeContext> = ({ disputeDetails, isRpcError = false }) => {
  const errMsg = isRpcError ? RPC_ERROR : INVALID_DISPUTE_DATA_ERROR;
  return (
    <>
      <StyledH1>{isUndefined(disputeDetails) ? <StyledSkeleton /> : disputeDetails?.title ?? errMsg}</StyledH1>
Severity: Minor
Found in web/src/components/DisputePreview/DisputeContext.tsx - About 35 mins 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 getPeriodLabel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const getPeriodLabel = (period: Periods, isCard: boolean): string => {
  switch (period) {
    case Periods.evidence:
      return `${isCard ? "In Progress - " : ""}Submitting Evidence`;
    case Periods.commit:
Severity: Minor
Found in web/src/components/DisputeView/PeriodBanner.tsx - About 35 mins 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 a Cognitive Complexity of 7 (exceeds 5 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: Minor
Found in web/src/pages/Resolver/NavigationButtons/SubmitDisputeButton.tsx - About 35 mins 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 handleEvidenceEvent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function handleEvidenceEvent(event: EvidenceEvent): void {
  const evidenceGroupID = event.params._externalDisputeID.toString();
  const evidenceGroup = ensureClassicEvidenceGroup(evidenceGroupID);
  const evidenceIndex = evidenceGroup.nextEvidenceIndex;
  evidenceGroup.nextEvidenceIndex = evidenceGroup.nextEvidenceIndex.plus(ONE);
Severity: Minor
Found in subgraph/core/src/EvidenceModule.ts - About 35 mins 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 DesktopHeader has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const DesktopHeader: React.FC = () => {
  const [isDappListOpen, toggleIsDappListOpen] = useToggle(false);
  const [isHelpOpen, toggleIsHelpOpen] = useToggle(false);
  const [isSettingsOpen, toggleIsSettingsOpen] = useToggle(false);
  const [isJurorLevelsMiniGuideOpen, toggleIsJurorLevelsMiniGuideOpen] = useToggle(false);
Severity: Minor
Found in web/src/layout/Header/DesktopHeader.tsx - About 35 mins 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 NotablePersons has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const NotablePersons: React.FC = () => {
  const { disputeData, setDisputeData } = useNewDisputeContext();

  //value here is the total number of fields-
  const updateNumberOfAliases = (value: number) => {
Severity: Minor
Found in web/src/pages/Resolver/Parameters/NotablePersons/index.tsx - About 35 mins 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 createResultObject has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const createResultObject = (
  sourceData: Record<string, any>,
  seek: string[],
  populate: string[]
): Record<string, any> => {
Severity: Minor
Found in kleros-sdk/src/dataMappings/utils/createResultObject.ts - About 35 mins 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

Avoid too many return statements within this function.
Open

    return `after ${targetDate.toLocaleDateString("en-US", options)}`;
Severity: Major
Found in web/src/utils/date.ts - About 30 mins to fix
Severity
Category
Status
Source
Language