Showing 43 of 130 total issues
File emojis.ts
has 1793 lines of code (exceeds 250 allowed). Consider refactoring. Open
export const emojis = [
'😀',
'😁',
'😂',
'🤣',
File descriptions.tsx
has 504 lines of code (exceeds 250 allowed). Consider refactoring. Open
import React from 'react'
import { GithubOutlined } from '@ant-design/icons'
import { VotingSystem } from 'votes'
File viz-borda.tsx
has 461 lines of code (exceeds 250 allowed). Consider refactoring. Open
import React, { useLayoutEffect, useMemo, useRef, useState } from 'react'
import { ArrowLeftOutlined, ArrowRightOutlined } from '@ant-design/icons'
import { a, to, useSpring } from '@react-spring/web'
import { useHover } from '@use-gesture/react'
import { Button } from 'antd'
Function forceLink
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
export function forceLink<
NodeDatum extends SimulationNodeDatum,
LinkDatum extends SimulationLinkDatum<NodeDatum> & { weight: number },
>(links: LinkDatum[] | null): Force {
let id = index,
- Read upRead up
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 ListVotesGroup
has 142 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const ListVotesGroup: React.FC = () => {
const ballots = useStore(selectBallots)
const changeBallotWeight = useStore(selectChangeBallotWeight)
const selectBallot = useStore(selectSelectBallot)
const selectedBallot = useStore(selectSelectedBallot)
Function MatrixComp
has 111 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const MatrixComp: React.FC = () => {
const [skew, setSkew] = useState(false)
const _matrix = useStore(selectMatrix, shallow)
const matrix = skew ? utils.makeAntisymetric(_matrix) : _matrix
const setHighlighted = useStore(selectSetHighlightCandidates, shallow)
Function useStore
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
subscribeWithSelector((set): Store => {
const updateCandidateCount = (desiredLength: number) =>
set(({ ballots, candidates, drawRate }) => {
const newCandidates = updateCandidateList(desiredLength, candidates)
return {
Function forceLink
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function forceLink<
NodeDatum extends SimulationNodeDatum,
LinkDatum extends SimulationLinkDatum<NodeDatum> & { weight: number },
>(links: LinkDatum[] | null): Force {
let id = index,
Function computeFromMatrix
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
const computeFromMatrix = (matrix: Matrix): ScoreObject => {
const n = matrix.candidates.length
const p: number[][] = range(n).map(() => range(n).map(() => 0))
for (let i = 0; i < n; i++)
- Read upRead up
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 BordaTreeMapInner
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
}> = ({ ballots, candidates }) => {
const [step, setStep] = useState(Step.INIT)
const candidatesString = candidates.map((c) => c.id)
- Read upRead up
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 tickIncrement
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function tickIncrement(start: number, stop: number, count: number): number {
const step = (stop - start) / Math.max(0, count),
power = Math.floor(Math.log10(step)),
error = step / Math.pow(10, power)
return power >= 0
- Read upRead up
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 strongconnect
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
private strongconnect(vertex: Vertex): void {
// Set the depth index for v to the smallest unused index
vertex.index = this.index
vertex.lowlink = this.index
this.index = this.index + 1
- Read upRead up
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 VizRankedPairs
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const VizRankedPairs: React.FC = () => {
const matrix = useStore(selectSkewMatrix)
const candidatesById = useCandidatesById()
const candidatesStrings = useCandidatesString()
// const width = useStore(selectWidth)
File ranker.tsx
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
import type { HTMLAttributes } from 'react'
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { CaretDownOutlined, CaretUpOutlined } from '@ant-design/icons'
import { animated, to, useSprings } from '@react-spring/web'
import { useDrag } from '@use-gesture/react'
Function Sandbox
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const Sandbox: React.FC = () => {
return (
<div className="container">
<Typography.Title>A sandbox for ranked voting systems</Typography.Title>
<p>
Function BallotsComp
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const BallotsComp = () => {
const groupedBallots = useStore(selectBallots)
const totalW = totalWeight(groupedBallots)
const addRandomBallot = useStore(selectAddRandomBallot)
Function makeJudgement
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
const makeJudgement = (candidates: string[], ballots: Ballot[]): Judgements => {
const judgements: Judgements = _.zipObject(
candidates,
candidates.map(() => [0, 0, 0, 0, 0, 0]),
)
- Read upRead up
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 Ranker
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
const Ranker: React.FC<Props> = ({
onVoteDrop,
prefs,
showHovers,
candidates,
- Read upRead up
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 computeFromMatrix
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
const computeFromMatrix = (matrix: Matrix): ScoreObject => {
const allEdges: Edge[] = matrix.array.flatMap(
(row, from) =>
row
.map((value, to) =>
Function SelectPremade
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const SelectPremade: React.FC = () => {
const setPremade = useStore(selectSetPremade)
const [selected, setSelected] = useState<string | null>(null)
return (