kleros/kleros-v2

View on GitHub

Showing 142 of 1,394 total issues

Function SelectArbitrable has 63 lines of code (exceeds 25 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: Major
Found in web-devtools/src/app/(main)/ruler/SelectArbitrable.tsx - About 2 hrs to fix

Function Evidence has 60 lines of code (exceeds 25 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: Major
Found in web/src/pages/Cases/CaseDetails/Evidence/index.tsx - About 2 hrs to fix

Function deployHomeGateway has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
  const { ethers, deployments, getNamedAccounts } = hre;
  const { deploy, execute } = deployments;
  const { zeroPadValue, toBeHex } = ethers;

Severity: Major
Found in contracts/deploy/03-vea-mock.ts - About 2 hrs to fix

Function Chart has 57 lines of code (exceeds 25 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: Major
Found in web/src/pages/Home/CourtOverview/Chart.tsx - About 2 hrs to fix

Function VoteStatus has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

}> = ({ choice, period, answers, isActiveRound, commited, hiddenVotes }) => {
  if (hiddenVotes) {
    if (!commited && (isActiveRound ? ["vote", "appeal", "execution"].includes(period) : true))
      return <StyledLabel>Did not commit vote </StyledLabel>;

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

const NextButton: React.FC<INextButton> = ({ nextRoute }) => {
  const navigate = useNavigate();
  const { disputeData, isPolicyUploading } = useNewDisputeContext();
  const location = useLocation();

Severity: Minor
Found in web/src/pages/Resolver/NavigationButtons/NextButton.tsx - About 2 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 calculateStats has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

const calculateStats = (
  isCourtFilter: boolean,
  courtData: CourtDetailsQuery["court"],
  counters: CounterQuery["counter"],
  filter?: Dispute_Filter
Severity: Minor
Found in web/src/pages/Cases/CasesFetcher.tsx - About 2 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 ChangeDeveloper has 52 lines of code (exceeds 25 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: Major
Found in web-devtools/src/app/(main)/ruler/ChangeDeveloper.tsx - About 2 hrs to fix

Function PersonFields has 50 lines of code (exceeds 25 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 2 hrs to fix

Function Search has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Search: React.FC = () => {
  const { page, order, filter } = useParams();
  const location = useRootPath();
  const decodedFilter = decodeURIFilter(filter ?? "all");
  const { id: searchValue, ...filterObject } = decodedFilter;
Severity: Minor
Found in web/src/components/CasesDisplay/Search.tsx - About 1 hr to fix

Function EmailConfirmation has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const EmailConfirmation: React.FC = () => {
  const { confirmEmail } = useAtlasProvider();

  const [isConfirming, setIsConfirming] = useState(false);
  const [isConfirmed, setIsConfirmed] = useState(false);
Severity: Minor
Found in web/src/pages/Settings/EmailConfirmation/index.tsx - About 1 hr to fix

Function updateCountsAndGetCurrentRuling has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export function updateCountsAndGetCurrentRuling(id: string, choice: BigInt, delta: BigInt): CurrentRulingInfo {
  const round = ClassicRound.load(id);
  if (!round) return { ruling: ZERO, tied: false };
  const choiceNum = choice.toI32();
  const newChoiceCount = round.counts[choiceNum].plus(delta);
Severity: Minor
Found in subgraph/core/src/entities/ClassicRound.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 Chart has a Cognitive Complexity of 15 (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 DrawButton has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

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

Function withdrawAppealContribution has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const withdrawAppealContribution = async (
  disputeId: string,
  roundId: string,
  contribution: Contribution
): Promise<boolean> => {
Severity: Minor
Found in contracts/scripts/keeperBot.ts - About 1 hr to fix

Function handleEvidenceEvent has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function handleEvidenceEvent(event: EvidenceEvent): void {
  const evidenceGroupID = event.params._externalDisputeID.toString();
  const evidenceGroup = ensureClassicEvidenceGroup(evidenceGroupID);
  const evidenceIndex = evidenceGroup.nextEvidenceIndex;
  evidenceGroup.nextEvidenceIndex = evidenceGroup.nextEvidenceIndex.plus(ONE);
Severity: Minor
Found in subgraph/core/src/EvidenceModule.ts - About 1 hr to fix

Function DisputeResolver has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const DisputeResolver: React.FC = () => {
  const location = useLocation();
  const [isDisputeResolverMiniGuideOpen, toggleDisputeResolverMiniGuide] = useToggle(false);
  const { isConnected } = useAccount();
  const isPreviewPage = location.pathname.includes("/preview");
Severity: Minor
Found in web/src/pages/Resolver/index.tsx - About 1 hr to fix

Function timeLeftUntil has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export function timeLeftUntil(isoString: string): string {
  const targetDate = new Date(isoString);
  const now = new Date();
  const timeDifference = targetDate.getTime() - now.getTime();

Severity: Minor
Found in web/src/utils/date.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 main has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default async function main() {
  logger.info("Starting up");

  const core = (await ethers.getContract("KlerosCore")) as KlerosCore;
  const resolver = (await ethers.getContract("DisputeResolver")) as DisputeResolver;
Severity: Minor
Found in contracts/scripts/disputeCreatorBot.ts - About 1 hr to fix
Severity
Category
Status
Source
Language