expertiza/expertiza

View on GitHub
app/helpers/charts_helper.rb

Summary

Maintainability
A
25 mins
Test Coverage
F
7%

Assignment Branch Condition size for get_bar_chart_url is too high. [37.22/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.44/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 has too many lines. [24/10]
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 if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [21/10]
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 if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

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

  def self.get_rg_color(value, max)
    ratio = value / (max / 2.0)
    color = ''

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

Method get_pie_chart_url has a Cognitive Complexity of 6 (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 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

Missing top-level module documentation comment.
Open

module ChartsHelper
Severity: Minor
Found in app/helpers/charts_helper.rb by rubocop

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

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

There are no issues that match your filters.

Category
Status