padrino/padrino-framework

View on GitHub
padrino-helpers/lib/padrino-helpers/form_builder/abstract_form_builder.rb

Summary

Maintainability
C
1 day
Test Coverage

Class AbstractFormBuilder has 48 methods (exceeds 20 allowed). Consider refactoring.
Open

      class AbstractFormBuilder
        attr_accessor :template, :object, :multipart
        attr_reader :namespace, :is_nested, :parent_form, :nested_index, :attributes_name, :model_name

        def initialize(template, object, options={})

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

            def initialize(template, object, options={})
              @template = template
              fail "FormBuilder template must be initialized" unless template
              @object = object.kind_of?(Symbol) ? build_object(object) : object
              fail "FormBuilder object must be present. If there's no object, use a symbol instead (i.e. :user)" unless object

    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 resolve_checked_values has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def resolve_checked_values(field, options)
              selected_values = Array(options[:selected] || field_value(field))
              if options[:collection]
                _, id_method = *field_methods(options)
                selected_values.map do |value|

    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

    There are no issues that match your filters.

    Category
    Status