serge-web/serge-web

View on GitHub

Showing 244 of 805 total issues

File wargames_ActionCreators.ts has 323 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import * as ActionConstant from 'src/config'
import 'whatwg-fetch'
import _ from 'lodash'

import * as wargamesApi from '../../api/wargames_api'
Severity: Minor
Found in client/src/ActionsAndReducers/dbWargames/wargames_ActionCreators.ts - About 3 hrs to fix

    Function SettingOverview has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    export const SettingOverview: React.FC<PropTypes> = ({
      overview: initialOverview, onSave, onChange,
      initiateWargame, wargameInitiated, ignoreFlatpickrSnapshot
    }) => {
      const [overview, setOverview] = useState<WargameOverview>(initialOverview)
    Severity: Minor
    Found in client/src/Components/local/organisms/setting-overview/index.tsx - 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 populateDb has 92 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const populateDb = () => {
      const promises = []
    
      return new Promise((resolve, reject) => {
        db.allDocs().then(entries => {
    Severity: Major
    Found in client/src/api/messageTypes_api.js - About 3 hrs to fix

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

      import { faCheck } from '@fortawesome/free-solid-svg-icons'
      import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
      import { Checkbox, FormControlLabel, Input } from '@material-ui/core'
      import FormControl from '@material-ui/core/FormControl'
      import MenuItem from '@material-ui/core/MenuItem'
      Severity: Minor
      Found in client/src/Components/local/organisms/setting-overview/index.tsx - About 3 hrs to fix

        Function RfiForm has 90 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const RfiForm: React.FC<Props> = (props) => {
          const classes = useStyles()
          const { message } = props
          const formReducers = (state: ActionPayload, action: Action): ActionPayload => {
            switch (action.type) {
        Severity: Major
        Found in client/src/Components/local/molecules/rfi-form/index.tsx - About 3 hrs to fix

          Function CollabMessageDetail has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

          export const CollabMessageDetail: React.FC<Props> = ({
            templates, message, state, onChange, isObserver, isUmpire,
            role, channelColb, permission, assignees = [], collapseMe, gameDate, onRead, isReaded
          }) => {
            const [answer, setAnswer] = useState<{ [property: string]: any }>((message.details.collaboration && message.details.collaboration.response) || {})
          Severity: Minor
          Found in client/src/Components/local/molecules/collab-message-detail/index.tsx - 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 TableHeadCell has 86 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const TableHeadCell = (props: Props): (React.ReactElement | null) => {
            const [open, setOpen] = useState<boolean>(false)
            const buttonRef = useRef(null)
            const { content, id, filters, onFilter, sort, onSort, sortingColId, sortDirection = 'asc' } = props
            const contentFilter = content as ContentFilterType
          Severity: Major
          Found in client/src/Components/local/atoms/table-head-cell/index.tsx - About 3 hrs to fix

            Function toMasked has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

            export const toMasked = (turnTime: GameTurnLength): string => {
              if (turnTime) {
                // we need to do this twice, so refactor to function
                const fromMillis = (millis: number): string => {
                  let days, hours, minutes, seconds

            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

            File handle-channel-updates.ts has 300 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { CHANNEL_CHAT, CHANNEL_COLLAB, CHAT_CHANNEL_ID, CUSTOM_MESSAGE, expiredStorage, INFO_MESSAGE, INFO_MESSAGE_CLIPPED } from 'src/config'
            import {
              ChannelTypes, ChannelUI, ForceData, MessageChannel,
              MessageCustom, MessageInfoType, MessageInfoTypeClipped, PlayerMessage, PlayerMessageLog, PlayerUiChannels, PlayerUiChatChannel, Role, SetWargameMessage, TemplateBodysByKey
            } from 'src/custom-types'
            Severity: Minor
            Found in client/src/Helpers/handle-channel-updates.ts - About 3 hrs to fix

              Function genPlayerLogDataTable has 78 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const genPlayerLogDataTable = (rows: PlayerLogModal[]): PlayerLogDataTable => {
                const sortCol = (str1: string | React.ReactElement, str2: string | React.ReactElement): number => {
                  if (!str1 || !str2) {
                    return 1
                  }
              Severity: Major
              Found in client/src/Views/PlayerLog/helpers/genData.tsx - About 3 hrs to fix

                Function ReactTable has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                export const ReactTable: React.FC<ReactTableProps> = (props) => {
                  const {
                    columns,
                    rows,
                    showArchived,
                Severity: Minor
                Found in client/src/Components/local/react-table/index.tsx - 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 webpackFinal has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  webpackFinal: async config => {
                    config.module.rules.push(
                    {
                      test: /\.(js|jsx)$/,
                      loader: require.resolve('babel-loader'),
                Severity: Major
                Found in client/.storybook/main.js - About 3 hrs to fix

                  Function tabRender has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const tabRender = (state: PlayerUi): (node: TabNode) => void => {
                    return (node: TabNode): void => {
                      setTimeout(() => {
                        const tabLayout = document.getElementsByClassName('flexlayout__layout')[0]
                        const tabSetHeaderElms = tabLayout.getElementsByClassName('flexlayout__tabset')
                  Severity: Major
                  Found in client/src/Views/ChannelTabsContainer/helpers/tabRender.tsx - About 3 hrs to fix

                    Function renderItems has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      const renderItems = items.map((item, key) => {
                        let uniqid: React.ReactText = key
                        let value = item
                        const isNumber = typeof item === 'number'
                        if (typeof item === 'object') {
                    Severity: Major
                    Found in client/src/Components/local/molecules/sortable-list/index.tsx - About 3 hrs to fix

                      Function echelonMobilityTowedarray has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const echelonMobilityTowedarray = (symbolset: string) => {
                        if (symbolset == '10') {
                          return [
                            { code: '00', name: 'Unspecified', sidc: '10031000000000000000' },
                            { code: '11', name: 'Team/Crew', sidc: '10031000110000000000' },

                        Function exportDataGroupedGetRowsAndFields has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                        Open

                        const exportDataGroupedGetRowsAndFields = (messages: Message[], message: Message, channelTitles: ChannelTitles) :ExportDataGroupedGetRowsAndFields => {
                          const messagesFiltered: Message[] = message.messageType === CUSTOM_MESSAGE 
                            ? messages.filter(msg => msg.messageType === CUSTOM_MESSAGE && (message as MessageCustom).templateId === (msg as MessageCustom).templateId)
                            : messages.filter(({ messageType }) => message.messageType === messageType)
                        
                        

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

                        const CoreRenderer: React.FC<CoreRendererProps> = ({ features, onDragged, onRemoved, onEdited, onSelect, forceStyles, selected = [] }) => {
                          const { filterFeatureIds, isMeasuring } = useMappingState()
                          const filter = (feature: Feature<Geometry, any>): boolean => feature.properties._type === RENDERER_CORE && filterFeatureIds.includes('' + feature.properties.id)
                          const style: StyleFunction<any> = (feature?: Feature<any>): PathOptions => {
                            if (feature) {

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

                        const DeleteModal: React.FC = () => {
                          const dispatch = useDispatch()
                          const currentModal = useSelector((state: RootState) => state.currentModal)
                          const wargame = useSelector((state: RootState) => state.wargame)
                        
                        
                        Severity: Minor
                        Found in client/src/Components/Modals/DeleteConfirmation.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 genPlayerLogDataTable has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export const genPlayerLogDataTable = (rows: PlayerLogModal[]): PlayerLogDataTable => {
                          const sortCol = (str1: string | React.ReactElement, str2: string | React.ReactElement): number => {
                            if (!str1 || !str2) {
                              return 1
                            }
                        Severity: Minor
                        Found in client/src/Views/PlayerLog/helpers/genData.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

                        File pouchdb.js has 288 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        const listeners = {}
                        let addListenersQueue = []
                        let wargameName = ''
                        const { wargameSettings, INFO_MESSAGE, dbSuffix, settings, CUSTOM_MESSAGE, databaseUrlPrefix } = require('../consts')
                        
                        
                        Severity: Minor
                        Found in server/providers/pouchdb.js - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language