serge-web/serge-web

View on GitHub

Showing 805 of 805 total issues

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

    db.find({
      selector: {
        wargame: req.params.wargame
      },
      fields: ['role', 'activityTime', 'activityType']
Severity: Major
Found in server/providers/pouchdb.js and 1 other location - About 7 hrs to fix
server/providers/couchdb.js on lines 338..356

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 179.

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 renderContent has 178 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const renderContent = (): React.ReactNode => {
    if (!localChannelUpdates) return null

    const handleSaveRows = (participants: ParticipantChat[]): void => {
      const newChannel = { ...localChannelUpdates }

    Function CollabChannel has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

    export const CollabChannel: React.FC<CollabChannelProps> = ({
      channel,
      forces,
      messageTemplates,
      onChange

    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 renderContent has 167 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const renderContent = (): React.ReactNode => {
        if (!localChannelUpdates) return null
    
        const handleSaveRows = (participants: ParticipantCustom[]): void => {
          const newChannel = { ...localChannelUpdates }

      Function genData has 161 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const genData = (
        messages: MessageCustom[],
        forces: ForceData[],
        role: ForceRole,
        templates: TemplateBodysByKey,
      Severity: Major
      Found in client/src/Components/local/collab-status-board/helpers/gen-data.tsx - About 6 hrs to fix

        Function CustomChannel has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
        Open

        export const CustomChannel: React.FC<CustomChannelProps> = ({
          channel,
          forces,
          messageTemplates,
          onChange

        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

          if (typeof turnLength === 'number') {
            // turn length in legacy format, plain millis
            return asTime.add(turnLength, 'ms').toISOString()
          } else {
            const turnTimeType: TurnLengthType = turnLength as TurnLengthType
        Severity: Major
        Found in client/src/Helpers/increment-game-time-helpers.ts and 1 other location - About 6 hrs to fix
        client/src/Helpers/increment-game-time.ts on lines 11..26

        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 163.

        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

          if (typeof turnLength === 'number') {
            // turn length in legacy format, plain millis
            return asTime.add(turnLength, 'ms').valueOf()
          } else {
            const turnTimeType: TurnLengthType = turnLength as TurnLengthType
        Severity: Major
        Found in client/src/Helpers/increment-game-time.ts and 1 other location - About 6 hrs to fix
        client/src/Helpers/increment-game-time-helpers.ts on lines 11..26

        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 163.

        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

        File index.tsx has 431 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { faCircleArrowRight } from '@fortawesome/free-solid-svg-icons'
        import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
        import { Box, Button } from '@material-ui/core'
        import Slide from '@mui/material/Slide'
        import { Feature, FeatureCollection, GeoJsonProperties, Geometry } from 'geojson'
        Severity: Minor
        Found in client/src/Components/local/atoms/core-mapping/index.tsx - About 6 hrs to fix

          File index.tsx has 431 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { faArrowAltCircleLeft, faWindowMaximize, faWindowMinimize } from '@fortawesome/free-solid-svg-icons'
          import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
          import { Checkbox, FormControlLabel } from '@material-ui/core'
          import { Feature, FeatureCollection, GeoJsonProperties, Geometry } from 'geojson'
          import { cloneDeep, get, isEqual, merge, set, uniq } from 'lodash'
          Severity: Minor
          Found in client/src/Components/local/atoms/mapping-panel/index.tsx - About 6 hrs to fix

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

                    <div className={styles['role-item']}>
                      <MobileSwitch disabled={!data.umpire} size='small' checked={roleItem.isObserver} onChange={(): void => {
                        handleChangeRole({ ...roleItem, isObserver: !roleItem.isObserver })
                      }} />
                      {key === 0 && <div
            client/src/Components/local/organisms/setting-forces/settings-force-roles/index.tsx on lines 56..65
            client/src/Components/local/organisms/setting-forces/settings-force-roles/index.tsx on lines 76..85
            client/src/Components/local/organisms/setting-forces/settings-force-roles/index.tsx on lines 86..95

            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 161.

            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 4 locations. Consider refactoring.
            Open

                    <div className={styles['role-item']}>
                      <MobileSwitch disabled={!data.umpire} size='small' checked={roleItem.isInsightViewer} onChange={(): void => {
                        handleChangeRole({ ...roleItem, isInsightViewer: !roleItem.isInsightViewer })
                      }} />
                      {key === 0 && <div
            client/src/Components/local/organisms/setting-forces/settings-force-roles/index.tsx on lines 56..65
            client/src/Components/local/organisms/setting-forces/settings-force-roles/index.tsx on lines 66..75
            client/src/Components/local/organisms/setting-forces/settings-force-roles/index.tsx on lines 86..95

            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 161.

            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 4 locations. Consider refactoring.
            Open

                    <div className={styles['role-item']}>
                      <MobileSwitch disabled={!data.umpire} size='small' checked={roleItem.isGameControl} onChange={(): void => {
                        handleChangeRole({ ...roleItem, isGameControl: !roleItem.isGameControl })
                      }} />
                      {key === 0 && <div
            client/src/Components/local/organisms/setting-forces/settings-force-roles/index.tsx on lines 66..75
            client/src/Components/local/organisms/setting-forces/settings-force-roles/index.tsx on lines 76..85
            client/src/Components/local/organisms/setting-forces/settings-force-roles/index.tsx on lines 86..95

            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 161.

            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 4 locations. Consider refactoring.
            Open

                    <div className={styles['role-item']}>
                      <MobileSwitch disabled={!data.umpire} size='small' checked={roleItem.isRFIManager} onChange={(): void => {
                        handleChangeRole({ ...roleItem, isRFIManager: !roleItem.isRFIManager })
                      }} />
                      {key === 0 && <div
            client/src/Components/local/organisms/setting-forces/settings-force-roles/index.tsx on lines 56..65
            client/src/Components/local/organisms/setting-forces/settings-force-roles/index.tsx on lines 66..75
            client/src/Components/local/organisms/setting-forces/settings-force-roles/index.tsx on lines 76..85

            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 161.

            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 3 locations. Consider refactoring.
            Open

            export const saveEditAndRelease: SubmitHandler = {
              handlerType: SUBMIT_HANDLER,
              handler: (_role: ForceRole, _verb: string, message: MessageCustom,
                newMsg: { [property: string]: any }, privateMessage: string): MessageCustom => {
                return {
            client/src/Components/local/molecules/collab-message-detail/helpers/handlers.ts on lines 102..124
            client/src/Components/local/molecules/collab-message-detail/helpers/handlers.ts on lines 189..211

            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 159.

            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 3 locations. Consider refactoring.
            Open

            export const submitForReview: SubmitHandler = {
              handlerType: SUBMIT_HANDLER,
              handler: (_role: ForceRole, _verb: string, message: MessageCustom,
                newMsg: { [property: string]: any }, privateMessage: string): MessageCustom => {
                return {
            client/src/Components/local/molecules/collab-message-detail/helpers/handlers.ts on lines 78..100
            client/src/Components/local/molecules/collab-message-detail/helpers/handlers.ts on lines 102..124

            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 159.

            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 3 locations. Consider refactoring.
            Open

            export const save: SubmitHandler = {
              handlerType: SUBMIT_HANDLER,
              handler: (_role: ForceRole, _verb: string, message: MessageCustom,
                newMsg: { [property: string]: any }, privateMessage: string): MessageCustom => {
                return {
            client/src/Components/local/molecules/collab-message-detail/helpers/handlers.ts on lines 78..100
            client/src/Components/local/molecules/collab-message-detail/helpers/handlers.ts on lines 189..211

            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 159.

            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

            export const handleRemoveRecipient = (newState: WargamesState, payload: string, tab: string) => {
              const curChannel = newState.data[tab].selectedChannel.uniqid
              const index = newState.data[tab].channels.find((c: ChannelTypes) => c.uniqid === curChannel).participants.findIndex((participant: ParticipantTypes) => participant.subscriptionId === payload)
              newState.data[tab].channels.find((c: ChannelTypes) => c.uniqid === curChannel).participants.splice(index, 1)
            }
            client/src/ActionsAndReducers/dbWargames/helpers/wargamesHandlers.ts on lines 121..129

            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 156.

            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

            export const handleUpdateRoleName = (newState: WargamesState, payload: { 
                force?: string
                role?: string
                oldName?: string
              }, tab: string) => {
            client/src/ActionsAndReducers/dbWargames/helpers/wargamesHandlers.ts on lines 105..109

            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 156.

            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 EditableRow has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
            Open

            export const EditableRow: React.FC<PropTypes> = ({
              items,
              onChange,
              actions,
              onSave,
            Severity: Minor
            Found in client/src/Components/local/molecules/editable-row/index.tsx - About 5 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

            Severity
            Category
            Status
            Source
            Language