activerecord-hackery/ransack

View on GitHub
lib/ransack/helpers/form_builder.rb

Summary

Maintainability
C
1 day
Test Coverage

Class FormBuilder has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

    class FormBuilder < (ENV[RANSACK_FORM_BUILDER].try(:constantize) ||
      ActionView::Helpers::FormBuilder)

      def label(method, *args, &block)
        options = args.extract_options!
Severity: Minor
Found in lib/ransack/helpers/form_builder.rb - About 3 hrs to fix

    Method attribute_select has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

          def attribute_select(options = nil, html_options = nil, action = nil)
            options ||= {}
            html_options ||= {}
            action ||= Constants::SEARCH
            default = options.delete(:default)
    Severity: Minor
    Found in lib/ransack/helpers/form_builder.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 predicate_select has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def predicate_select(options = {}, html_options = {})
            options[:compounds] = true if options[:compounds].nil?
            default = options.delete(:default) || Constants::CONT
    
            keys =
    Severity: Minor
    Found in lib/ransack/helpers/form_builder.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 search_fields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def search_fields(name, args, block)
            args << {} unless args.last.is_a?(Hash)
            args.last[:builder] ||= options[:builder]
            args.last[:parent_builder] = self
            options = args.extract_options!
    Severity: Minor
    Found in lib/ransack/helpers/form_builder.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 value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def value
            if @allow_method_names_outside_object
              object.send @method_name if object && object.respond_to?(@method_name, true)
            else
              object.send @method_name if object
    Severity: Minor
    Found in lib/ransack/helpers/form_builder.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

    There are no issues that match your filters.

    Category
    Status