kleros/kleros-v2

View on GitHub

Showing 113 of 1,343 total issues

Function OptionsFields has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

  const updateOptions = (value: number) => {
    const defaultAnswer: Answer = { title: "", id: value.toString(), description: "" };
Severity: Minor
Found in web/src/pages/Resolver/Parameters/VotingOptions/OptionsFields.tsx - About 1 hr to fix

Function commify has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function commify(value: string | number): string {
  const comps = String(value).split(".");

  if (!String(value).match(/^-?[0-9]*\.?[0-9]*$/)) {
    return "0";
Severity: Minor
Found in web/src/utils/commify.ts - About 1 hr to fix

Function CasesFetcher has 36 lines of code (exceeds 25 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 1 hr to fix

Function deployForeignGateway has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
  const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
  const { deploy, execute } = deployments;

  // fallback to hardhat node signers on local network
Severity: Minor
Found in contracts/deploy/04-foreign-arbitrable.ts - About 1 hr to fix

Function useTimeline has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const useTimeline = (dispute: DisputeDetailsQuery["dispute"], currentItemIndex: number, currentPeriodIndex: number) => {
  const isDesktop = useIsDesktop();
  const titles = useMemo(() => {
    const titles = ["Evidence", "Voting", "Appeal", "Executed"];
    if (dispute?.court.hiddenVotes) {
Severity: Minor
Found in web/src/pages/Cases/CaseDetails/Timeline.tsx - About 1 hr to fix

Function updateTokenAndEthShiftFromEvent has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function updateTokenAndEthShiftFromEvent(event: TokenAndETHShiftEvent): void {
  const jurorAddress = event.params._account;
  const disputeID = event.params._disputeID;
  const dispute = Dispute.load(disputeID.toString());
  if (!dispute) return;
Severity: Minor
Found in subgraph/core/src/entities/TokenAndEthShift.ts - About 1 hr to fix

Function handleVoteCast has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function handleVoteCast(event: VoteCast): void {
  const juror = event.params._juror.toHexString();
  const coreDisputeID = event.params._coreDisputeID.toString();
  const coreDispute = Dispute.load(coreDisputeID);
  const classicDisputeID = `${DISPUTEKIT_ID}-${coreDisputeID}`;
Severity: Minor
Found in subgraph/core/src/DisputeKitClassic.ts - About 1 hr to fix

Function Chart has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const Chart: React.FC = () => {
  const [chartOption, setChartOption] = useState("stakedPNK");
  const { data } = useHomePageContext();
  const chartData = data?.counters;
  const courtsChartData = data?.courts;
Severity: Minor
Found in web/src/pages/Home/CourtOverview/Chart.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

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

Function constructDisputeTemplate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const constructDisputeTemplate = (disputeData: IDisputeData) => {
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  const { courtId, numberOfJurors, arbitrationCost, ...baseTemplate } = disputeData;

  if (!isUndefined(baseTemplate.aliasesArray)) {
Severity: Minor
Found in web/src/context/NewDisputeContext.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

Function resolveUserDispute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export function resolveUserDispute(id: string, previousFeeAmount: BigInt, feeAmount: BigInt, disputeID: string): void {
  const user = ensureUser(id);
  if (user.resolvedDisputes.includes(disputeID)) {
    if (previousFeeAmount.gt(ZERO)) {
      if (feeAmount.le(ZERO)) {
Severity: Minor
Found in subgraph/core/src/entities/User.ts - 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

Function deployArbitration has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
  const { deployments, getNamedAccounts, getChainId } = hre;
  const { deploy } = deployments;

  // fallback to hardhat node signers on local network
Severity: Minor
Found in contracts/deploy/00-home-chain-arbitrable.ts - About 1 hr to fix

Function Policy has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

  const handleFileUpload = (file: File) => {
    setIsPolicyUploading(true);
Severity: Minor
Found in web/src/pages/Resolver/Policy/index.tsx - About 1 hr to fix

Function General has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const General: React.FC = () => {
  const { address, chain } = useAccount();

  const addressExplorerLink = useMemo(() => {
    return `${chain?.blockExplorers?.default.url}/address/${address}`;
Severity: Minor
Found in web/src/layout/Header/navbar/Menu/Settings/General.tsx - About 1 hr to fix

Function deployResolver has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const deployResolver: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
  const { ethers } = hre;

  const template = `{
    "$schema": "../NewDisputeTemplate.schema.json",
Severity: Minor
Found in contracts/deploy/05-arbitrable-dispute-template.ts - About 1 hr to fix

Function Explore has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Explore: React.FC = () => {
  const location = useLocation();
  const { isOpen, toggleIsOpen } = useOpenContext();

  return (
Severity: Minor
Found in web/src/layout/Header/navbar/Explore.tsx - About 1 hr to fix

Function Court has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Court: React.FC = () => {
  const { disputeData, setDisputeData } = useNewDisputeContext();
  const { data } = useCourtTree();
  const items = useMemo(() => !isUndefined(data) && [rootCourtToItems(data.court)], [data]);

Severity: Minor
Found in web/src/pages/Resolver/Parameters/Court.tsx - About 1 hr to fix

Function deployForeignGateway has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
  const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
  const { deploy, execute } = deployments;
  const { hexZeroPad, hexlify } = ethers.utils;

Severity: Minor
Found in contracts/deploy/01-foreign-gateway-on-gnosis.ts - About 1 hr to fix

Function authMiddleware has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const authMiddleware = () => {
  return {
    before: async (request) => {
      const { event } = request;

Severity: Minor
Found in web/netlify/middleware/authMiddleware.ts - About 1 hr to fix

Function deployForeignGateway has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
  const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
  const { deploy, execute } = deployments;
  const { hexZeroPad, hexlify } = ethers.utils;

Severity: Minor
Found in contracts/deploy/01-foreign-gateway-on-ethereum.ts - About 1 hr to fix
Severity
Category
Status
Source
Language