serge-web/serge-web

View on GitHub
client/src/Components/local/organisms/setting-channels/channels/chat.tsx

Summary

Maintainability
F
6 days
Test Coverage

Function renderContent has 178 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const renderContent = (): React.ReactNode => {
    if (!localChannelUpdates) return null

    const handleSaveRows = (participants: ParticipantChat[]): void => {
      const newChannel = { ...localChannelUpdates }

    Function ChatChannel has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

    export const ChatChannel: React.FC<ChatChannelProps> = ({
      channel,
      forces,
      onChange
    }) => {

    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 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 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 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)

          Similar blocks of code found in 2 locations. 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) {
          client/src/Components/local/organisms/setting-channels/channels/collab.tsx on lines 186..225

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 377.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                if (nextParticipant.forceUniqid) {
                  const forceIndex = forces.findIndex(force => force.uniqid === nextParticipant.forceUniqid)
                  if (forceIndex !== -1) {
                    roleOptions = forces[forceIndex].roles.map((role): Option => ({
                      name: role.name,
          client/src/Components/local/organisms/setting-channels/channels/collab.tsx on lines 100..110
          client/src/Components/local/organisms/setting-channels/channels/custom.tsx on lines 86..96

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 121.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              const renderTableFooter = (): React.ReactElement => {
                const items = generateRowItemsChat(forces, defaultParticipantChat)
                return <EditableRow
                  isGenerator={true}
                  noSwitchOnReset
          client/src/Components/local/organisms/setting-channels/channels/collab.tsx on lines 227..240

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 112.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

            return (
              <>
                <Confirm
                  isOpen={participantKey !== -1}
                  title="Delete Participation"
          client/src/Components/local/organisms/setting-channels/channels/collab.tsx on lines 399..412
          client/src/Components/local/organisms/setting-channels/channels/custom.tsx on lines 242..255

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 95.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                const activeRoles: Array<number> = partRoles ? partRoles.map(role => {
                  return roleOptions.findIndex(option => option.value.roleId === role)
                }).filter(active => active !== -1) : []
          client/src/Components/local/organisms/setting-channels/channels/collab.tsx on lines 113..115

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 82.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              const handleCreateParticipant = (rowItems: RowItem[]): void => {
                if (localChannelUpdates) {
                  handleSaveRows([
                    ...localChannelUpdates.participants,
                    rowToParticipantChat(forces, rowItems, defaultParticipantChat)
          client/src/Components/local/organisms/setting-channels/channels/collab.tsx on lines 175..184
          client/src/Components/local/organisms/setting-channels/channels/custom.tsx on lines 145..154

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 69.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

                const roles: Array<Role['roleId']> = access.active ? access.active.map((key: number) => (
                  selectedForce.roles[key].roleId
                )) : []
          client/src/Components/local/organisms/setting-channels/channels/collab.tsx on lines 74..74
          client/src/Components/local/organisms/setting-channels/channels/custom.tsx on lines 66..66

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 68.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 3 locations. Consider refactoring.
          Open

                return [
                  {
                    active: forceSelected,
                    multiple: false,
                    options: forces,
          client/src/Components/local/organisms/setting-channels/channels/collab.tsx on lines 150..167
          client/src/Components/local/organisms/setting-channels/channels/custom.tsx on lines 120..137

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 66.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              const handleChangeRow = (nextItems: RowItem[], participant: ParticipantChat): RowItem[] => {
                const nextParticipant = rowToParticipantChat(forces, nextItems, participant)
                return generateRowItemsChat(forces, nextParticipant)
              }
          client/src/Components/local/organisms/setting-channels/channels/collab.tsx on lines 170..173

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 57.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              const handleSaveRows = (participants: ParticipantChat[]): void => {
                const newChannel = { ...localChannelUpdates }
                newChannel.participants = participants
                setLocalChannelUpdates(newChannel)
              }
          client/src/Components/local/organisms/setting-channels/channels/collab.tsx on lines 60..64
          client/src/Components/local/organisms/setting-channels/channels/custom.tsx on lines 57..61

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 54.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          There are no issues that match your filters.

          Category
          Status