peers/peerjs-server

View on GitHub

Showing 6 of 10 total issues

Function TransmissionHandler has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

export const TransmissionHandler = ({
    realm,
}: {
    realm: IRealm;
}): ((client: IClient | undefined, message: IMessage) => boolean) => {
Severity: Minor
Found in src/messageHandler/handlers/transmission/index.ts - About 3 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

Function constructor has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    constructor(
        realm: IRealm,
        private readonly handlersRegistry: IHandlersRegistry = new HandlersRegistry(),
    ) {
        const transmissionHandler: Handler = TransmissionHandler({ realm });
Severity: Minor
Found in src/messageHandler/index.ts - About 1 hr to fix

    Function handle has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        const handle = (client: IClient | undefined, message: IMessage) => {
            const type = message.type;
            const srcId = message.src;
            const dstId = message.dst;
    
    
    Severity: Minor
    Found in src/messageHandler/handlers/transmission/index.ts - About 1 hr to fix

      Function _onSocketConnection has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private _onSocketConnection(socket: WebSocket, req: IncomingMessage): void {
              // An unhandled socket error might crash the server. Handle it first.
              socket.on("error", (error) => {
                  this._onSocketError(error);
              });
      Severity: Minor
      Found in src/services/webSocketServer/index.ts - About 1 hr to fix

        Function pruneOutstanding has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            private pruneOutstanding(): void {
                const destinationClientsIds = this.realm.getClientsIdsWithQueue();
        
                const now = new Date().getTime();
                const maxDiff = this.config.expire_timeout;
        Severity: Minor
        Found in src/services/messagesExpire/index.ts - About 1 hr 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 _onSocketConnection has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private _onSocketConnection(socket: WebSocket, req: IncomingMessage): void {
                // An unhandled socket error might crash the server. Handle it first.
                socket.on("error", (error) => {
                    this._onSocketError(error);
                });
        Severity: Minor
        Found in src/services/webSocketServer/index.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

        Severity
        Category
        Status
        Source
        Language