serge-web/serge-web

View on GitHub

Showing 244 of 805 total issues

Function generateFeatures has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const generateFeatures = (bounds: L.LatLngBounds, numPoints: number, numShapes: number): FeatureCollection => {
  const features: Feature[] = []
  const x_min = bounds.getEast()
  const x_max = bounds.getWest()
  const y_min = bounds.getSouth()

    Function createChannel has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const createChannel = (
      // all channels list, need to create uniq name
      channels: ChannelTypes[],
      // for which force we need to create Original Template if format given
      defaultForce: ForceData,

      Function CollapsibleHeader has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const CollapsibleHeader: React.FC<PropTypes> = (props) => {
        const { children, onClick, onExpand, iconType = COLLASIBLE_DEFAULT_ICON } = props
        const collapsed: boolean = typeof props.collapsed === 'undefined' ? true : props.collapsed
        const hasContent: boolean = typeof props.hasContent === 'undefined' ? false : props.hasContent
        const collapseOnDragHover: boolean = typeof props.collapseOnDragHover === 'undefined' ? false : props.collapseOnDragHover

        Function initEditor has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const initEditor = (): () => void => {
            const hideArrayButtons = disabled
            const jsonEditorConfig = hideArrayButtons
              ? { disableArrayReOrder: true, disableArrayAdd: true, disableArrayDelete: true }
              : { disableArrayReOrder: false, disableArrayAdd: false, disableArrayDelete: false }
        Severity: Major
        Found in client/src/Components/local/molecules/json-editor/index.tsx - About 2 hrs to fix

          Function ChannelMessage has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const ChannelMessage: React.FC<Props> = (props: Props) => {
            const CollapsibleHeader = ({ onExpand, collapsed }: any): React.ReactElement => {
              const { onRead, onUnread, message } = props
          
              const title = messageTitleFor(message)
          Severity: Major
          Found in client/src/Components/local/molecules/channel-message/index.tsx - About 2 hrs to fix

            Function renderRoleFields has 56 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              const renderRoleFields = (item: SortableListItem, key: number): React.ReactNode => {
                const roleItem = item as Role
                const handleChangeRole = (nextRole: Role, submitPlans = false): void => {
                  const roles: Array<Role> = submitPlans ? data.roles.map(role => ({ ...role, canSubmitPlans: false })) : [...data.roles]
                  roles[key] = nextRole

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

                render () {
                  const loading = this.props.dbLoading.loadingWargames
               
                  if (loading) {
                    return <Loader />
              Severity: Major
              Found in client/src/Views/GameDesignerInterface.jsx - About 2 hrs to fix

                Function initialize has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  initialize(options) {
                    this.menus = []
                    L.Util.setOptions(this, options)
                    const opts = this.options
                
                
                Severity: Major
                Found in client/static/leaflet/select/leaflet.select.js - About 2 hrs to fix

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

                  import React, { useMemo, useState } from 'react'
                  import { makeStyles, Theme } from '@material-ui/core/styles'
                  import TableContainer from '@material-ui/core/TableContainer'
                  import Table from '@material-ui/core/Table'
                  import TableBody from '@material-ui/core/TableBody'
                  Severity: Minor
                  Found in client/src/Components/local/organisms/data-table/index.tsx - About 2 hrs to fix

                    handlers has 21 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    const handlers: Record<string, ActionHandler> = {
                      [ActionConstant.ALL_WARGAME_NAMES_SAVED]: (newState, action) => wargamesHandlers.handleAllWargameNamesSaved(newState, (action as AllWargameNameSaved).payload),
                      [ActionConstant.SET_CURRENT_WARGAME]: (newState, action) => wargamesHandlers.handleSetCurrentWargame(newState, (action as SetCurrentWargame).payload),
                      [ActionConstant.SET_EXPORT_WARGAME]: (newState, action) => wargamesHandlers.handleSetExportWargame(newState, (action as SetCurrentWargame).payload),
                      [ActionConstant.SET_CURRENT_GAME_SETUP_TAB]: (newState, action) => wargamesHandlers.handleSetCurrentGameSetupTab(newState, (action as SetCurrentGameSetupTab).payload),
                    Severity: Minor
                    Found in client/src/ActionsAndReducers/dbWargames/wargames_Reducer.ts - About 2 hrs to fix

                      Function Version has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const Version: React.FC<VersionProps> = () => {
                        const dispatch = useDispatch()
                        const { notifications, playerLog, wargame }: VersionProps = useSelector(({ notifications, playerLog, wargame }: VersionProps) => ({ notifications, playerLog, wargame }))
                        const [toggleBeat, setToggleBeat] = useState(false)
                        const [serverStatus, setServerStatus] = useState('')
                      Severity: Major
                      Found in client/src/Views/Version.tsx - About 2 hrs to fix

                        Function DeleteModal has 53 lines of code (exceeds 25 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: Major
                        Found in client/src/Components/Modals/DeleteConfirmation.tsx - About 2 hrs to fix

                          Function handleNonInfoMessage has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const handleNonInfoMessage = (data: SetWargameMessage, channel: string, message: MessageCustom, playerId: string) => {
                            const sourceRole: string = message.details.from.roleId
                            const logger: PlayerMessage = {
                              roleId: message.details.from.roleId,
                              lastMessageTitle: message.templateId,
                          Severity: Major
                          Found in client/src/Helpers/handle-channel-updates.ts - About 2 hrs to fix

                            Function generateRowItemsCustom has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

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

                              Function AdminAndInsightsTabsContainer has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const AdminAndInsightsTabsContainer = (): React.ReactElement => {
                                const state = usePlayerUiState()
                                const playerUiDispatch = usePlayerUiDispatch()
                                const dispatch = useDispatch()
                              
                              

                                Function WargameList has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                Open

                                export const WargameList: React.FC<Props> = ({ wargames, menuConfig, onGameClick, toggleAction, useCustomScroll = false }: Props) => {
                                  const [wargameQuery, setWargameQuery] = useState('')
                                  const [wargameMenuOpen, setWargameMenuOpen] = useState('')
                                  const [scrollPos, setScrollPos] = useState<any>({})
                                
                                
                                Severity: Minor
                                Found in client/src/Components/local/organisms/wargame-list/index.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

                                Function ChatMessage has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                Open

                                export const ChatMessage: React.FC<Props> = ({ message, isOwner, isUmpire, markUnread, hideAuthor }: Props) => {
                                  const PrivateBadge = (): React.ReactElement => (
                                    <span>
                                      <span className={styles['icon-private']}>
                                        <FontAwesomeIcon size='1x' icon={faUserSecret} />
                                Severity: Minor
                                Found in client/src/Components/local/molecules/chat-message/index.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

                                Function MessageCreator has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                Open

                                const MessageCreator: React.FC<PropTypes> = ({
                                  schema,
                                  privateMessage,
                                  onMessageSend,
                                  onCancel,
                                Severity: Minor
                                Found in client/src/Components/local/form-elements/message-creator/index.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

                                Function constructor has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  constructor (props, content) {
                                    super(props, content)
                                
                                    JSONEditor.JSONEditor.defaults.options.iconlib = 'fontawesome5'
                                    JSONEditor.JSONEditor.defaults.options.theme = 'bootstrap4'
                                Severity: Minor
                                Found in client/src/Components/jsonSchemaEditor/index.jsx - About 1 hr to fix

                                  Function ColFilter has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  const ColFilter: React.FC<ColFilterProps> = (props) => {
                                    const { onClose, open, anchorEl, filters, onFilterChanged, colName } = props
                                    const { menuItem } = useStyles()
                                    const [localFilter, setLocalFilter] = useState<CellFilter[]>([])
                                  
                                  
                                  Severity: Minor
                                  Found in client/src/Components/local/react-table/helpers/col-filter.tsx - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language