Showing 113 of 1,343 total issues
Function getFormattedRewards
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export const getFormattedRewards = (data: any, pricesData: any) => {
return rewards.map(({ token, coinId, getValue, getAmount }) => {
const coinPrice = !isUndefined(pricesData) ? pricesData[CoinIds[token]]?.price : undefined;
const totalReward = data && calculateTotalJurorReward(coinId, data);
- Read upRead up
- Create a ticketCreate a ticket
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 getCourtsPath
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export const getCourtsPath = (
node: CourtTreeQuery["court"],
id: string | undefined,
path: IItem[] = []
): IItem[] | null => {
- Read upRead up
- Create a ticketCreate a ticket
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 updateCountsAndGetCurrentRuling
has 27 lines of code (exceeds 25 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);
- Create a ticketCreate a ticket
Function isRngReady
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const isRngReady = async () => {
const { randomizerRng, blockHashRNG, sortition } = await getContracts();
const currentRng = await sortition.rng();
if (currentRng === randomizerRng.address) {
const requesterID = await randomizerRng.requesterToID(sortition.address);
- Create a ticketCreate a ticket
Function executeDelayedStakes
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const executeDelayedStakes = async () => {
const { sortition } = await getContracts();
// delayedStakes = 1 + delayedStakeWriteIndex - delayedStakeReadIndex
const delayedStakesRemaining = BigNumber.from(1)
- Create a ticketCreate a ticket
Function accordionItems
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const accordionItems = useMemo(() => {
return drawnJurors
.map((drawnJuror) =>
!isUndefined(drawnJuror.vote?.justification?.choice)
? {
- Create a ticketCreate a ticket
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("auth-token")?.replace(/"/g, "");
return toast.promise<Response, Error>(
fetch(`/.netlify/functions/uploadToIPFS?key=kleros-v2&operation=${operation}`, {
- Create a ticketCreate a ticket
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.callStatic.passPeriod(dispute.id);
- Create a ticketCreate a ticket
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.constants.AddressZero;
const courtsV1 = (await ethers.getContractAt("IKlerosLiquid", courtAddress)) as IKlerosLiquid;
- Create a ticketCreate a ticket
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}`;
- Create a ticketCreate a ticket
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 });
- Create a ticketCreate a ticket
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.address) {
const requesterID = await randomizerRng.requesterToID(sortition.address);
- Read upRead up
- Create a ticketCreate a ticket
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 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 });
- Read upRead up
- Create a ticketCreate a ticket
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();
- Read upRead up
- Create a ticketCreate a ticket
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 9 (exceeds 5 allowed). Consider refactoring. Open
const FormContactDetails: React.FC<ISettings> = ({ toggleIsSettingsOpen }) => {
const [telegramInput, setTelegramInput] = useState<string>("");
const [emailInput, setEmailInput] = useState<string>("");
const [telegramIsValid, setTelegramIsValid] = useState<boolean>(false);
const [emailIsValid, setEmailIsValid] = useState<boolean>(false);
- Read upRead up
- Create a ticketCreate a ticket
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);
- Read upRead up
- Create a ticketCreate a ticket
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 (!(await drawJurors(dispute, drawIterations))) {
logger.info(`Failed to draw jurors for dispute #${dispute.id}, skipping it`);
break;
}
- Create a ticketCreate a ticket
Function StageTwo
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const StageTwo: React.FC<IStageTwo> = ({ setAmount }) => {
const { paidFees, winningChoice, winnerRequiredFunding, fundedChoices } = useFundingContext();
const { winnerSideCountdown } = useCountdownContext();
const options = useOptionsContext();
const { selectedOption, setSelectedOption } = useSelectedOptionContext();
- Read upRead up
- Create a ticketCreate a ticket
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 ? (
- Read upRead up
- Create a ticketCreate a ticket
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 PassPeriodButton
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const PassPeriodButton: React.FC<IPassPeriodButton> = ({ id, setIsOpen, period }) => {
const [isSending, setIsSending] = useState(false);
const publicClient = usePublicClient();
const { data: maintenanceData } = useDisputeMaintenanceQuery(id);
- Read upRead up
- Create a ticketCreate a ticket
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"