RocketChat/Rocket.Chat

View on GitHub
apps/meteor/client/views/meet/CallPage.tsx

Summary

Maintainability
D
2 days
Test Coverage

Function CallPage has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

const CallPage = ({
    roomId,
    visitorToken,
    visitorId,
    status,
Severity: Minor
Found in apps/meteor/client/views/meet/CallPage.tsx - About 7 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 CallPage.tsx has 375 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Box, Flex, ButtonGroup, Button, Icon } from '@rocket.chat/fuselage';
import { UserAvatar } from '@rocket.chat/ui-avatar';
import { useTranslation, useStream } from '@rocket.chat/ui-contexts';
import moment from 'moment';
import React, { useEffect, useState } from 'react';
Severity: Minor
Found in apps/meteor/client/views/meet/CallPage.tsx - About 5 hrs to fix

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

    const CallPage = ({
        roomId,
        visitorToken,
        visitorId,
        status,
    Severity: Major
    Found in apps/meteor/client/views/meet/CallPage.tsx and 12 other locations - About 55 mins to fix
    apps/meteor/app/api/server/lib/users.ts on lines 135..218
    apps/meteor/client/components/message/content/ThreadMetrics.tsx on lines 26..81
    apps/meteor/client/components/message/content/attachments/file/AudioAttachment.tsx on lines 10..30
    apps/meteor/client/components/message/content/attachments/file/VideoAttachment.tsx on lines 11..36
    apps/meteor/client/sidebarv2/Item/Condensed.tsx on lines 22..48
    apps/meteor/client/sidebarv2/Item/Medium.tsx on lines 20..46
    apps/meteor/client/sidebarv2/header/CreateTeamModal.tsx on lines 125..161
    apps/meteor/client/views/admin/settings/Setting/inputs/BooleanSettingInput.tsx on lines 10..45
    apps/meteor/client/views/marketplace/AppsPage/AppsPageContentBody.tsx on lines 26..68
    apps/meteor/server/services/federation/application/room/input/RoomReceiverDto.ts on lines 110..128
    apps/meteor/server/services/federation/application/room/input/RoomReceiverDto.ts on lines 218..237
    packages/livechat/src/components/Composer/index.tsx on lines 267..293

    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

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

                    <Box
                        position='absolute'
                        zIndex={1}
                        style={{
                            top: '5%',
    Severity: Minor
    Found in apps/meteor/client/views/meet/CallPage.tsx and 1 other location - About 45 mins to fix
    apps/meteor/client/views/meet/CallPage.tsx on lines 328..347

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

    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

                            <Box
                                position='absolute'
                                zIndex={1}
                                style={{
                                    top: '5%',
    Severity: Minor
    Found in apps/meteor/client/views/meet/CallPage.tsx and 1 other location - About 45 mins to fix
    apps/meteor/client/views/meet/CallPage.tsx on lines 197..227

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

    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

                            <Button
                                id='camera'
                                square
                                title={isCameraOn ? t('Turn_off_video') : t('Turn_on_video')}
                                onClick={(): void => toggleButton('camera')}
    Severity: Minor
    Found in apps/meteor/client/views/meet/CallPage.tsx and 1 other location - About 40 mins to fix
    apps/meteor/client/views/meet/CallPage.tsx on lines 236..245

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

    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

                            <Button
                                id='mic'
                                square
                                title={isMicOn ? t('Mute_microphone') : t('Unmute_microphone')}
                                onClick={(): any => toggleButton('mic')}
    Severity: Minor
    Found in apps/meteor/client/views/meet/CallPage.tsx and 1 other location - About 40 mins to fix
    apps/meteor/client/views/meet/CallPage.tsx on lines 246..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 48.

    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

                    webrtcInstance.startCall({
                        audio: true,
                        video: {
                            width: { ideal: 1920 },
                            height: { ideal: 1080 },
    Severity: Minor
    Found in apps/meteor/client/views/meet/CallPage.tsx and 1 other location - About 30 mins to fix
    apps/meteor/client/views/meet/CallPage.tsx on lines 151..157

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

    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

                                webrtcInstance.startCall({
                                    audio: true,
                                    video: {
                                        width: { ideal: 1920 },
                                        height: { ideal: 1080 },
    Severity: Minor
    Found in apps/meteor/client/views/meet/CallPage.tsx and 1 other location - About 30 mins to fix
    apps/meteor/client/views/meet/CallPage.tsx on lines 133..139

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

    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