kleros/kleros-v2

View on GitHub

Showing 142 of 1,394 total issues

Function deployArbitration has 40 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-arbitration-ruler.ts - About 1 hr to fix

Function SelectArbitrable has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

const SelectArbitrable: React.FC = () => {
  const { arbitrable, setArbitrable, knownArbitrables } = useRulerContext();
  const publicClient = usePublicClient({ chainId: 1 }) as PublicClient;
  const ref = useRef<HTMLDivElement>(null);
  const [isClient, setIsClient] = useState(false);
Severity: Minor
Found in web-devtools/src/app/(main)/ruler/SelectArbitrable.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 useTimeline has a Cognitive Complexity of 13 (exceeds 5 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

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 commify has a Cognitive Complexity of 13 (exceeds 5 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

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 CourtDetails has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const CourtDetails: React.FC = () => {
  const { id } = useParams();
  const { data: policy } = useCourtPolicy(id);
  const { data } = useCourtTree();
  const [isStakingMiniGuideOpen, toggleStakingMiniGuide] = useToggle(false);
Severity: Minor
Found in web/src/pages/Courts/CourtDetails/index.tsx - About 1 hr to fix

Function Description has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Description: React.FC = () => {
  const { id } = useParams();
  const { data: policy } = useCourtPolicy(id);
  const navigate = useNavigate();
  const currentPathName = useLocation().pathname.split("/").at(-1);
Severity: Minor
Found in web/src/pages/Courts/CourtDetails/Description.tsx - About 1 hr to fix

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 processData has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const processData = (data: HomePageBlockQuery, allTime: boolean) => {
  const presentCourts = data.presentCourts;
  const pastCourts = data.pastCourts;
  const processedCourts: CourtWithTree[] = Array(presentCourts.length);
  const processed = new Set();
Severity: Minor
Found in web/src/hooks/queries/useHomePageBlockQuery.ts - 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 Evidence has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const Evidence: React.FC = () => {
  const { id } = useParams();
  const { data: disputeData } = useDisputeDetailsQuery(id);
  const ref = useRef<HTMLDivElement>(null);
  const [search, setSearch] = useState<string>();
Severity: Minor
Found in web/src/pages/Cases/CaseDetails/Evidence/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 FormContactDetails has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const FormContactDetails: React.FC<ISettings> = ({ toggleIsSettingsOpen }) => {
  const [emailInput, setEmailInput] = useState<string>("");
  const [emailIsValid, setEmailIsValid] = useState<boolean>(false);
  const { address } = useAccount();
  const { user, isAddingUser, isFetchingUser, addUser, updateEmail, isUpdatingUser, userExists } = useAtlasProvider();

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 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 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 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 getDispute has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const getDispute = async (disputeParameters: GetDisputeParameters): Promise<DisputeDetails | undefined> => {
  if (disputeParameters.options?.sdkConfig) {
    configureSDK(disputeParameters.options.sdkConfig);
  }
  const { disputeId, dtrSubgraph, coreSubgraph, options } = disputeParameters;
Severity: Minor
Found in kleros-sdk/src/utils/getDispute.ts - About 1 hr to fix

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

export function updateEffectiveStake(courtID: string): void {
  let court = Court.load(courtID);
  if (!court) return;

  while (court) {
Severity: Minor
Found in subgraph/core/src/entities/Court.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

Severity
Category
Status
Source
Language