serge-web/serge-web

View on GitHub

Showing 252 of 825 total issues

Function _renderItem has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  _renderItem(item, menu) {
    const selected = this._isSelected(item)

    const p = L.DomUtil.create('div', 'leaflet-control-select-menu-line', menu)
    const pContent = L.DomUtil.create(
Severity: Minor
Found in client/static/leaflet/select/leaflet.select.js - About 1 hr to fix

    Function onMessageValuesChanged has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const onMessageValuesChanged = (messageLocal: MessagesValues, value: string[], action: Action, type: string): MessagesValues => {
      const nextMessageLocal: MessagesValues = { ...messageLocal }
      
      switch (type) {
        case MessageGroupType.MESSAGE_TEMPLATE:

      Function componentFor has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const componentFor = (
        key: string,
        prop: SelectedProps,
        propertyType: PropertyType,
        value: any,

        Function onDelete has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const onDelete = () => {
            const curTab = wargame.currentTab
        
            switch (type) {
              case 'force': {
        Severity: Minor
        Found in client/src/Components/Modals/DeleteConfirmation.tsx - About 1 hr to fix

          Function createWargame has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const createWargame = async (dispatch: Dispatch, wargameLists : WargameList[]): Promise<Wargame> => {
            const name = `wargame-${uniqid.time()}`
            const db = new DbProvider(databasePath + name)
            addWargameDbStore({ name, db })
          
          
          Severity: Minor
          Found in client/src/api/wargames_api/index.ts - About 1 hr to fix

            Function handleSaveForce has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              const handleSaveForce = (newForces: ForceData[]) => {
                const { selectedForce } = forces
                const { uniqid } = selectedForce as ForceData
                const newForceData = newForces.find(force => force.uniqid === uniqid)
                if (newForceData) {
            Severity: Minor
            Found in client/src/Views/GameSetupNew.tsx - About 1 hr to fix

              Function postNewMessageTypeToDb has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const postNewMessageTypeToDb = (schema) => {
                return new Promise((resolve, reject) => {
                  (async () => {
                    // Get all existing message types from the database
                    const allMessages = await getAllMessagesFromDb()
              Severity: Minor
              Found in client/src/api/messageTypes_api.js - About 1 hr to fix

                Function addMessage has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const addMessage = (messageDetail, schema) => {
                  return new Promise((resolve, reject) => {
                    (async () => {
                      const allMessages = await getAllMessagesFromDb()
                      const matchedName = allMessages.find((el) => el.details.title === messageDetail.title && el._id !== messageDetail.id)
                Severity: Minor
                Found in client/src/api/messages_api.js - About 1 hr to fix

                  Function renderChatOptions has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      const renderChatOptions = (): React.ReactElement => {
                        const handleCheckbox = (event: ChangeEvent<HTMLInputElement>): void => {
                          const newChannel = { ...localChannelUpdates }
                          newChannel.hideMessageAuthor = event.target.checked
                          setChatAuthorHidden(event.target.checked)

                    Function getParticipantStates has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export const getParticipantStates = (
                      channel: ChannelTypes, forceId: string | undefined,
                      role: Role['roleId'], isObserver: boolean,
                      allTemplatesByKey: TemplateBodysByKey,
                      // TODO: move it to reducer, for future default Message can be changed from admin
                    Severity: Minor
                    Found in client/src/Helpers/participant-states.ts - About 1 hr to fix

                      Function configCommonProps has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const configCommonProps = (propIn: Record<string, unknown>, gameDate: string): Record<string, unknown> => {
                        const prop = deepCopy(propIn)
                        switch (prop.format) {
                          case 'datetime-local':
                            // no, don't overwride flatpick
                      Severity: Minor
                      Found in client/src/Helpers/config-date-time-local.ts - About 1 hr to fix

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

                        const Template: StoryFn<StoryPropTypes> = (args) => {
                          const { privateMessage, confirmCancel } = args
                          const channel = watuWargame.data.channels.channels[0]
                          const channels = {}
                          watuWargame.data.channels.channels.forEach(c => {

                          Consider simplifying this complex logical expression.
                          Open

                            if ((isUmpire && isObserver) || isParticipant) {
                              const { forceIcons, forceColors, forceNames } = buildForceIconsColorsNames(channel.participants, allForces)
                              const isCollab = channel.channelType === CHANNEL_COLLAB
                              const messages = messagesFiltered.filter(
                                (message) => (message.details && message.details.channel === channel.uniqid) || (!isCollab && message.messageType === INFO_MESSAGE_CLIPPED)
                          Severity: Major
                          Found in client/src/Helpers/handle-channel-updates.ts - About 1 hr to fix

                            Function getFormatAndDefaultFieldName has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const getFormatAndDefaultFieldName = (schema: { format: string }, value: string): FormatInfo => {
                              switch (schema.format) {
                                case 'datetime-local':
                                  // don't bother with validation if it's na IZO string
                                  if (isISOString(value)) {

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

                            export const openMessage = (channel: string, payloadMessage: MessageChannel, newState: PlayerUi): ChannelUI => {
                              // mutating `messages` array - copyState at top of switch
                              const channelMessages: Array<MessageChannel> = (newState.channels[channel].messages || [])
                              const selectedForce = newState.selectedForce ? newState.selectedForce.uniqid : ''
                              if (payloadMessage._id !== undefined) {

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

                            export const SplitButton: React.FC<Props> = ({ label, options = [], onClick }: Props) => {
                              const gridStyles = useButtonStyle()
                              const [open, setOpen] = useState<boolean>(false)
                              const anchorRef = useRef<any>(null)
                              const [selectedIndex, setSelectedIndex] = useState<number>(-1)
                            Severity: Minor
                            Found in client/src/Components/local/atoms/split-button/index.tsx - About 55 mins 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 componentFor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const componentFor = (
                              key: string,
                              prop: SelectedProps,
                              propertyType: PropertyType,
                              value: any,

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

                            export const CollabStatusBoard: React.FC<CollabStatusBoardProps> = ({
                              templates, messages, channelColb, isObserver, isUmpire, onChange, role, forces,
                              gameDate, onMessageRead, onMarkAllAsRead, onMarkAllAsUnRead, currentWargame, collabActivity
                            }) => {
                              const [showArchived, setShowArchived] = useState<boolean>(false)
                            Severity: Minor
                            Found in client/src/Components/local/collab-status-board/index.tsx - About 55 mins 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 findEmptyRolenames has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const findEmptyRolenames = (newData: ForceData, forces: ForceData[]): Array<{ forceName:string, roleName: string }> => {
                              // use new force-data object, to check new values
                              const forcesData = _.map(forces, force => force.uniqid === newData.uniqid ? newData : force)
                            
                              // create flat list of data objects to check
                            Severity: Minor
                            Found in client/src/Helpers/find-empty-rolenames.ts - About 55 mins 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 SchemaEditor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export function SchemaEditor (elementId) {
                              Editor.call(this, elementId)
                            
                              // Check whether the node is a properties button for an object,
                              // and not for the schema of an object named properties
                            Severity: Minor
                            Found in client/src/Components/jsonSchemaEditor/json-schema-editor/editor.js - About 45 mins 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