app/helpers/topics_helper.rb

Summary

Maintainability
A
45 mins
Test Coverage

Method has too many lines. [22/10]
Open

  def topic_type_breadcrumb_for(topic)
    html = '<ul class="breadcrumb">'
    count = 0
    topic_types = topic.topic_type.self_and_ancestors
    topic_types.each do |tt|
Severity: Minor
Found in app/helpers/topics_helper.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for topic_type_breadcrumb_for is too high. [26.42/15]
Open

  def topic_type_breadcrumb_for(topic)
    html = '<ul class="breadcrumb">'
    count = 0
    topic_types = topic.topic_type.self_and_ancestors
    topic_types.each do |tt|
Severity: Minor
Found in app/helpers/topics_helper.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method topic_type_breadcrumb_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def topic_type_breadcrumb_for(topic)
    html = '<ul class="breadcrumb">'
    count = 0
    topic_types = topic.topic_type.self_and_ancestors
    topic_types.each do |tt|
Severity: Minor
Found in app/helpers/topics_helper.rb - About 45 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

Use the return of the conditional for variable assignment and comparison.
Open

      if topic_types.size == count
        classes << 'selected-topic-type'
      else
        classes << 'ancestor-topic-type'
      end
Severity: Minor
Found in app/helpers/topics_helper.rb by rubocop

There are no issues that match your filters.

Category
Status