kleros/kleros-v2

View on GitHub

Showing 142 of 1,394 total issues

Avoid too many return statements within this function.
Open

    return false;
Severity: Major
Found in contracts/scripts/keeperBot.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

    if (period === "execution" && isDrawnInDispute && !hasVotedInDispute) return LabelArgs.DidNotVote;
Severity: Major
Found in web/src/components/DisputeView/CardLabels/index.tsx - About 30 mins to fix

Avoid too many return statements within this function.
Open

    if (!isDrawnCurrentRound) return LabelArgs.NotDrawn;
Severity: Major
Found in web/src/components/DisputeView/CardLabels/index.tsx - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return [secondsToDayHourMinute(dispute?.court.timesPerPeriod[index])];
Severity: Major
Found in web/src/pages/Cases/CaseDetails/Timeline.tsx - About 30 mins to fix

Avoid too many return statements within this function.
Open

      return value.toFixed(2);
Severity: Major
Found in web/src/utils/beautifyStatNumber.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

    if (["commit", "vote"].includes(period ?? "") && !hasVotedCurrentRound) return LabelArgs.CanVote;
Severity: Major
Found in web/src/components/DisputeView/CardLabels/index.tsx - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return `in ${daysLeft} day${daysLeft > 1 ? "s" : ""}`;
Severity: Major
Found in web/src/utils/date.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

    if (hasVotedCurrentRound) return LabelArgs.Voted; // plus rewards if execution
Severity: Major
Found in web/src/components/DisputeView/CardLabels/index.tsx - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return;
Severity: Major
Found in subgraph/core/src/entities/Dispute.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

    if (!decoded) return;
Severity: Major
Found in subgraph/core/src/entities/Dispute.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

  return commify(value.toFixed(0));
Severity: Major
Found in web/src/utils/beautifyStatNumber.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return LabelArgs.DidNotVote; // plus rewards if execution
Severity: Major
Found in web/src/components/DisputeView/CardLabels/index.tsx - About 30 mins to fix

Function SubmitEvidenceModal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

}> = ({ isOpen, evidenceGroup, close }) => {
  const { data: walletClient } = useWalletClient();
  const publicClient = usePublicClient();
  const wagmiConfig = useConfig();
  const [isSending, setIsSending] = useState(false);
Severity: Minor
Found in web/src/pages/Cases/CaseDetails/Evidence/SubmitEvidenceModal.tsx - About 25 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 getNewValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function getNewValue(currentVar: string, targetVar: string, delta: BigInt, counter: Entity | null): Value {
  if (currentVar === targetVar) {
    return !counter ? Value.fromBigInt(delta) : Value.fromBigInt(counter.get(currentVar)!.toBigInt().plus(delta));
  } else {
    return !counter ? Value.fromBigInt(ZERO) : counter.get(currentVar)!;
Severity: Minor
Found in subgraph/core/src/datapoint.ts - About 25 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 ensureClassicContributionFromEvent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function ensureClassicContributionFromEvent<T>(event: T): ClassicContribution | null {
  if (!(event instanceof ContributionEvent) && !(event instanceof Withdrawal)) return null;
  const coreDisputeID = event.params._coreDisputeID.toString();
  const coreRoundIndex = event.params._coreRoundID.toString();
  const roundID = `${DISPUTEKIT_ID}-${coreDisputeID}-${coreRoundIndex}`;
Severity: Minor
Found in subgraph/core/src/entities/ClassicContribution.ts - About 25 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 VotesAccordion has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const VotesAccordion: React.FC<IVotesAccordion> = ({ drawnJurors, period, answers, isActiveRound, hiddenVotes }) => {
  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 25 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 deployArbitration has a Cognitive Complexity of 6 (exceeds 5 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: Minor
Found in contracts/deploy/00-home-chain-arbitration-neo.ts - About 25 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 CasesFetcher has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const CasesFetcher: React.FC = () => {
  const { page, order, filter } = useParams();
  const location = useRootPath();
  const navigate = useNavigate();
  const isDesktop = useIsDesktop();
Severity: Minor
Found in web/src/pages/Cases/CasesFetcher.tsx - About 25 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 getActivityDelta has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function getActivityDelta(previousStake: BigInt, newStake: BigInt): BigInt {
  if (previousStake.gt(ZERO)) {
    return newStake.gt(ZERO) ? ZERO : BigInt.fromI32(-1);
  } else {
    return newStake.gt(ZERO) ? ONE : ZERO;
Severity: Minor
Found in subgraph/core/src/entities/JurorTokensPerCourt.ts - About 25 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 Popup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const Popup: React.FC<PopupProps & IPopup> = ({
  title,
  icon: Icon,
  popupType,
  setIsOpen,
Severity: Minor
Found in web/src/components/Popup/index.tsx - About 25 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

Severity
Category
Status
Source
Language