JCMais/node-libcurl

View on GitHub

Showing 46 of 1,345 total issues

File CurlOption.ts has 1521 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: Major
Found in lib/generated/CurlOption.ts - About 4 days to fix

    File Curl.ts has 736 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: Major
    Found in lib/Curl.ts - About 1 day to fix

      Function create has 222 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const create = (defaultOptions: CurlyOptions = {}): CurlyFunction => {
        function curly<ResultData>(
          url: string,
          options: CurlyOptions = {},
        ): Promise<CurlyResult<ResultData>> {
      Severity: Major
      Found in lib/curly.ts - About 1 day to fix

        Function create has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
        Open

        const create = (defaultOptions: CurlyOptions = {}): CurlyFunction => {
          function curly<ResultData>(
            url: string,
            options: CurlyOptions = {},
          ): Promise<CurlyResult<ResultData>> {
        Severity: Minor
        Found in lib/curly.ts - About 6 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 curly has 160 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function curly<ResultData>(
            url: string,
            options: CurlyOptions = {},
          ): Promise<CurlyResult<ResultData>> {
            const curlHandle = new Curl()
        Severity: Major
        Found in lib/curly.ts - About 6 hrs to fix

          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

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

            const run = async () => {
              const curlOptionsFilePath = path.resolve(
                __dirname,
                '../lib/generated/CurlOption.ts',
              )
            Severity: Major
            Found in scripts/build-constants.js - About 4 hrs to fix

              Function createAndPerformAndCloseCurlHandlesMultiTest has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
              Open

              function createAndPerformAndCloseCurlHandlesMultiTest() {
                let i = AMOUNT_ITERATIONS_PER_RUN
                let toClose: Curl[] = []
                let toPerform: Curl[] = []
                let currentlyPerforming: Curl[] = []
              Severity: Minor
              Found in tools/brute-force-leak-test.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 createAndPerformAndCloseCurlHandlesMultiTest has 89 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function createAndPerformAndCloseCurlHandlesMultiTest() {
                let i = AMOUNT_ITERATIONS_PER_RUN
                let toClose: Curl[] = []
                let toPerform: Curl[] = []
                let currentlyPerforming: Curl[] = []
              Severity: Major
              Found in tools/brute-force-leak-test.ts - About 3 hrs to fix

                File curly.ts has 308 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 lib/curly.ts - About 3 hrs to fix

                  Curl has 28 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class Curl extends EventEmitter {
                    /**
                     * Calls [`curl_global_init()`](http://curl.haxx.se/libcurl/c/curl_global_init.html).
                     *
                     * For **flags** see the the enum {@link CurlGlobalInit | `CurlGlobalInit`}.
                  Severity: Minor
                  Found in lib/Curl.ts - About 3 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 setUploadStream has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        setUploadStream(stream: Readable | null) {
                          if (!stream) {
                            if (this.readFunctionStream) {
                              this.cleanupReadFunctionStreamEvents()
                              this.readFunctionStream = null
                      Severity: Major
                      Found in lib/Curl.ts - About 3 hrs to fix

                        Function defaultWriteFunctionStreamBased has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          protected defaultWriteFunctionStreamBased(
                            chunk: Buffer,
                            size: number,
                            nmemb: number,
                          ) {
                        Severity: Major
                        Found in lib/Curl.ts - About 2 hrs to fix

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

                            return function run() {
                              return new Promise<void>((resolve) => {
                                while (i--) {
                                  console.log('creating handler')
                          
                          
                          Severity: Major
                          Found in tools/brute-force-leak-test.ts - About 2 hrs to fix

                            Function createSetOptOverloads has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const createSetOptOverloads = (filePath, setOptReturnType = 'CurlCode') => {
                              let easyClassSetOptOverloadsData = [
                                getSetOptDefinition(
                                  'DataCallbackOptions',
                                  optionKindValueMap.dataCallback,
                            Severity: Major
                            Found in scripts/utils/createSetOptOverloads.js - About 2 hrs to fix

                              Function readFrame has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function readFrame(frame) {
                                const firstByte = frame.readUInt8(0)
                              
                                const fin = ((firstByte & 0b10000000) === 0b10000000) | 0
                                const rs1 = firstByte & 0b01000000
                              Severity: Major
                              Found in examples/21-websockets-client-helpers/index.js - About 2 hrs to fix

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

                                wss.on('connection', function connection(ws) {
                                  let pingTimeout = null
                                  lastSocket = ws
                                  ws.on('message', function (message) {
                                    console.log('ws.on - message:', message)
                                Severity: Minor
                                Found in examples/21-websockets-server/index.js - About 1 hr to fix

                                  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
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language