JCMais/node-libcurl

View on GitHub
examples/21-websockets-client.js

Summary

Maintainability
C
1 day
Test Coverage

Function onConnected has 144 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const onConnected = (easyHandle) => {
  try {
    state.connectionOpen = true

    // We are using this callback to listen for changes in the socket.
Severity: Major
Found in examples/21-websockets-client.js - About 5 hrs to fix

    File 21-websockets-client.js has 305 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * Copyright (c) Jonathan Cardoso Machado. All Rights Reserved.
     *
     * This source code is licensed under the MIT license found in the
     * LICENSE file in the root directory of this source tree.
    Severity: Minor
    Found in examples/21-websockets-client.js - About 3 hrs to fix

      Function sendData has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      function sendData(handle, buffer) {
        let bufferToSend = buffer
        while (bufferToSend) {
          const { code, bytesSent } = handle.send(bufferToSend)
      
      
      Severity: Minor
      Found in examples/21-websockets-client.js - 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 receiveData has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      function receiveData(handle, bufferSize = 32 * 1024) {
        const buffers = []
      
        // eslint-disable-next-line no-constant-condition
        while (true) {
      Severity: Minor
      Found in examples/21-websockets-client.js - 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

      There are no issues that match your filters.

      Category