serge-web/serge-web

View on GitHub

Showing 252 of 825 total issues

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

      .then(dbList => {
        const dbLists = dbList.map(dbName => dbName.replace(dbSuffix, ''))
        const wargameDbs = dbLists.filter(name => name.includes('wargame'))
        const reversedWargameDbs = wargameDbs.reverse()
        const serverPath = `${req.protocol}://${req.get('host')}`
Severity: Minor
Found in server/providers/pouchdb.js - About 1 hr to fix

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

    const setupEditor = (editor: Editor | null, schema: any, ref: RefObject<HTMLDivElement>,
      jsonEditorConfig: Record<string, any>, 
      showErrorsMode?: string): Editor | null => {
      if (editor !== null) {
        editor.destroy()

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

        const initMapListener = () => {
          let layersVisible = true 
          map.pm.Toolbar.createCustomControl({
            name: 'showLayersText',
            block: 'custom',

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

            const generateRowItemsChat = (forces: ForceData[], nextParticipant: ParticipantChat): RowItem[] => {
              let forceSelected: number[] = [0]
              let roleOptions: Option[] = []
              const additionalFields: RowItem[] = []
        
        

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

            const Wrapper = (): React.ReactElement => {
              const forcesMock = watuWargame.data.forces.forces[0]
              const initialState = { types: forcesMock.roles }
          
              const [items, setItems] = useState<{ types: Array<Item> }>(initialState)

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

            const Template: StoryFn<MessageListPropTypes> = (args) => {
              const { messages, playerForceId, hideForcesInChannel } = args
              const icons = [
                './images/default_img/forceDefault.png'
              ]

              Function exportDataGrouped has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              const exportDataGrouped = (messages: Message[], channelTitles: ChannelTitles): ExportItemData[] => {
                const data: ExportItemData[] = []
                const messageTypes: MessageTypes = {}
              
                for (const message of messages) {

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

              const runServer = (
                pouchOptions,
                corsOptions,
                imgDir,
                port,
              Severity: Minor
              Found in server/server.js - 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 renderTableBody has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  const renderTableBody = (data: ChannelCollab): React.ReactElement[] => {
                    if (!data.participants) return [<></>]
                    return data.participants.map((participantCollab, key) => {
                      const handleSaveRow = (row: RowItem[], pKey = -1): void => {
                        if (pKey === -1) {

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

                    const renderTableBody = (data: ChannelChat): React.ReactElement[] => {
                      if (!data.participants) return [<></>]
                      return data.participants.map((participantChat, key) => {
                        const handleSaveRow = (row: RowItem[], pKey = -1): void => {
                          if (pKey === -1) {

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

                      const renderTableBody = (data: ChannelCustom): React.ReactElement[] => {
                        if (!data.participants) return [<></>]
                        return data.participants.map((participant, key) => {
                          const handleSaveRow = (row: RowItem[], pKey = -1): void => {
                            if (pKey === -1) {

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

                      render () {
                        let modal
                        switch (this.props.currentModal.modal) {
                          case 'delete':
                            modal = <DeleteModal />
                    Severity: Minor
                    Found in client/src/Components/Modals/ModalSwitch/ModalSwitchAdmin.tsx - About 1 hr to fix

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

                        const sendMessage = (e: React.MouseEvent<HTMLButtonElement>): void => {
                          e.persist()
                          const details: MessageDetails = {
                            channel: channel.uniqid,
                            from: {
                      Severity: Minor
                      Found in client/src/Components/local/form-elements/message-creator/index.tsx - About 1 hr to fix

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

                        const factory = (state: PlayerUi): Factory => {  
                          return (node: TabNode): React.ReactNode => {
                            /** helper to determine if the specified channel should be rendered */
                            const renderThisChannel = (channelData?: ChannelUI): boolean => {
                              if (channelData) {
                        Severity: Minor
                        Found in client/src/Views/ChannelTabsContainer/helpers/factory.tsx - About 1 hr to fix

                          Function saveNewMessage has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            const saveNewMessage = (newFeatureCollection: FeatureCollection<Geometry, GeoJsonProperties>) => {
                              if (newFeatureCollection) {
                                const timestamp = new Date().toISOString()
                                const details: MessageDetails = {
                                  channel: channel.uniqid,
                          Severity: Minor
                          Found in client/src/Components/local/atoms/core-mapping/index.tsx - About 1 hr to fix

                            Function onDragged has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              const onDragged = (id: number | string, latLngs: LatLng | LatLng[] | LatLng[][]) => {
                                if (featureCollection && featureCollection.features) {
                                  const cloneFeatureCollection = cloneDeep(featureCollection)
                                  const idx = cloneFeatureCollection.features.findIndex(f => f.properties?.id === id)
                                  if (idx !== -1 && latLngs) {
                            Severity: Minor
                            Found in client/src/Components/local/atoms/core-mapping/index.tsx - About 1 hr to fix

                              Function checkV3ParticipantStates has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export const checkV3ParticipantStates = (channel: ChannelTypes, selectedForce: string | undefined, selectedRole: Role['roleId'], isObserver: boolean): CheckParticipantStates => {
                                if (selectedForce === undefined) throw new Error('selectedForce is undefined')
                                const channelParts: CoreParticipant[] = channel.participants
                                const participatingForce: CoreParticipant | undefined = channelParts && channelParts.find(p => matchedForceFilter(p.forceUniqid, selectedForce))
                                // not a member of this channel, return false answer
                              Severity: Minor
                              Found in client/src/Helpers/participant-states.ts - About 1 hr to fix

                                Consider simplifying this complex logical expression.
                                Open

                                              if (row.type === ROW_WITH_COLLAPSIBLE_TYPE) {
                                                const { collapsible, cells, rowKey } = row
                                                const tableCells = cells || row
                                                // ideally we'll use the contents of cell zero (message-id). If we can't
                                                // just use the row count
                                Severity: Critical
                                Found in client/src/Components/local/organisms/data-table/index.tsx - About 1 hr to fix

                                  Function wargameListPromise has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      const wargameListPromise = allDbsPromise.then(allDbs => {
                                        const wargameDbs = allDbs.filter(name => name.includes('wargame'))
                                        const reversedWargameDbs = wargameDbs.reverse()
                                        return Promise.all(reversedWargameDbs.map(async db => {
                                          const databaseName = checkSqliteExists(db)
                                  Severity: Minor
                                  Found in server/providers/couchdb.js - About 1 hr to fix

                                    Function Template has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    const Template: StoryFn = (args) => {
                                      // the channels child element may theoretically be undefined, we
                                      // make the compiler happy
                                      if (args.channels === undefined) {
                                        return <div />
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language