RocketChat/Rocket.Chat

View on GitHub
apps/meteor/client/views/room/body/RoomBodyV2.tsx

Summary

Maintainability
F
6 days
Test Coverage

Function RoomBody has 209 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const RoomBody = (): ReactElement => {
    const chat = useChat();
    if (!chat) {
        throw new Error('No ChatContext provided');
    }
Severity: Major
Found in apps/meteor/client/views/room/body/RoomBodyV2.tsx - About 1 day to fix

    Function RoomBody has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

    const RoomBody = (): ReactElement => {
        const chat = useChat();
        if (!chat) {
            throw new Error('No ChatContext provided');
        }
    Severity: Minor
    Found in apps/meteor/client/views/room/body/RoomBodyV2.tsx - About 5 hrs 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

    File RoomBodyV2.tsx has 251 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { css } from '@rocket.chat/css-in-js';
    import { Box } from '@rocket.chat/fuselage';
    import { useMergedRefs } from '@rocket.chat/fuselage-hooks';
    import { usePermission, useRole, useSetting, useTranslation, useUser, useUserPreference } from '@rocket.chat/ui-contexts';
    import type { MouseEventHandler, ReactElement } from 'react';
    Severity: Minor
    Found in apps/meteor/client/views/room/body/RoomBodyV2.tsx - About 2 hrs to fix

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

                                  <div className={['messages-box'].filter(isTruthy).join(' ')}>
                                      <JumpToRecentMessageButton visible={hasNewMessages} onClick={handleNewMessageButtonClick} text={t('New_messages')} />
                                      <JumpToRecentMessageButton
                                          visible={hasMoreNextMessages}
                                          onClick={handleJumpToRecentButtonClick}
      Severity: Major
      Found in apps/meteor/client/views/room/body/RoomBodyV2.tsx and 1 other location - About 2 days to fix
      apps/meteor/client/views/room/body/RoomBody.tsx on lines 263..308

      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 426.

      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 handleCloseFlexTab: MouseEventHandler<HTMLElement> = useCallback(
              (e): void => {
                  /*
                   * check if the element is a button or anchor
                   * it considers the role as well
      Severity: Major
      Found in apps/meteor/client/views/room/body/RoomBodyV2.tsx and 1 other location - About 7 hrs to fix
      apps/meteor/client/views/room/body/RoomBody.tsx on lines 150..180

      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 179.

      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

                                      <div className={['container-bars', uploads.length && 'show'].filter(isTruthy).join(' ')}>
                                          {uploads.map((upload) => (
                                              <UploadProgressIndicator
                                                  key={upload.id}
                                                  id={upload.id}
      Severity: Major
      Found in apps/meteor/client/views/room/body/RoomBodyV2.tsx and 1 other location - About 5 hrs to fix
      apps/meteor/client/views/room/body/RoomBody.tsx on lines 240..251

      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 148.

      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 canPreview = useMemo(() => {
              if (room && room.t !== 'c') {
                  return true;
              }
      
      
      Severity: Major
      Found in apps/meteor/client/views/room/body/RoomBodyV2.tsx and 1 other location - About 1 hr to fix
      apps/meteor/client/views/room/body/RoomBody.tsx on lines 73..87

      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 71.

      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 { handleNewMessageButtonClick, handleJumpToRecentButtonClick, handleComposerResize, hasNewMessages, newMessagesScrollRef } =
              useHasNewMessages(room._id, user?._id, atBottomRef, {
                  sendToBottom,
                  sendToBottomIfNecessary,
                  isAtBottom,
      Severity: Major
      Found in apps/meteor/client/views/room/body/RoomBodyV2.tsx and 1 other location - About 1 hr to fix
      apps/meteor/client/views/room/body/RoomBody.tsx on lines 120..125

      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 64.

      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

                      <section
                          role='presentation'
                          className={`messages-container flex-tab-main-content ${admin ? 'admin' : ''}`}
                          id={`chat-window-${room._id}`}
                          onClick={hideFlexTab && handleCloseFlexTab}
      Severity: Major
      Found in apps/meteor/client/views/room/body/RoomBodyV2.tsx and 1 other location - About 1 hr to fix
      apps/meteor/client/views/room/body/RoomBody.tsx on lines 220..322

      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 63.

      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

                                  <RoomComposer>
                                      <ComposerContainer
                                          subscription={subscription}
                                          onResize={handleComposerResize}
                                          onNavigateToPreviousMessage={handleNavigateToPreviousMessage}
      Severity: Major
      Found in apps/meteor/client/views/room/body/RoomBodyV2.tsx and 1 other location - About 1 hr to fix
      apps/meteor/client/views/room/body/RoomBody.tsx on lines 309..319

      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 58.

      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