reactrb/reactrb

View on GitHub

Showing 22 of 108 total issues

Method render has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def render
      paths_searched = []
      if params.component_name.start_with? "::"
        paths_searched << params.component_name.gsub(/^\:\:/,"")
        component = params.component_name.gsub(/^\:\:/,"").split("::").inject(Module) { |scope, next_const| scope.const_get(next_const, false) } rescue nil
Severity: Minor
Found in lib/rails-helpers/top_level_rails_component.rb - About 4 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

Method define_param has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

      def self.define_param(name, param_type)
        if param_type == Observable
          define_method("#{name}") do
            value_for(name)
          end
Severity: Minor
Found in lib/react/component/props_wrapper.rb - 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

Method render has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

      def render(name, *args, &block)
        was_outer_most = !@not_outer_most
        @not_outer_most = true
        remove_nodes_from_args(args)
        @buffer ||= [] unless @buffer
Severity: Minor
Found in lib/react/rendering_context.rb - About 2 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

Method convert_props has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def self.convert_props(properties)
      raise "Component parameters must be a hash. Instead you sent #{properties}" unless properties.is_a? Hash
      props = {}
      properties.map do |key, value|
        if key == "class_name" && value.is_a?(Hash)
Severity: Minor
Found in lib/react/api.rb - About 2 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

Class Validator has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Validator
    attr_accessor :errors
    attr_reader :props_wrapper
    private :errors, :props_wrapper

Severity: Minor
Found in lib/react/validator.rb - About 2 hrs to fix

    Method create_native_react_class has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.create_native_react_class(type)
          raise "Provided class should define `render` method"  if !(type.method_defined? :render)
          render_fn = (type.method_defined? :_render_wrapper) ? :_render_wrapper : :render
          # this was hashing type.to_s, not sure why but .to_s does not work as it Foo::Bar::View.to_s just returns "View"
          @@component_classes[type] ||= %x{
    Severity: Major
    Found in lib/react/api.rb - About 2 hrs to fix

      Method render has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def render(component_name, props, prerender_options)
              if prerender_options.is_a?(Hash)
                if v8_runtime? && prerender_options[:context_initializer]
                  raise PrerenderError.new(component_name, props, "you must use 'therubyracer' with the prerender[:context] option") unless v8_runtime?
                else
      Severity: Minor
      Found in lib/reactive-ruby/server_rendering/contextual_renderer.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 define_param has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def self.define_param(name, param_type)
              if param_type == Observable
                define_method("#{name}") do
                  value_for(name)
                end
      Severity: Minor
      Found in lib/react/component/props_wrapper.rb - About 1 hr to fix

        Method render has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def render(name, *args, &block)
                was_outer_most = !@not_outer_most
                @not_outer_most = true
                remove_nodes_from_args(args)
                @buffer ||= [] unless @buffer
        Severity: Minor
        Found in lib/react/rendering_context.rb - About 1 hr to fix

          Method log has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.log(message, message_type = :info)
                message = [message] unless message.is_a? Array
          
                is_production = React::Config.config[:environment] == 'production'
          
          
          Severity: Minor
          Found in lib/reactive-ruby/isomorphic_helpers.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 load_context has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.load_context(unique_id = nil, name = nil)
                  # can be called on the client to force re-initialization for testing purposes
                  if !unique_id || !@context || @context.unique_id != unique_id
                    if on_opal_server?
                     `console.history = []` rescue nil
          Severity: Minor
          Found in lib/reactive-ruby/isomorphic_helpers.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 convert_props has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def self.convert_props(properties)
                raise "Component parameters must be a hash. Instead you sent #{properties}" unless properties.is_a? Hash
                props = {}
                properties.map do |key, value|
                  if key == "class_name" && value.is_a?(Hash)
          Severity: Minor
          Found in lib/react/api.rb - About 1 hr to fix

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

                def self.convert_props(properties)
                  props = self.orig_convert_props(properties)
                  props.map do |key, value|
                    if key == "ref" && value.is_a?(Proc)
                      new_proc = Proc.new do |native_inst|
            Severity: Minor
            Found in lib/react/ref_callback.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

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

                  def remove_nodes_from_args(args)
                    args[0].each do |key, value|
                      begin
                        value.as_node if value.is_a?(Element)
                      rescue Exception
            Severity: Minor
            Found in lib/react/rendering_context.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 render has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def render(container = nil, params = {}, &block)
                    if container
                      container = container.type if container.is_a? React::Element
                      define_method :render do
                        React::RenderingContext.render(container, params) { instance_eval(&block) if block }
            Severity: Minor
            Found in lib/react/component/class_methods.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 find has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.find(selector)
                selector = begin
                  selector.dom_node
                rescue
                  selector
            Severity: Minor
            Found in lib/react/ext/opal-jquery/element.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

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

              def self.render(element, container)
                %x{
                    console.error(
                      "Warning: Using deprecated behavior of `React.render`,",
                      "require \"react/top_level_render\" to get the correct behavior."
            Severity: Minor
            Found in lib/react/top_level.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

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

              def self.render(element, container)
                container = `container.$$class ? container[0] : container`
            
                cb = %x{
                  function(){
            Severity: Minor
            Found in lib/react/top_level_render.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

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

                def self.eval_native_react_component(name)
                  component = `eval(name)`
                  raise "#{name} is not defined" if `#{component} === undefined`
                  is_component_class = `#{component}.prototype !== undefined` &&
                                        (`!!#{component}.prototype.isReactComponent` ||
            Severity: Minor
            Found in lib/react/api.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

            Method render_component has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def render_component(*args)
                  @component_name = (args[0].is_a? Hash) || args.empty? ? params[:action].camelize : args.shift
                  @render_params = args.shift || {}
                  options = args[0] || {}
                  render inline: '<%= react_component @component_name, @render_params, '\
            Severity: Minor
            Found in lib/reactive-ruby/rails/controller_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

            Severity
            Category
            Status
            Source
            Language