shakacode/react_on_rails

View on GitHub

Showing 36 of 44 total issues

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

        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

              Avoid too many return statements within this function.
              Open

                return React.createElement(component as ReactComponent, props);
              Severity: Major
              Found in node_package/src/createReactOutput.ts - About 30 mins to fix

                Function renderInit has a Cognitive Complexity of 6 (exceeds 5 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 25 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 json_safe_and_pretty has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def json_safe_and_pretty(hash_or_string)
                      return "{}" if hash_or_string.nil?
                
                      unless hash_or_string.is_a?(String) || hash_or_string.is_a?(Hash)
                        raise ReactOnRails::Error, "#{__method__} only accepts String or Hash as argument " \
                Severity: Minor
                Found in lib/react_on_rails/helper.rb - About 25 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 server_bundle_js_file_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.server_bundle_js_file_path
                      # Either:
                      # 1. Using same bundle for both server and client, so server bundle will be hashed in manifest
                      # 2. Using a different bundle (different Webpack config), so file is not hashed, and
                      #    bundle_js_path will throw so the default path is used without a hash.
                Severity: Minor
                Found in lib/react_on_rails/utils.rb - About 25 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