kleros/kleros-v2

View on GitHub
web/src/components/DisputeView/CardLabels/index.tsx

Summary

Maintainability
C
7 hrs
Test Coverage

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

const getFundingRewards = (contributions: ClassicContribution[], closed: boolean) => {
  if (isUndefined(contributions) || contributions.length === 0) return 0;
  const contribution = contributions.reduce((acc, val) => {
    if (isUndefined(val?.rewardAmount) && isUndefined(val?.amount)) return acc;
    if (closed) {
Severity: Minor
Found in web/src/components/DisputeView/CardLabels/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

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

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 (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

    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

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

There are no issues that match your filters.

Category
Status