bogdanRada/washout_builder

View on GitHub
app/helpers/washout_builder_method_list_helper.rb

Summary

Maintainability
A
35 mins
Test Coverage

Method create_return_type_list_html has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create_return_type_list_html(xml, output)
    if output.nil? || output[0].blank?
      xml.span('class' => 'pre') { |sp| sp << 'void' }
    else
      complex_class = output[0].find_complex_class_name
Severity: Minor
Found in app/helpers/washout_builder_method_list_helper.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

Unnecessary spacing detected.
Open

    return_content = builder_out[0].multiplied ?  "Array of #{real_class}" : "#{real_class}"

This cop checks for extra/unnecessary whitespace.

Example:

# good if AllowForAlignment is true
name      = "RuboCop"
# Some comment and an empty line

website  += "/bbatsov/rubocop" unless cond
puts        "rubocop"          if     debug

# bad for any configuration
set_app("RuboCop")
website  = "https://github.com/bbatsov/rubocop"

Prefer to_s over string interpolation.
Open

            sp << "#{output[0].type}"

This cop checks for strings that are just an interpolated expression.

Example:

# bad
"#{@var}"

# good
@var.to_s

# good if @var is already a String
@var

Operator ? should be surrounded by a single space.
Open

    return_content = builder_out[0].multiplied ?  "Array of #{real_class}" : "#{real_class}"

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Prefer to_s over string interpolation.
Open

          y << "#{return_content}"

This cop checks for strings that are just an interpolated expression.

Example:

# bad
"#{@var}"

# good
@var.to_s

# good if @var is already a String
@var

Prefer to_s over string interpolation.
Open

    return_content = builder_out[0].multiplied ?  "Array of #{real_class}" : "#{real_class}"

This cop checks for strings that are just an interpolated expression.

Example:

# bad
"#{@var}"

# good
@var.to_s

# good if @var is already a String
@var

There are no issues that match your filters.

Category
Status