JCMais/node-libcurl

View on GitHub

Showing 46 of 1,345 total issues

Function defaultWriteFunctionStreamBased has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  protected defaultWriteFunctionStreamBased(
    chunk: Buffer,
    size: number,
    nmemb: number,
  ) {
Severity: Minor
Found in lib/Curl.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 parseHeaders has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export function parseHeaders(headersString: string): HeaderInfo[] {
  const headers = headersString.split(/\r?\n|\r/g)
  const len = headers.length
  const result = []

Severity: Minor
Found in lib/parseHeaders.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 readFrame has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function readFrame(frame) {
  const firstByte = frame.readUInt8(0)

  const fin = ((firstByte & 0b10000000) === 0b10000000) | 0
  const rs1 = firstByte & 0b01000000
Severity: Minor
Found in examples/21-websockets-client-helpers/index.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 cb has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function cb(code) {
  const { data } = this
  const now = Date.now()

  let shouldWrite = false
Severity: Minor
Found in examples/stress-test.js - About 1 hr to fix

    Function attachPackageToRelease has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    async function attachPackageToRelease(pckg, release) {
      const packagePath = path.resolve(pckg)
    
      if (!fs.existsSync(packagePath)) {
        throw new Error(
    Severity: Minor
    Found in scripts/module-packaging.js - About 1 hr 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

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

      function fileIsComing(fileInfo, remains) {
        console.log(
          util.format(
            'Remaining entries: %d / Current: %s / Size: %d - ',
            remains,
      Severity: Minor
      Found in examples/16-ftp-wildcard-fnmatch.js - About 1 hr to fix

        Function run has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const run = async () => {
          try {
            // there are many ways to use the curly.* functions
            let response = null
        
        
        Severity: Minor
        Found in examples/03-curly.js - About 1 hr to fix

          Function removePackageFromRelease has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          async function removePackageFromRelease(packageToDelete, release) {
            const packageToDeleteName = path.basename(packageToDelete)
          
            let found = false
          
          
          Severity: Minor
          Found in scripts/module-packaging.js - About 1 hr to fix

            Function createAndCloseCurlHandlesTest has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function createAndCloseCurlHandlesTest() {
              let i = 0
              const shouldClose = iteration++ % 2
              const postData = [
                {
            Severity: Minor
            Found in tools/brute-force-leak-test.ts - About 1 hr to fix

              Function parseHeaders has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function parseHeaders(headersString: string): HeaderInfo[] {
                const headers = headersString.split(/\r?\n|\r/g)
                const len = headers.length
                const result = []
              
              
              Severity: Minor
              Found in lib/parseHeaders.ts - About 1 hr to fix

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

                const run = async () => {
                  // the files we are going to read and write
                  const uploadFilePath = './100mb.in.data.zip'
                  const downloadFilePath = './100mb.out.data.zip'
                
                
                Severity: Minor
                Found in examples/03-curly-streams.js - About 1 hr to fix

                  Function retrieveWinDeps has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const retrieveWinDeps = async () => {
                    const fileExists = fs.existsSync(fileWithDepsTag)
                  
                    if (!fileExists && !envCurlForWindowsDepsVersionTag) {
                      console.error(
                  Severity: Minor
                  Found in scripts/retrieve-win-deps.js - About 1 hr to fix

                    Function packFrame has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function packFrame(data, type) {
                      const length = data.length
                      // initial offset is 6
                      // 1 byte for the first part (fin, rsvn, opcode)
                      // 1 byte for the mask and payload length(first part)
                    Severity: Minor
                    Found in examples/21-websockets-client-helpers/index.js - About 1 hr to fix

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

                      const debugCallback = (infoType, content) => {
                        let text = ''
                      
                        const contentString = content.toString('utf8')
                      
                      
                      Severity: Minor
                      Found in examples/12-debug-callback.js - About 1 hr to fix

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

                        function gracefulShutdown(server, options = {}) {
                          const {
                            gracePeriod = process.env.GRACEFUL_SHUTDOWN_GRACE_PERIOD_MS || 5000,
                            onShutdown = noopFn,
                          } = options
                        Severity: Minor
                        Found in examples/19-binary-data-protobuf/gracefulShutdown.js - About 1 hr to fix

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

                          async function replaceTokensOnFiles(dir) {
                            const filesToCheck = [
                              'libssh2.gyp',
                              'openssl/openssl.gyp',
                              'cares/cares.gyp',
                          Severity: Minor
                          Found in scripts/retrieve-win-deps.js - About 1 hr to fix

                            Function setOpt has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                              setOpt(optionIdOrName: never, optionValue: never): this {
                                // special case for WRITEFUNCTION and HEADERFUNCTION callbacks
                                //  since if they are set back to null, we must restore the default callback.
                                let value = optionValue
                                if (
                            Severity: Minor
                            Found in lib/Curl.ts - About 55 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 retrieveWinDeps has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const retrieveWinDeps = async () => {
                              const fileExists = fs.existsSync(fileWithDepsTag)
                            
                              if (!fileExists && !envCurlForWindowsDepsVersionTag) {
                                console.error(
                            Severity: Minor
                            Found in scripts/retrieve-win-deps.js - About 45 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