Showing 43 of 130 total issues

File emojis.ts has 1793 lines of code (exceeds 250 allowed). Consider refactoring.
Open

export const emojis = [
  '😀',
  '😁',
  '😂',
  '🤣',
Severity: Major
Found in demo/src/emojis.ts - About 4 days to fix

    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'
    
    
    Severity: Major
    Found in demo/src/methods/descriptions.tsx - About 1 day to fix

      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'
      Severity: Minor
      Found in demo/src/methods/borda/viz-borda.tsx - About 7 hrs to fix

        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,
        Severity: Minor
        Found in demo/src/force-link.ts - About 6 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 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)
        Severity: Major
        Found in demo/src/list-votes-group.tsx - About 5 hrs to fix

          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)
          Severity: Major
          Found in demo/src/matrix.tsx - About 4 hrs to fix

            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 {
            Severity: Major
            Found in demo/src/store/index.ts - About 4 hrs to fix

              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,
              Severity: Major
              Found in demo/src/force-link.ts - About 3 hrs to fix

                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++)
                Severity: Minor
                Found in votes/src/methods/schulze/index.ts - About 3 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 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)
                
                
                Severity: Minor
                Found in demo/src/methods/borda/viz-borda.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 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
                Severity: Minor
                Found in demo/src/axis.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 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
                Severity: Minor
                Found in votes/src/methods/ranked-pairs/tarjan.ts - 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 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)
                Severity: Major
                Found in demo/src/methods/ranked-pairs/viz-ranked-pairs.tsx - About 2 hrs to fix

                  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'
                  Severity: Minor
                  Found in demo/src/react-ranker/ranker.tsx - About 2 hrs to fix

                    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>
                    Severity: Major
                    Found in demo/src/sandbox.tsx - About 2 hrs to fix

                      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)
                      Severity: Minor
                      Found in demo/src/ballots.tsx - About 1 hr to fix

                        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]),
                          )
                        Severity: Minor
                        Found in votes/src/methods/majority-judgment/index.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 Ranker has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                        Open

                        const Ranker: React.FC<Props> = ({
                          onVoteDrop,
                          prefs,
                          showHovers,
                          candidates,
                        Severity: Minor
                        Found in demo/src/react-ranker/ranker.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 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) =>
                        Severity: Minor
                        Found in votes/src/methods/ranked-pairs/index.ts - About 1 hr to fix

                          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 (
                          Severity: Minor
                          Found in demo/src/select-premade.tsx - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language