lipp/node-jet

View on GitHub

Showing 12 of 29 total issues

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

'use strict'

import { Logger, logger } from '../log.js'
import {
  AddRequest,
Severity: Minor
Found in src/3_jet/daemon/index.ts - About 3 hrs to fix

    Function castMessage has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    export const castMessage = <T extends MethodRequest>(msg: MethodRequest): T => {
      if (!('method' in msg)) throw new invalidRequest('No method')
      const method = msg.method as EventType
      const params = msg.params
      switch (method) {
    Severity: Minor
    Found in src/3_jet/messages.ts - About 2 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 castMessage has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const castMessage = <T extends MethodRequest>(msg: MethodRequest): T => {
      if (!('method' in msg)) throw new invalidRequest('No method')
      const method = msg.method as EventType
      const params = msg.params
      switch (method) {
    Severity: Minor
    Found in src/3_jet/messages.ts - About 1 hr to fix

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

        constructor(port: number | Socket, ip = '') {
          super()
          if (port instanceof Socket) {
            this.socket = port
          } else {
      Severity: Minor
      Found in src/1_socket/message-socket.ts - About 1 hr to fix

        Function listen has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          listen() {
            this.wsServer = new WsServer({
              port: this.config.wsPort,
              server: this.config.server,
              path: this.config.wsPath,
        Severity: Minor
        Found in src/1_socket/wsserver.ts - About 1 hr to fix

          Function createPathMatcher has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const createPathMatcher = (options: FetchParams) => {
            if (!options.path) {
              return () => true
            }
            const po = options.path
          Severity: Minor
          Found in src/3_jet/daemon/path_matcher.ts - About 1 hr to fix

            Function addEventListener has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              addEventListener(
                method: string | symbol,
                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                listener: { (...args: any[]): void; call?: any }
              ) {
            Severity: Minor
            Found in src/1_socket/message-socket.ts - About 1 hr to fix

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

              var edgePos = () => {
                var x = Math.random()
                var size = 0.8
                if (Math.random() > 0.7) {
                  size = 0.4
              Severity: Minor
              Found in examples/balls/server/index.ts - About 1 hr to fix

                Function renderBall has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                var renderBall = (ball: ballEvent) => {
                  if (ball.event === 'Add') {
                    try {
                      balls[ball.path] = ball
                      svgContainer
                Severity: Minor
                Found in examples/balls/client/index.ts - About 1 hr to fix

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

                  export const createPathMatcher = (options: FetchParams) => {
                    if (!options.path) {
                      return () => true
                    }
                    const po = options.path
                  Severity: Minor
                  Found in src/3_jet/daemon/path_matcher.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

                  Avoid too many return statements within this function.
                  Open

                        return msg as T
                  Severity: Major
                  Found in src/3_jet/messages.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                          return msg as T
                    Severity: Major
                    Found in src/3_jet/messages.ts - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language