JCMais/node-libcurl

View on GitHub

Showing 1,345 of 1,345 total issues

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

  onEnd() {
    const isStreamResponse = !!(this.features & CurlFeature.StreamResponse)
    const isDataStorageEnabled =
      !isStreamResponse && !(this.features & CurlFeature.NoDataStorage)
    const isDataParsingEnabled =
Severity: Minor
Found in lib/Curl.ts - About 1 hr to fix

    Function sendProtoBufMessage has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    async function sendProtoBufMessage(url, message) {
      const curl = new Curl()
      curl.setOpt('URL', url)
      // enable if you want to see even more debug info
      // curl.setOpt('VERBOSE', true)
    Severity: Minor
    Found in examples/19-binary-data-protobuf.js - About 1 hr to fix

      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

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                            handle.setOpt(Curl.option.WRITEFUNCTION, function (buf, size, nmemb) {
                              console.log('WRITEFUNCTION: ')
                              console.log(arguments)
                            
                              return size * nmemb
                            Severity: Major
                            Found in examples/02-easy.js and 1 other location - About 1 hr to fix
                            examples/02-easy.js on lines 23..28

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 56.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                            handle.setOpt(Curl.option.HEADERFUNCTION, function (buf, size, nmemb) {
                              console.log('HEADERFUNCTION: ')
                              console.log(arguments)
                            
                              return size * nmemb
                            Severity: Major
                            Found in examples/02-easy.js and 1 other location - About 1 hr to fix
                            examples/02-easy.js on lines 32..37

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 56.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Severity
                            Category
                            Status
                            Source
                            Language