agensdev/wardrobe

View on GitHub

Showing 33 of 559 total issues

Method _present has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

        def _present(attributes: nil, **args)
          options = self.class.plugin_store[:presenter][:options].merge(args)
          result = {}
          # TODO: Optimize!
          _attribute_store.store.each do |key, atr|
Severity: Minor
Found in lib/wardrobe/plugins/presenter.rb - About 5 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 _create_configurable_set_method has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

        def _create_configurable_set_method(name, setter_name, **opts)
          class_methods_module do
            define_method(setter_name) do |*args, **kargs, &blk|
              klass = self
              opts[:before_update].call(klass) if opts[:before_update]
Severity: Minor
Found in lib/wardrobe/plugins/configurable.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 create_option_methods has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def create_option_methods(config)
      config.option_store.each do |option|
        define_singleton_method(option.name) do |&blk|
          if blk
            if options[option.name].nil? && option.options[:init]
Severity: Minor
Found in lib/wardrobe/attribute.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 add_to_ordered_array has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def add_to_ordered_array(new_item)
      if @order.empty?
        @order << new_item
      else
        # We have to figure out where to place the item.
Severity: Minor
Found in lib/wardrobe/middleware_registry.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 _value_changed? has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

        def _value_changed?(value, ref)
          if ref == :wardrobe_instance
            if value._changed?
              _dirty!
              _dirty_tracker_dirty_sub_instances << value
Severity: Minor
Found in lib/wardrobe/plugins/dirty_tracker.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 merge_options has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def merge_options(other)
      merged_options = options.dup
      other.each do |key, value|
        next if merged_options[key] == value
        if merged_options[key]
Severity: Minor
Found in lib/wardrobe/attribute.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 run has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

        def run(report = true)
          if validation && validation.any?
            validate(validation, report)
          elsif value.respond_to?(:_validate!)
            if value._validation_errors.any?
Severity: Minor
Found in lib/wardrobe/plugins/validation/validator.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 merge has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def merge(other, calling_object)
      if frozen?
        dup.merge(other, calling_object)
      else
        (other.stores.keys - stores.keys).each do |name|
Severity: Minor
Found in lib/wardrobe/config.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 _present has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def _present(attributes: nil, **args)
          options = self.class.plugin_store[:presenter][:options].merge(args)
          result = {}
          # TODO: Optimize!
          _attribute_store.store.each do |key, atr|
Severity: Minor
Found in lib/wardrobe/plugins/presenter.rb - About 1 hr to fix

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

            def validate(validation, report)
              if validation.type == :special
                send(*validation.args, report)
              else
                begin
    Severity: Minor
    Found in lib/wardrobe/plugins/validation/validator.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 create_option_methods has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def create_option_methods(config)
          config.option_store.each do |option|
            define_singleton_method(option.name) do |&blk|
              if blk
                if options[option.name].nil? && option.options[:init]
    Severity: Minor
    Found in lib/wardrobe/attribute.rb - About 1 hr to fix

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

          def add_to_ordered_array(new_item)
            if @order.empty?
              @order << new_item
            else
              # We have to figure out where to place the item.
      Severity: Minor
      Found in lib/wardrobe/middleware_registry.rb - About 1 hr to fix

        Method _create_configurable_set_method has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def _create_configurable_set_method(name, setter_name, **opts)
                  class_methods_module do
                    define_method(setter_name) do |*args, **kargs, &blk|
                      klass = self
                      opts[:before_update].call(klass) if opts[:before_update]
        Severity: Minor
        Found in lib/wardrobe/plugins/configurable.rb - About 1 hr to fix

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

                    def type?(predicate)
                      return if self.is_a?(predicate)
                      if predicate == Wardrobe::Boolean
                        return if self.is_a?(TrueClass) || self.is_a?(FalseClass)
                        "must be a TrueClass or FalseClass"
          Severity: Minor
          Found in lib/wardrobe/plugins/validation/refinements/object.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 each_key? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def each_key?(validation, report)
                    errors = {}
                    value.each do |key, _|
                      result = Validator.new(key, nil, nil, validation).run(false)
                      result = [result] unless result.is_a?(Array)
          Severity: Minor
          Found in lib/wardrobe/plugins/validation/validator.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 each_value? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def each_value?(validation, report)
                    errors = {}
                    value.each do |key, val|
                      result = Validator.new(val, nil, nil, validation).run(false)
                      result = [result] unless result.is_a?(Array)
          Severity: Minor
          Found in lib/wardrobe/plugins/validation/validator.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 add has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def add(name, klass, defining_object, config, **args, &blk)
          Severity: Minor
          Found in lib/wardrobe/attribute_store.rb - About 45 mins to fix

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

                    def each?(validation, report)
                      errors = {}
                      value.each_with_index do |item, index|
                        result = Validator.new(item, nil, nil, validation).run(false)
                        result = [result] unless result.is_a?(Array)
            Severity: Minor
            Found in lib/wardrobe/plugins/validation/validator.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 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def initialize(name, klass, defining_object, config, **options)
            Severity: Minor
            Found in lib/wardrobe/attribute.rb - About 35 mins to fix

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

                      def update_hash(name, klass, hash_key, hash_klass, &blk)
              Severity: Minor
              Found in lib/wardrobe/plugins/configurable/configurable_store.rb - About 35 mins to fix
                Severity
                Category
                Status
                Source
                Language