app/form_builders/formatted_form_builder.rb

Summary

Maintainability
C
1 day
Test Coverage

Method form_field has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def form_field(attribute, options, &block)
    content_tag(:div, class: "field") do
      # Label
      label = label(attribute, options[:label])

Severity: Minor
Found in app/form_builders/formatted_form_builder.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 file_field has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def file_field(attribute, options = {})
    form_field(attribute, options) do
      file_tag(attribute, options) do
        file_label_tag(attribute, options) do
          # Input for selecting the file
Severity: Minor
Found in app/form_builders/formatted_form_builder.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 submit has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def submit(value = nil, options = {})
    css_class = "is-flex"

    # If the "justify" option is provided, use it as the class.
    # If not provided, justify to the end.
Severity: Minor
Found in app/form_builders/formatted_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 form_field has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def form_field(attribute, options, &block)
    content_tag(:div, class: "field") do
      # Label
      label = label(attribute, options[:label])

Severity: Minor
Found in app/form_builders/formatted_form_builder.rb - About 1 hr to fix

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

      def control_tag(_attribute, options = {})
        css_class = "control"
    
        # Add "has-icons-left" class if the option "prefix_icon" is provided.
        css_class += " has-icons-left" if options[:prefix_icon]
    Severity: Minor
    Found in app/form_builders/formatted_form_builder.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 collection_select has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def collection_select(attribute, collection, value_method, text_method, options = {}, html_options = {})
    Severity: Minor
    Found in app/form_builders/formatted_form_builder.rb - About 45 mins to fix

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

        def file_tag(attribute, options = {}, &block)
          css_class = "file"
      
          # Add "has-name" class if the skip_name option is false
          css_class += " has-name" unless options[:skip_name]
      Severity: Minor
      Found in app/form_builders/formatted_form_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

      There are no issues that match your filters.

      Category
      Status