kleros/kleros-v2

View on GitHub

Showing 113 of 1,343 total issues

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

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

export const replacePlaceholdersWithValues = (mapping: any, context: Record<string, unknown>) => {
  const replace = (obj) => {
    if (typeof obj === "string") {
      return mustache.render(obj, context);
    } else if (Array.isArray(obj)) {
Severity: Minor
Found in kleros-sdk/src/dataMappings/utils/replacePlaceholdersWithValues.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 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 { AddressZero } = hre.ethers.constants;
  const RNG_LOOKAHEAD = 20;

Severity: Minor
Found in contracts/deploy/00-home-chain-arbitration.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 fetchIpfsJsonAction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const fetchIpfsJsonAction = async (mapping: FetchIpfsJsonMapping) => {
  const { ipfsUri, seek, populate } = mapping;

  let httpUri;
  if (ipfsUri.startsWith("/ipfs/")) {
Severity: Minor
Found in kleros-sdk/src/dataMappings/actions/fetchIpfsJsonAction.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 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 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 { AddressZero } = hre.ethers.constants;
  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 DrawButton has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const DrawButton: React.FC<IDrawButton> = ({ id, numberOfVotes, setIsOpen, period }) => {
  const [isSending, setIsSending] = useState(false);
  const publicClient = usePublicClient();
  const { data: maintenanceData } = useDisputeMaintenanceQuery(id);
  const { data: phase } = useSortitionModulePhase();
Severity: Minor
Found in web/src/pages/Cases/CaseDetails/MaintenanceButtons/DrawButton.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

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

Severity
Category
Status
Source
Language