Floppy/dataslate

View on GitHub

Showing 242 of 242 total issues

Function App has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export function App (): JSX.Element {
  const [roster, setRoster] = useState<Roster2018 | Roster2021 | RosterWH40k9e | null>(null)

  const [settings, setSettings] = useState(DEFAULT_SETTINGS)

Severity: Minor
Found in src/App.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  return (props.category !== '' && props.category.toLowerCase() !== 'specialist' && props.category.toLowerCase() !== 'specialist retainer'
    ? <img className='category' style={{ height: '1em', marginRight: '10px' }} alt={props.category} src={`/icons/${props.category.toLowerCase()}.svg`} />
    : <></>
Severity: Major
Found in src/components/KillTeam2018/CategoryIcon.tsx and 1 other location - About 1 hr to fix
src/components/KillTeam2018/SpecialistIcon.tsx on lines 8..10

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 69.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

              {!isNaN(props.unit.psychic.deny) ? <StatBadge name='Deny' value={props.unit.psychic.deny.toString()} /> : <></>}
Severity: Major
Found in src/components/WH40k9e/PsychicPhaseDetails.tsx and 1 other location - About 1 hr to fix
src/components/WH40k9e/PsychicPhaseDetails.tsx on lines 28..28

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 69.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  const weapons = props.phase === 'shooting'
    ? props.weapons.filter((x) => (x.type !== 'Melee'))
    : props.weapons.filter((x) => (x.type === 'Melee'))
Severity: Major
Found in src/components/KillTeam2018/WeaponList.tsx and 1 other location - About 1 hr to fix
src/components/WH40k9e/WeaponList.tsx on lines 12..14

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 69.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

              {!isNaN(props.unit.psychic.cast) ? <StatBadge name='Cast' value={props.unit.psychic.cast.toString()} /> : <></>}
Severity: Major
Found in src/components/WH40k9e/PsychicPhaseDetails.tsx and 1 other location - About 1 hr to fix
src/components/WH40k9e/PsychicPhaseDetails.tsx on lines 29..29

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 69.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  return (props.specialism !== ''
    ? <img className='specialism' style={{ height: '1em', marginRight: '10px' }} alt={props.specialism} src={`/icons/${props.specialism.toLowerCase()}.svg`} />
    : <></>
Severity: Major
Found in src/components/KillTeam2018/SpecialistIcon.tsx and 1 other location - About 1 hr to fix
src/components/KillTeam2018/CategoryIcon.tsx on lines 8..10

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 69.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  const weapons = props.phase === 'shooting'
    ? props.weapons.filter((x) => (x.type !== 'Melee'))
    : props.weapons.filter((x) => (x.type === 'Melee'))
Severity: Major
Found in src/components/WH40k9e/WeaponList.tsx and 1 other location - About 1 hr to fix
src/components/KillTeam2018/WeaponList.tsx on lines 13..15

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 69.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function parseUnitSelection has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const parseUnitSelection = (unitSelectionNode: Node): Unit => {
  let profiles = _.uniqBy([
    ...nodeMap("bs:profiles/bs:profile[@typeName='Unit']", unitSelectionNode, parseUnitProfile),
    ...nodeMap("bs:selections/bs:selection/bs:profiles/bs:profile[@typeName='Unit']", unitSelectionNode, parseUnitProfile)
  ], (p) => p.hash).sort((a: Profile, b: Profile) => (a.name.localeCompare(b.name)))
Severity: Minor
Found in src/parsers/WH40k9e/BattlescribeParser.ts - About 1 hr to fix

    Function PowerList has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function PowerList (props: Props): JSX.Element {
      return (
        <Row xs={1} sm={2} md={3} className='g-4'>
          {_.sortBy(props.powers, ['name']).map((x: PsychicPower) => (
            <Col key={x.id}>
    Severity: Minor
    Found in src/components/KillTeam2021/PowerList.tsx - About 1 hr to fix

      Function FightPhaseDetails has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function FightPhaseDetails (props: Props): JSX.Element {
        return (
          <>
            <Row style={{
              pageBreakInside: 'avoid'
      Severity: Minor
      Found in src/components/WH40k9e/FightPhaseDetails.tsx - About 1 hr to fix

        Function ModelTitle has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function ModelTitle (props: Props): JSX.Element {
          const headingStyle = {
            background: 'black',
            color: 'white',
            padding: '5px',
        Severity: Minor
        Found in src/components/ModelTitle.tsx - About 1 hr to fix

          Function parseOperative has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const parseOperative = (model: Element): Operative => {
            const allKeywords = (xpSelect(".//bs:categories/bs:category[@primary='false']/@name", model) as Node[]).map((x) => (x.textContent ?? '').replace('💀', ''))
            const faction = _.intersection(allKeywords, factionKeywords).pop() ?? allKeywords.find((k) => (k === k.toUpperCase())) ?? null
            const keywords = _.remove(allKeywords, (x) => (x !== faction))
          
          
          Severity: Minor
          Found in src/parsers/KillTeam2021/BattlescribeParser.ts - About 1 hr to fix

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                  for (const ployData of factionData.strategicPloys) {
                    for (const keyword of keywords) {
                      if (ployData.description.includes(keyword)) {
                        expect(ployData.description).toContain(`**${keyword}**`)
                      }
            Severity: Major
            Found in src/components/KillTeam2021/data.test.ts and 1 other location - About 1 hr to fix
            src/components/KillTeam2021/data.test.ts on lines 16..22

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 64.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            const archetypes: FireteamArchetypes = {
              fireteams: {
                'Exaction Squad Kill Team': [Archetype.RECON, Archetype.SECURITY, Archetype.SEEK_AND_DESTROY],
                // Battlescribe data currently has 'Kill Team' as catalogue name, not Hand of the Archon
                'Kill Team': [Archetype.RECON, Archetype.SECURITY, Archetype.SEEK_AND_DESTROY]
            Severity: Major
            Found in src/components/KillTeam2021/data/exactionSquad.ts and 1 other location - About 1 hr to fix
            src/components/KillTeam2021/data/handOfTheArchon.ts on lines 5..12

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 64.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                  for (const ployData of factionData.tacticalPloys) {
                    for (const keyword of keywords) {
                      if (ployData.description.includes(keyword)) {
                        expect(ployData.description).toContain(`**${keyword}**`)
                      }
            Severity: Major
            Found in src/components/KillTeam2021/data.test.ts and 1 other location - About 1 hr to fix
            src/components/KillTeam2021/data.test.ts on lines 8..14

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 64.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            const archetypes: FireteamArchetypes = {
              fireteams: {
                'Hand of the Archon': [Archetype.RECON, Archetype.SECURITY, Archetype.SEEK_AND_DESTROY],
                // Battlescribe data currently has 'Kill Team' as catalogue name, not Hand of the Archon
                'Kill Team': [Archetype.RECON, Archetype.SECURITY, Archetype.SEEK_AND_DESTROY]
            Severity: Major
            Found in src/components/KillTeam2021/data/handOfTheArchon.ts and 1 other location - About 1 hr to fix
            src/components/KillTeam2021/data/exactionSquad.ts on lines 8..14

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 64.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function StatsTable has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function StatsTable (props: Props): JSX.Element {
              return (
                <Table striped bordered size='sm'>
                  <thead>
                    <tr>
            Severity: Minor
            Found in src/components/KillTeam2018/StatsTable.tsx - About 1 hr to fix

              Function parseBattlescribeXML has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const parseBattlescribeXML = (doc: Document): Roster => {
                const operatives = []
                const name = xpSelect('string(/bs:roster/@name)', doc, true).toString()
                const faction = xpSelect('string(//bs:force/@catalogueName)', doc, true).toString()
                for (const model of xpSelect('//bs:selection[@type=\'model\']', doc) as Element[]) {
              Severity: Minor
              Found in src/parsers/KillTeam2021/BattlescribeParser.ts - About 1 hr to fix

                Function TacOpsList has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function TacOpsList (props: Props): JSX.Element {
                  return (
                    <Row xs={1} sm={2} md={3} className='g-4'>
                      {props.tacOps.map((x: TacOp) => (
                        <Col key={x.id}>

                  Function WeaponList has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function WeaponList (props: Props): JSX.Element {
                    const weapons = props.phase === 'shooting'
                      ? props.weapons.filter((x) => (x.type !== 'Melee'))
                      : props.weapons.filter((x) => (x.type === 'Melee'))
                  
                  
                  Severity: Minor
                  Found in src/components/WH40k9e/WeaponList.tsx - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language