Anapher/Strive

View on GitHub
src/Web/WebSPA/Client/src/features/whiteboard/whiteboard-controller.ts

Summary

Maintainability
C
1 day
Test Coverage

File whiteboard-controller.ts has 305 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { fabric } from 'fabric';
import { IEvent } from 'fabric/fabric-impl';
import jsonPatch from 'fast-json-patch';
import _ from 'lodash';
import {

    WhiteboardController has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class WhiteboardController {
       private fc: fabric.Canvas;
       private tool: WhiteboardTool;
       private options: WhiteboardToolOptions;
       private unsubscribeTool: (() => void) | undefined;

      Function updateCanvas has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

         public updateCanvas(canvas: WhiteboardCanvas) {
            canvas = this.pathCache.preprocess(canvas); // paths must be unpacked from point array to svg paths
            const newVersion = _.maxBy(canvas.objects, (x) => x.version)?.version ?? 0;
      
            if (!this.currentVersion) {

        Function updateCanvas has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

           public updateCanvas(canvas: WhiteboardCanvas) {
              canvas = this.pathCache.preprocess(canvas); // paths must be unpacked from point array to svg paths
              const newVersion = _.maxBy(canvas.objects, (x) => x.version)?.version ?? 0;
        
              if (!this.currentVersion) {

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

           private onObjectRemoved(e: IEvent) {
              if (!e.target) return;
              const deletionId = (e.target as any).deletionId;
        
              if (deletionId) {
        Severity: Minor
        Found in src/Web/WebSPA/Client/src/features/whiteboard/whiteboard-controller.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 onLiveUpdateReceived has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

           private onLiveUpdateReceived(update: WhiteboardLiveUpdateDto) {
              if (!this.currentCanvas) return;
        
              if (update.action.type === 'end') {
                 this.removeLiveUpdate(update.participantId);
        Severity: Minor
        Found in src/Web/WebSPA/Client/src/features/whiteboard/whiteboard-controller.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

        There are no issues that match your filters.

        Category
        Status