wwidea/composable_builders

View on GitHub

Showing 4 of 4 total issues

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

        def create_tagged_field(method_name, options_position = 0)
          define_method("#{method_name}") do |method, *args|
            options = (args[options_position] || {}).reverse_merge!(default_options)
            tail = options.delete(:tail)
            @template.content_tag(:div, options.delete(:div_options)) do
Severity: Minor
Found in lib/composable_builders/components/tagged.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 format_for_display has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def format_for_display(value)
          result = case value
            when Date, Time
              value.strftime("%m/%d/%y")
            when TrueClass
Severity: Minor
Found in lib/composable_builders/components/deformable.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

Consider simplifying this complex logical expression.
Open

          unless args[0].is_a?(String) or args[0].is_a?(Symbol)
            deprecated_habtm_check_boxes(*args)
          else
            method = args[0]
            choices = args[1]
Severity: Major
Found in lib/composable_builders/components/tagged.rb - About 40 mins to fix

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

        def create(options = {})
          Class.new(ActionView::Helpers::FormBuilder) do
            include ComposableBuilders::Components::Global
            include ComposableBuilders::Components::Deformable if options[:deformable]
            include ComposableBuilders::Components::Printable if options[:printable]
    Severity: Minor
    Found in lib/builders/composable_builder.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