shakacode/react_on_rails

View on GitHub

Showing 44 of 44 total issues

Method add_js_dependencies has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def add_js_dependencies
        major_minor_patch_only = /\A\d+\.\d+\.\d+\z/
        if ReactOnRails::VERSION.match?(major_minor_patch_only)
          package_json.manager.add(["react-on-rails@#{ReactOnRails::VERSION}"])
        else
Severity: Minor
Found in lib/generators/react_on_rails/base_generator.rb - About 1 hr to fix

    Method check_autobundling_requirements has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_autobundling_requirements
          raise_missing_components_subdirectory if auto_load_bundle && !components_subdirectory.present?
          return unless components_subdirectory.present?
    
          ReactOnRails::PackerUtils.raise_shakapacker_not_installed unless ReactOnRails::PackerUtils.using_packer?
    Severity: Minor
    Found in lib/react_on_rails/configuration.rb - 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

    Method server_rendered_react_component has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def server_rendered_react_component(render_options)
          return { "html" => "", "consoleReplayScript" => "" } unless render_options.prerender
    
          react_component_name = render_options.react_component_name
          props = render_options.props
    Severity: Minor
    Found in lib/react_on_rails/helper.rb - About 1 hr to fix

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

      function renderInit(): void {
        // Install listeners when running on the client (browser).
        // We must do this check for turbolinks AFTER the document is loaded because we load the
        // Webpack bundles first.
        if ((!turbolinksInstalled() || !turbolinksSupported()) && !turboInstalled()) {
      Severity: Minor
      Found in node_package/src/clientStartup.ts - About 1 hr to fix

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

        export function consoleReplay(customConsoleHistory: typeof console['history'] | undefined = undefined): string {
          // console.history is a global polyfill used in server rendering.
          const consoleHistory = customConsoleHistory ?? console.history;
        
          if (!(Array.isArray(consoleHistory))) {
        Severity: Minor
        Found in node_package/src/buildConsoleReplay.ts - About 1 hr to fix

          Method reset_pool_if_server_bundle_was_modified has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                  def reset_pool_if_server_bundle_was_modified
                    return unless ReactOnRails.configuration.development_mode
          
                    if ReactOnRails::Utils.server_bundle_path_is_http?
                      return if @server_bundle_url == ReactOnRails::Utils.server_bundle_js_file_path
          Severity: Minor
          Found in lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb - 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 reactOnRailsPageUnloaded has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function reactOnRailsPageUnloaded(): void {
            debugTurbolinks('reactOnRailsPageUnloaded');
            if (supportsRootApi) {
              const { roots } = findContext();
          
          
          Severity: Minor
          Found in node_package/src/clientStartup.ts - 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

          Method load_pack_for_generated_component has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def load_pack_for_generated_component(react_component_name, render_options)
                return unless render_options.auto_load_bundle
          
                ReactOnRails::PackerUtils.raise_nested_entries_disabled unless ReactOnRails::PackerUtils.nested_entries?
                if Rails.env.development?
          Severity: Minor
          Found in lib/react_on_rails/helper.rb - 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

          Method invoke_and_exit_if_failed has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.invoke_and_exit_if_failed(cmd, failure_message)
                stdout, stderr, status = Open3.capture3(cmd)
                unless status.success?
                  stdout_msg = stdout.present? ? "\nstdout:\n#{stdout.strip}\n" : ""
                  stderr_msg = stderr.present? ? "\nstderr:\n#{stderr.strip}\n" : ""
          Severity: Minor
          Found in lib/react_on_rails/utils.rb - 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

          Method initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def initialize(node_modules_location: nil, server_bundle_js_file: nil, prerender: nil,
                             replay_console: nil, make_generated_server_bundle_the_entrypoint: nil,
                             trace: nil, development_mode: nil,
                             logging_on_server: nil, server_renderer_pool_size: nil,
                             server_renderer_timeout: nil, raise_on_prerender_error: true,
          Severity: Minor
          Found in lib/react_on_rails/configuration.rb - 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

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

              if (typeof newOptions.traceTurbolinks !== 'undefined') {
                this.options.traceTurbolinks = newOptions.traceTurbolinks;
          
                // eslint-disable-next-line no-param-reassign
                delete newOptions.traceTurbolinks;
          Severity: Minor
          Found in node_package/src/ReactOnRails.ts and 1 other location - About 40 mins to fix
          node_package/src/ReactOnRails.ts on lines 114..119

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

          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

              if (typeof newOptions.turbo !== 'undefined') {
                this.options.turbo = newOptions.turbo;
          
                // eslint-disable-next-line no-param-reassign
                delete newOptions.turbo;
          Severity: Minor
          Found in node_package/src/ReactOnRails.ts and 1 other location - About 40 mins to fix
          node_package/src/ReactOnRails.ts on lines 107..112

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

          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

          Method calc_message has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def calc_message(component_name, console_messages, err, js_code, props)
          Severity: Minor
          Found in lib/react_on_rails/prerender_error.rb - About 35 mins to fix

            Method render has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def render(props_string, rails_context, redux_stores, react_component_name, render_options)
            Severity: Minor
            Found in lib/react_on_rails/server_rendering_js_code.rb - About 35 mins to fix

              Function delegateToRenderer has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                componentObj: RegisteredComponent,
                props: Record<string, string>,
                railsContext: RailsContext,
                domNodeId: string,
                trace: boolean,
              Severity: Minor
              Found in node_package/src/clientStartup.ts - About 35 mins to fix

                Method symbolize_keys has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def symbolize_keys(hash)
                      hash.each_with_object({}) do |(key, value), new_hash|
                        new_key = key.is_a?(String) ? key.to_sym : key
                        new_value = value.is_a?(Hash) ? symbolize_keys(value) : value
                        new_hash[new_key] = new_value
                Severity: Minor
                Found in rakelib/task_helpers.rb - About 35 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

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

                    if (reMatchShouldNotBeGeneratorError.test(e.message)) {
                      msg += `${shouldBeRenderFunctionError}\n\n`;
                      console.error(shouldBeRenderFunctionError);
                    }
                Severity: Minor
                Found in node_package/src/handleError.ts and 1 other location - About 35 mins to fix
                node_package/src/handleError.ts on lines 19..22

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

                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

                    if (reMatchShouldBeGeneratorError.test(e.message)) {
                      msg += `${shouldBeRenderFunctionError}\n\n`;
                      console.error(shouldBeRenderFunctionError);
                    }
                Severity: Minor
                Found in node_package/src/handleError.ts and 1 other location - About 35 mins to fix
                node_package/src/handleError.ts on lines 30..33

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

                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

                  } else if (turbolinksVersion5()) {
                    debugTurbolinks(
                      'USING TURBOLINKS 5: document added event listeners ' +
                      'turbolinks:before-render and turbolinks:render.');
                    document.addEventListener('turbolinks:before-render', reactOnRailsPageUnloaded);
                Severity: Minor
                Found in node_package/src/clientStartup.ts and 1 other location - About 30 mins to fix
                node_package/src/clientStartup.ts on lines 283..303

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

                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

                  if (turboInstalled()) {
                    debugTurbolinks(
                      'USING TURBO: document added event listeners ' +
                      'turbo:before-render and turbo:render.');
                    document.addEventListener('turbo:before-render', reactOnRailsPageUnloaded);
                Severity: Minor
                Found in node_package/src/clientStartup.ts and 1 other location - About 30 mins to fix
                node_package/src/clientStartup.ts on lines 290..303

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

                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