kleros/kleros-v2

View on GitHub

Showing 113 of 1,343 total issues

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

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

  // fallback to hardhat node signers on local network
Severity: Major
Found in contracts/deploy/00-home-chain-arbitration-ruler.ts - About 2 hrs to fix

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

export function handleNewPeriod(event: NewPeriod): void {
  const disputeID = event.params._disputeID;
  const dispute = Dispute.load(disputeID.toString());
  if (!dispute) return;
  const court = Court.load(dispute.court);
Severity: Minor
Found in subgraph/core/src/KlerosCore.ts - 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 JurorBalanceDisplay has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const JurorBalanceDisplay = () => {
  const { id } = useParams();
  const { address } = useAccount();
  const { data: jurorBalance } = useReadSortitionModuleGetJurorBalance({
    query: {
Severity: Minor
Found in web/src/pages/Courts/CourtDetails/StakePanel/JurorStakeDisplay.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 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 handleEvidenceEvent has 45 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 withdrawAppealContribution has 42 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 Chart has 41 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: Minor
Found in web/src/pages/Home/CourtOverview/Chart.tsx - About 1 hr to fix

Function CourtDetails has 40 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 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

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

export function handleNewPeriod(event: NewPeriod): void {
  const disputeID = event.params._disputeID;
  const dispute = Dispute.load(disputeID.toString());
  if (!dispute) return;
  const court = Court.load(dispute.court);
Severity: Minor
Found in subgraph/core/src/KlerosCore.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 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 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
Severity
Category
Status
Source
Language