JCMais/node-libcurl

View on GitHub

Showing 1,345 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

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

                                    ? [
                                        `export const ${variableName}CamelCaseMap = {`,
                                        ...constants.map(
                                          (option) =>
                                            `${getDescriptionCommentForOption(option)}${
                                Severity: Major
                                Found in scripts/utils/createConstantsFile.js and 1 other location - About 1 hr to fix
                                scripts/utils/createConstantsFile.js on lines 25..40

                                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 70.

                                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

                                  const constantsObj = [
                                    `
                                    /**
                                     * @public
                                     */
                                Severity: Major
                                Found in scripts/utils/createConstantsFile.js and 1 other location - About 1 hr to fix
                                scripts/utils/createConstantsFile.js on lines 43..52

                                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 70.

                                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

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