ece517-p3/expertiza

View on GitHub
app/helpers/charts_helper.rb

Summary

Maintainability
A
45 mins
Test Coverage

Assignment Branch Condition size for get_bar_chart_url is too high. [37/15]
Open

  def self.get_bar_chart_url(labels, values, max)
    return  "" if labels.length != values.length

    address = "http://chart.apis.google.com/chart?cht=bhs&chxt=x,y&chf=bg,s,dddddd&chtt=Average+response+score+by+question&chs=600x" + (labels.length * 25 + 60).to_s

Severity: Minor
Found in app/helpers/charts_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

Assignment Branch Condition size for get_pie_chart_url is too high. [33.62/15]
Open

  def self.get_pie_chart_url(labels, values)
    return  "" if labels.length != values.length

    address = "http://chart.apis.google.com/chart?cht=p3&chs=300x125"
    max = 100.0
Severity: Minor
Found in app/helpers/charts_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 get_pie_chart_url has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def self.get_pie_chart_url(labels, values)
    return  "" if labels.length != values.length

    address = "http://chart.apis.google.com/chart?cht=p3&chs=300x125"
    max = 100.0
Severity: Minor
Found in app/helpers/charts_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

Line is too long. [165/160]
Open

    address = "http://chart.apis.google.com/chart?cht=bhs&chxt=x,y&chf=bg,s,dddddd&chtt=Average+response+score+by+question&chs=600x" + (labels.length * 25 + 60).to_s
Severity: Minor
Found in app/helpers/charts_helper.rb by rubocop

Prefer each over for.
Open

    for value in values
Severity: Minor
Found in app/helpers/charts_helper.rb by rubocop

This cop looks for uses of the for keyword, or each method. The preferred alternative is set in the EnforcedStyle configuration parameter. An each call with a block on a single line is always allowed, however.

Prefer each over for.
Open

    for value in values
Severity: Minor
Found in app/helpers/charts_helper.rb by rubocop

This cop looks for uses of the for keyword, or each method. The preferred alternative is set in the EnforcedStyle configuration parameter. An each call with a block on a single line is always allowed, however.

Prefer each over for.
Open

    for value in values
Severity: Minor
Found in app/helpers/charts_helper.rb by rubocop

This cop looks for uses of the for keyword, or each method. The preferred alternative is set in the EnforcedStyle configuration parameter. An each call with a block on a single line is always allowed, however.

Useless assignment to variable - address. Use + instead of +=.
Open

    address += value_string + label_string + color_string
Severity: Minor
Found in app/helpers/charts_helper.rb by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

Prefer each over for.
Open

    for j in 0..max
Severity: Minor
Found in app/helpers/charts_helper.rb by rubocop

This cop looks for uses of the for keyword, or each method. The preferred alternative is set in the EnforcedStyle configuration parameter. An each call with a block on a single line is always allowed, however.

Use value.zero? instead of value == 0.
Open

      unless value == 0
Severity: Minor
Found in app/helpers/charts_helper.rb by rubocop

This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

Example: EnforcedStyle: predicate (default)

# bad

foo == 0
0 > foo
bar.baz > 0

# good

foo.zero?
foo.negative?
bar.baz.positive?

Example: EnforcedStyle: comparison

# bad

foo.zero?
foo.negative?
bar.baz.positive?

# good

foo == 0
0 > foo
bar.baz > 0

Useless assignment to variable - address. Use + instead of +=.
Open

    address += value_string + label_string + color_string
Severity: Minor
Found in app/helpers/charts_helper.rb by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

There are no issues that match your filters.

Category
Status