extinctionrebellion/RebelsManager

View on GitHub
app/helpers/ui_helper.rb

Summary

Maintainability
B
5 hrs
Test Coverage
F
10%

Complex method UiHelper#section_heading (64.1)
Open

  def section_heading(heading:, extra: nil, spacing: :hr, count: nil, icon: nil)
    out = ActiveSupport::SafeBuffer.new
    if spacing == :hr
      out << content_tag(:div, class: "grid-x") do
        content_tag(:div, class: "cell auto") do
Severity: Minor
Found in app/helpers/ui_helper.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Method section_heading has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def section_heading(heading:, extra: nil, spacing: :hr, count: nil, icon: nil)
    out = ActiveSupport::SafeBuffer.new
    if spacing == :hr
      out << content_tag(:div, class: "grid-x") do
        content_tag(:div, class: "cell auto") do
Severity: Minor
Found in app/helpers/ui_helper.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 section_heading has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def section_heading(heading:, extra: nil, spacing: :hr, count: nil, icon: nil)
    out = ActiveSupport::SafeBuffer.new
    if spacing == :hr
      out << content_tag(:div, class: "grid-x") do
        content_tag(:div, class: "cell auto") do
Severity: Minor
Found in app/helpers/ui_helper.rb - About 1 hr to fix

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

      def callout(type, content:, tiny: false, link_label: nil, link_href: nil, link_options: {})
        out = ActiveSupport::SafeBuffer.new
        if link_label && link_href
          out << content_tag(:div, class: "cell small-12 medium-shrink") do
            if tiny
    Severity: Minor
    Found in app/helpers/ui_helper.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

    Complex method UiHelper#callout (22.6)
    Open

      def callout(type, content:, tiny: false, link_label: nil, link_href: nil, link_options: {})
        out = ActiveSupport::SafeBuffer.new
        if link_label && link_href
          out << content_tag(:div, class: "cell small-12 medium-shrink") do
            if tiny
    Severity: Minor
    Found in app/helpers/ui_helper.rb by flog

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    There are no issues that match your filters.

    Category
    Status