kleros/kleros-v2

View on GitHub

Showing 142 of 1,394 total issues

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

    const expectFromDraw = async (drawTx: Promise<ContractTransactionResponse>) => {
      console.log((await core.getRoundInfo(0, 0)).drawIterations);
      expect(await core.getRoundInfo(0, 0).then((round) => round.drawIterations)).to.equal(3);

      const tx = await (await drawTx).wait();
Severity: Minor
Found in contracts/test/arbitration/draw.ts - About 1 hr to fix

Function handleChoiceFunded has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function handleChoiceFunded(event: ChoiceFunded): void {
  const coreDisputeID = event.params._coreDisputeID.toString();
  const coreRoundIndex = event.params._coreRoundID.toString();
  const choice = event.params._choice;
  const roundID = `${DISPUTEKIT_ID}-${coreDisputeID}-${coreRoundIndex}`;
Severity: Minor
Found in subgraph/core/src/DisputeKitClassic.ts - About 1 hr to fix

Function uploadFormDataToIPFS has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function uploadFormDataToIPFS(formData: FormData, operation = "evidence"): Promise<Response> {
  const authToken = sessionStorage.getItem("authToken")?.replace(/"/g, "");

  return toast.promise<Response, Error>(
    fetch(`/.netlify/functions/uploadToIPFS?key=kleros-v2&operation=${operation}`, {
Severity: Minor
Found in web/src/utils/uploadFormDataToIPFS.ts - About 1 hr to fix

Function expectFromDraw has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    const expectFromDraw = async (drawTx: Promise<ContractTransactionResponse>) => {
      console.log((await core.getRoundInfo(0, 0)).drawIterations);
      expect(await core.getRoundInfo(0, 0).then((round) => round.drawIterations)).to.equal(3);

      const tx = await (await drawTx).wait();
Severity: Minor
Found in contracts/test/arbitration/draw.ts - About 1 hr to fix

Function VotingOptions has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

  const handleQuestionWrite = (event: React.ChangeEvent<HTMLInputElement>) => {
    setDisputeData({ ...disputeData, question: event.target.value });
Severity: Minor
Found in web/src/pages/Resolver/Parameters/VotingOptions/index.tsx - About 1 hr to fix

Function main has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function main() {
  const chainId = Number(await hre.getChainId());
  const courtAddress = configByChain.get(chainId)?.courtAddress ?? hre.ethers.ZeroAddress;
  const courtsV1 = (await ethers.getContractAt("IKlerosLiquid", courtAddress)) as IKlerosLiquid;

Severity: Minor
Found in contracts/scripts/getCourtsV1.ts - About 1 hr to fix

Function expectFromDraw has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    const expectFromDraw = async (drawTx: Promise<ContractTransactionResponse>) => {
      console.log((await core.getRoundInfo(0, 0)).drawIterations);
      expect(await core.getRoundInfo(0, 0).then((round) => round.drawIterations)).to.equal(3);

      const tx = await (await drawTx).wait();
Severity: Minor
Found in contracts/test/arbitration/draw.ts - About 1 hr to fix

Function passPeriod has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const passPeriod = async (dispute: { id: string }) => {
  const { core } = await getContracts();
  let success = false;
  try {
    await core.passPeriod.staticCall(dispute.id);
Severity: Minor
Found in contracts/scripts/keeperBot.ts - About 1 hr to fix

Function PersonFields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const PersonFields: React.FC = () => {
  const { disputeData, setDisputeData } = useNewDisputeContext();
  const validationTimerRef = useRef<NodeJS.Timeout | null>(null);
  const publicClient = usePublicClient({ chainId: 1 });

Severity: Minor
Found in web/src/pages/Resolver/Parameters/NotablePersons/PersonFields.tsx - About 55 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 ChangeDeveloper has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const ChangeDeveloper: React.FC = () => {
  const { isConnected, chainId } = useAccount();
  const { arbitrable, currentDeveloper, refetchData } = useRulerContext();
  const [newDeveloper, setNewDeveloper] = useState("");
  const [isChanging, setIsChanging] = useState(false);
Severity: Minor
Found in web-devtools/src/app/(main)/ruler/ChangeDeveloper.tsx - About 55 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 CasesGrid has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const CasesGrid: React.FC<ICasesGrid> = ({ disputes, casesPerPage, totalPages, currentPage, setCurrentPage }) => {
  const { filter } = useParams();
  const decodedFilter = decodeURIFilter(filter ?? "all");
  const { id: searchValue } = decodedFilter;
  const { isList } = useIsList();
Severity: Minor
Found in web/src/components/CasesDisplay/CasesGrid.tsx - About 55 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 beautifyStatNumber has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export function beautifyStatNumber(value: number, invertValue: boolean = false): string {
  const absValue = Math.abs(value);

  if (absValue >= 1e9) {
    return `${commify((value / 1e9).toFixed(2))}B`;
Severity: Minor
Found in web/src/utils/beautifyStatNumber.ts - About 55 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 Onboarding has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const Onboarding: React.FC<IOnboarding> = ({ toggleMiniGuide }) => {
  const [isStakingMiniGuideOpen, toggleStakingMiniGuide] = useToggle(false);
  const [isBinaryVotingMiniGuideOpen, toggleBinaryVotingMiniGuide] = useToggle(false);
  const [isRankedVotingMiniGuideOpen, toggleRankedVotingMiniGuide] = useToggle(false);
  const [isAppealMiniGuideOpen, toggleAppealMiniGuide] = useToggle(false);
Severity: Minor
Found in web/src/components/Popup/MiniGuides/Onboarding/index.tsx - About 55 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 isRngReady has a Cognitive Complexity of 9 (exceeds 5 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 55 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 9 (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 55 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 RewardsAndFundLabel has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const RewardsAndFundLabel: React.FC<IRewardsAndFundLabel> = ({ value, unit = "ETH", isFund = false }) => {
  const theme = useTheme();
  const isWon = Number(value) > 0;
  const color = isWon ? theme.success : theme.error;
  return Number(value) !== 0 ? (
Severity: Minor
Found in web/src/components/DisputeView/CardLabels/RewardsAndFundLabel.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 updateDisputeRequestData has a Cognitive Complexity of 8 (exceeds 5 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 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 ExecuteDelayedStakeButton has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const ExecuteDelayedStakeButton: React.FC<IExecuteStakeDelayedButton> = ({ setIsOpen }) => {
  const [isSending, setIsSending] = useState(false);
  const publicClient = usePublicClient();
  const { data: phase } = useSortitionModulePhase();
  const { data: delayedStakeWriteIndex } = useReadSortitionModuleDelayedStakeWriteIndex();

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.choice === null) continue;
Severity: Major
Found in subgraph/core/src/KlerosCore.ts - About 45 mins to fix

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

const Dashboard: React.FC = () => {
  const { isConnected, address } = useAccount();
  const { page, order, filter } = useParams();
  const location = useRootPath();
  const navigate = useNavigate();
Severity: Minor
Found in web/src/pages/Dashboard/index.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

Severity
Category
Status
Source
Language