serge-web/serge-web

View on GitHub

Showing 244 of 805 total issues

Function UnsavedChannelModal has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const UnsavedChannelModal: React.FC = () => {
  const dispatch = useDispatch()
  const wargame = useSelector((state: RootState) => state.wargame)
  const currentModal = useSelector((state: RootState) => state.currentModal)

Severity: Minor
Found in client/src/Components/Modals/UnsavedChannelModal.tsx - About 35 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 MilSymbolRenderer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const MilSymbolRenderer: React.FC<CoreRendererProps> = ({ features, onDragged, onRemoved, onSelect, showLabels, selected = [] }): any => {
  const { filterFeatureIds, isMeasuring } = useMappingState()

  const filter = (feature: Feature<Geometry, any>): boolean => feature.properties._type === RENDERER_MILSYM && filterFeatureIds.includes('' + feature.properties.id)
  const pointToLayer = (feature: Feature<Point, any>, latLng: L.LatLng) => {

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

Avoid too many return statements within this function.
Open

      return that.createStrItem(pair)
Severity: Major
Found in client/src/Components/MessagePreview.jsx - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

      return []

      Avoid too many return statements within this function.
      Open

            if (moment(pair[1], moment.ISO_8601, true).isValid()) return that.createTimeItem(pair)
      Severity: Major
      Found in client/src/Components/MessagePreview.jsx - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return (
                <Fragment key={`${pair[0]}-${pair[1]}`}>
                  <h3>{pair[0]}</h3>
                  <span>{pair[1]}</span>
                </Fragment>
        Severity: Major
        Found in client/src/Components/MessagePreview.jsx - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return true

            Avoid too many return statements within this function.
            Open

                    return {
                      type: 'Feature',
                      properties: props,
                      geometry: {
                        coordinates: polygon.coordinates,
            Severity: Major
            Found in client/src/Components/local/atoms/core-mapping/index.tsx - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return <></>

                Avoid too many return statements within this function.
                Open

                        return null
                Severity: Major
                Found in client/src/Components/local/atoms/core-mapping/index.tsx - About 30 mins to fix

                  Function actionsFor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const actionsFor = (actionTable: ActionTable, state: States, permission: Permission, isOwner?: boolean): Action[] => {
                    const forState: ActionList = actionTable[state]
                    if (state === States.InProgress) {
                      // special handling. We only offer save/submit if it's the owner
                      if (isOwner) {

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

                  export const lightOrDark = (color: string): 'light' | 'dark' => {
                    let r: any, g: any, b: any
                    // Check the format of the color, HEX or RGB?
                    if (color.match(/^rgb/)) {
                      // If HEX --> store the red, green, blue values in separate variables
                  Severity: Minor
                  Found in client/src/Components/local/map-control/helpers/lightOrDark.ts - About 25 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 Template has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const Template: Story<TurnPropTypes> = (args) => {
                    const { ...props } = args
                    const [state, setState] = useState({
                      phase: props.phase,
                      currentTurn: args.currentTurn,

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

                  export const StatusBar: React.FC<PropTypes> = ({
                    onChange,
                    onSave,
                    wargame: initialWargame
                  }) => {
                  Severity: Minor
                  Found in client/src/Components/local/molecules/statusbar/index.tsx - About 25 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 getChannelTitlesFromInfoTypeMessages has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const getChannelTitlesFromInfoTypeMessages = (messages: MessageInfoType[]): ChannelTitles => {
                    const channelTitles: ChannelTitles = {}
                    for (const { data } of messages) {
                      for (const channel of data.channels.channels) {
                        const { name, uniqid } = channel
                  Severity: Minor
                  Found in client/src/ActionsAndReducers/ExportItems/ExportItems_ActionsCreators.ts - About 25 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 AdminLogin has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const AdminLogin: React.FC<Props> = ({ onSubmit }: Props) => {
                    // (temporarily) put password in box, to make testing quicker in dev
                    const providePassword = true
                    const [password, setPassword] = useState(providePassword ? DEFAULT_SERVER : '')
                    const gameInfo = useSelector((state: RootState) => state.gameInfo)
                  Severity: Minor
                  Found in client/src/Components/local/organisms/admin-login/index.tsx - About 25 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 filteredMessages has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const filteredMessages = (messages: MessageCustom[], showArchived: boolean): MessageCustom[] => {
                    return messages.filter(msg => {
                      if (showArchived) {
                        // ok - show all messages
                        return true

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

                  const convertMilliseconds = (milliseconds: number, type: string): string => {
                    if (milliseconds === null) return ''
                  
                    let hours, minutes, seconds, days
                    seconds = Math.floor(milliseconds / 1000)
                  Severity: Minor
                  Found in client/src/Helpers/convert-milliseconds.ts - About 25 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 ChannelTabsContainer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const ChannelTabsContainer: React.FC<Props> = ({ rootRef, onTabChange }): React.ReactElement => {
                    const [allowTabChangeEvent, setAllowTabChangeEvent] = useState<boolean>(false)
                    const [wargamesLoaded, setWargamesLoaded] = useState(false)
                    const selectedNode = useRef<FlexLayout.TabNode>()
                  
                  
                  Severity: Minor
                  Found in client/src/Views/ChannelTabsContainer/ChannelTabsContainer.tsx - About 25 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 getColumns has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const getColumns = (message: MessageCustom, columns: SpecialChannelColumns[]): string[][] => {
                    const msg = message.message
                    const res = columns.map((column: SpecialChannelColumns): string[] => {
                      switch (column) {
                        case SpecialChannelColumns.LOCATION: {
                  Severity: Minor
                  Found in client/src/Components/local/collab-status-board/helpers/get-columns.ts - About 25 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