woodcrust/slim_form_object

View on GitHub

Showing 5 of 5 total issues

Method default_settings has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def default_settings
      define_singleton_method(:after_validation_form_block)    { Proc.new {} } unless respond_to?(:after_validation_form_block)
      define_singleton_method(:after_save_form_block)          { Proc.new {} } unless respond_to?(:after_save_form_block)
      define_singleton_method(:after_save_object_block)        { Proc.new { true } } unless respond_to?(:after_save_object_block)      
      define_singleton_method(:allow_object_processing_block)  { Proc.new { |data_object| true } } unless respond_to?(:allow_object_processing_block)
Severity: Minor
Found in lib/slim_form_object/processing.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 make_hash_objects_and_nested_objects has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def make_hash_objects_and_nested_objects(key_params, value_params)
      model      = get_class_of(key_params, form_object.base_modules[key_params.to_sym])
      attributes = {}
      nested     = []
      unless model
Severity: Minor
Found in lib/slim_form_object/assign.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 input_name_from_type has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def input_name_from_type(type)
          prefix = @options[:prefix] || ActionView::Helpers::DateTimeSelector::DEFAULT_PREFIX
          prefix += "[#{@options[:index]}]" if @options.has_key?(:index)

          field_name = @options[:field_name] || type
Severity: Minor
Found in lib/slim_form_object/form_helpers/extension_actionview.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 validation_objects has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def validation_objects(objects)
      objects.each do |data_object|
        next unless allow_to_validate_object?(data_object)
        set_errors( snake(data_object.model), data_object.object.errors ) unless data_object.object.valid?
        validation_objects(data_object.nested)
Severity: Minor
Found in lib/slim_form_object/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 get_reflection has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def get_reflection(class1, class2)
    class1.reflections.select do |k,v|
      if v&.options&.send(:[], :polymorphic)
        temp_reflections = class2.reflections.select do |k,v|
          v&.options&.send(:[], :polymorphic) ? false : (v.klass == class1)
Severity: Minor
Found in lib/slim_form_object/helpers.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

Severity
Category
Status
Source
Language