RocketChat/Rocket.Chat

View on GitHub
apps/meteor/client/lib/VideoConfManager.ts

Summary

Maintainability
F
3 days
Test Coverage

File VideoConfManager.ts has 583 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import type { IRoom, IUser } from '@rocket.chat/core-typings';
import { Emitter } from '@rocket.chat/emitter';
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';

Severity: Major
Found in apps/meteor/client/lib/VideoConfManager.ts - About 1 day to fix

    VideoConfManager has 41 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export const VideoConfManager = new (class VideoConfManager extends Emitter<VideoConfEvents> {
        private userId: string | undefined;
    
        private currentCallHandler: ReturnType<typeof setTimeout> | undefined;
    
    
    Severity: Minor
    Found in apps/meteor/client/lib/VideoConfManager.ts - About 5 hrs to fix

      Function acceptIncomingCall has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public acceptIncomingCall(callId: string): void {
              const callData = this.incomingDirectCalls.get(callId);
              if (!callData) {
                  throw new Error('Unable to find accepted call information.');
              }
      Severity: Minor
      Found in apps/meteor/client/lib/VideoConfManager.ts - About 1 hr to fix

        Function joinCall has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public async joinCall(callId: string): Promise<void> {
                debug && console.log(`[VideoConf] Joining call ${callId}.`);
        
                if (this.incomingDirectCalls.has(callId)) {
                    const data = this.incomingDirectCalls.get(callId);
        Severity: Minor
        Found in apps/meteor/client/lib/VideoConfManager.ts - About 1 hr to fix

          Function onDirectCallEnded has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private onDirectCallEnded(params: DirectCallParams): void {
                  if (!params.callId) {
                      debug && console.log(`[VideoConf] Invalid 'video-conference.end' event received: ${params.callId}, ${params.uid}.`);
                      return;
                  }
          Severity: Minor
          Found in apps/meteor/client/lib/VideoConfManager.ts - About 1 hr to fix

            Function startCall has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public async startCall(roomId: IRoom['_id'], title?: string): Promise<void> {
                    if (!this.userId || this.isBusy()) {
                        throw new Error('Video manager is busy.');
                    }
            
            
            Severity: Minor
            Found in apps/meteor/client/lib/VideoConfManager.ts - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                      if (!params || typeof params !== 'object' || !params.callId || !params.uid || !params.rid) {
                          debug && console.error('[VideoConf] Invalid params received.');
                          return;
                      }
              Severity: Major
              Found in apps/meteor/client/lib/VideoConfManager.ts - About 40 mins to fix

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

                    private async onVideoConfNotification({ action, params }: { action: string; params: DirectCallParams }): Promise<void> {
                        if (!action || typeof action !== 'string') {
                            debug && console.error('[VideoConf] Invalid action received.');
                            return;
                        }
                Severity: Minor
                Found in apps/meteor/client/lib/VideoConfManager.ts - 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 callUser has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    private async callUser({ uid, rid, callId }: DirectCallParams): Promise<void> {
                        if (this.currentCallHandler || this.currentCallData) {
                            throw new Error('Video Conference State Error.');
                        }
                
                
                Severity: Minor
                Found in apps/meteor/client/lib/VideoConfManager.ts - 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 onDirectCallJoined has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    private onDirectCallJoined(params: DirectCallParams): void {
                        if (!params.callId) {
                            debug && console.log(`[VideoConf] Invalid 'video-conference.join' event received: ${params.callId}, ${params.uid}.`);
                            return;
                        }
                Severity: Minor
                Found in apps/meteor/client/lib/VideoConfManager.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 joinCall has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public async joinCall(callId: string): Promise<void> {
                        debug && console.log(`[VideoConf] Joining call ${callId}.`);
                
                        if (this.incomingDirectCalls.has(callId)) {
                            const data = this.incomingDirectCalls.get(callId);
                Severity: Minor
                Found in apps/meteor/client/lib/VideoConfManager.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 onDirectCallAccepted has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    private onDirectCallAccepted(params: DirectCallParams, skipConfirmation = false): void {
                        if (!params.callId || params.callId !== this.currentCallData?.callId) {
                            debug && console.log(`[VideoConf] User ${params.uid} has accepted a call ${params.callId} from us, but we're not calling.`);
                            return;
                        }
                Severity: Minor
                Found in apps/meteor/client/lib/VideoConfManager.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 onDirectCallEnded has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    private onDirectCallEnded(params: DirectCallParams): void {
                        if (!params.callId) {
                            debug && console.log(`[VideoConf] Invalid 'video-conference.end' event received: ${params.callId}, ${params.uid}.`);
                            return;
                        }
                Severity: Minor
                Found in apps/meteor/client/lib/VideoConfManager.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

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

                        if (!params.callId || params.callId !== this.currentCallData?.callId) {
                            debug && console.log(`[VideoConf] User ${params.uid} has accepted a call ${params.callId} from us, but we're not calling.`);
                            return;
                        }
                Severity: Major
                Found in apps/meteor/client/lib/VideoConfManager.ts and 1 other location - About 1 hr to fix
                apps/meteor/client/lib/VideoConfManager.ts on lines 741..744

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

                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

                        if (!params.callId || params.callId !== this.currentCallData?.callId) {
                            debug && console.log(`[VideoConf] User ${params.uid} has rejected a call ${params.callId} from us, but we're not calling.`);
                            return;
                        }
                Severity: Major
                Found in apps/meteor/client/lib/VideoConfManager.ts and 1 other location - About 1 hr to fix
                apps/meteor/client/lib/VideoConfManager.ts on lines 638..641

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

                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

                        if (!params.callId) {
                            debug && console.log(`[VideoConf] Invalid 'video-conference.end' event received: ${params.callId}, ${params.uid}.`);
                            return;
                        }
                Severity: Minor
                Found in apps/meteor/client/lib/VideoConfManager.ts and 1 other location - About 45 mins to fix
                apps/meteor/client/lib/VideoConfManager.ts on lines 680..683

                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

                        if (!params.callId) {
                            debug && console.log(`[VideoConf] Invalid 'video-conference.join' event received: ${params.callId}, ${params.uid}.`);
                            return;
                        }
                Severity: Minor
                Found in apps/meteor/client/lib/VideoConfManager.ts and 1 other location - About 45 mins to fix
                apps/meteor/client/lib/VideoConfManager.ts on lines 706..709

                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

                        this.userId && this.notifyUser(callData.uid, 'accepted', { callId, uid: this.userId, rid: callData.rid });
                Severity: Minor
                Found in apps/meteor/client/lib/VideoConfManager.ts and 1 other location - About 40 mins to fix
                apps/meteor/client/lib/VideoConfManager.ts on lines 242..242

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

                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

                        this.userId && this.notifyUser(callData.uid, 'rejected', { callId, uid: this.userId, rid: callData.rid });
                Severity: Minor
                Found in apps/meteor/client/lib/VideoConfManager.ts and 1 other location - About 40 mins to fix
                apps/meteor/client/lib/VideoConfManager.ts on lines 231..231

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

                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

                        this.incomingDirectCalls.set(callId, {
                            callId,
                            uid,
                            rid,
                            timeout: this.createAbortTimeout(callId),
                Severity: Minor
                Found in apps/meteor/client/lib/VideoConfManager.ts and 1 other location - About 30 mins to fix
                apps/meteor/client/views/admin/workspace/VersionCard/getVersionStatus.spec.ts on lines 113..185

                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