Showing 43 of 130 total issues
Function round
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected round(
candidates: string[],
idx: number,
): {
eliminated: string[]
Function useStore
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
subscribeWithSelector((set): Store => {
const updateCandidateCount = (desiredLength: number) =>
set(({ ballots, candidates, drawRate }) => {
const newCandidates = updateCandidateList(desiredLength, candidates)
return {
- 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 Render
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Render(props: Omit<T, 'width'>): React.ReactElement {
const ref = useRef<HTMLDivElement>(null)
const [componentSize, setComponentSize] = useState<number | null>(null)
const seet = useCallback(() => {
if (ref.current) {
Function render
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
render(): React.ReactElement {
return (
<Html>
<Head>
<link
Function boxes
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
const boxes: (BoxMeta & BoxPosition & WithColor)[] = useMemo(() => {
if (!scale) return []
if (step === Step.TREEMAP) {
return boxTreemap({
boxes: bboxes,
Function useWidth
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function useWidth(ref: RefObject<HTMLDivElement>) {
const [ComponentSize, setComponentSize] = useState(getSize(ref.current))
const seet = useCallback(() => {
if (ref.current) {
setComponentSize(getSize(ref.current))
Function VizFptp
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const VizFptp: React.FC = () => {
const ballots = useStore(selectBallots)
const candidatesById = useCandidatesById()
const candidatesStrings = useCandidatesString()
const width = useStore(selectWidth)
Function matrixFromBallots
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export const matrixFromBallots = (
ballots: Ballot[],
candidates: string[],
): Matrix => {
const array: number[][] = times(candidates.length, () =>
- 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 round
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const round = (
candidates: string[],
_ballots: Ballot[],
): {
qualified: string[]
Function setPos
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const setPos = (
oldRanking: string[][],
elementToMoveId: string,
newPos: number,
): string[][] => {
- 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
Avoid deeply nested control flow statements. Open
if (i !== k && j !== k)
p[j][k] = Math.max(p[j][k], Math.min(p[j][i], p[i][k]))
Function getMedian
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export const getMedian = (arr: number[]): number => {
const sumWeights = _.sum(arr)
let s = 0
let i = 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 WithWidth
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export const WithWidth = <T extends { width: number }>(
Comp: React.ComponentType<T>,
) =>
function Render(props: Omit<T, 'width'>): React.ReactElement {
const ref = useRef<HTMLDivElement>(null)
- 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 a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const computeFromMatrix = (matrix: Matrix): ScoreObject => {
const allEdges: Edge[] = matrix.array.flatMap(
(row, from) =>
row
.map((value, to) =>
- 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 randomRankingFromSores
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const randomRankingFromSores = (
scoreObject: ScoreObject,
random: () => number,
): string[] => {
const candidates = Object.keys(scoreObject)
- 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 isZero
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const isZero = (matrix: number[][]): boolean => {
for (let i = 0; i < matrix.length; i++)
for (let j = 0; j < matrix.length; j++) if (matrix[i][j] !== 0) return false
return true
}
- 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 findNashEquilibrium
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export const findNashEquilibrium = (matrix: SkewSymmetricMatrix): number[] => {
if (isZero(matrix)) return matrix.map(() => 1 / matrix.length)
const constraints: Record<string, Record<string, number>> = {
sum: { equal: 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 computeScores
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const computeScores = (
candidates: string[],
_ballots: Ballot[],
): ScoreObject => {
const scores = scoresZero(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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const computeFromMatrix = (matrix: Matrix) => {
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 updateBuckets
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export const updateBuckets = (
buckets: { id: string; elements: number[] }[],
item: number,
newRank: number,
) => {
- 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"