brundage/thermostat

View on GitHub
lib/thermostat/heat_index_calculator.rb

Summary

Maintainability
A
0 mins
Test Coverage

Assignment Branch Condition size for heat_index is too high. [43.1/15]
Open

    def heat_index
      t = temperature.convert_to(heat_index_scale).scalar
      r = relative_humidity_percent
      hi = hi_c1 + hi_c2*t + hi_c3*r + hi_c4*t*r + hi_c5*t**2 + hi_c6*r**2 + hi_c7*r*t**2 + hi_c8*t*r**2 + hi_c9*(t*r)**2
      return Unit.new(hi, heat_index_scale).convert_to(temperature)

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

Surrounding space missing for operator *.
Open

      hi = hi_c1 + hi_c2*t + hi_c3*r + hi_c4*t*r + hi_c5*t**2 + hi_c6*r**2 + hi_c7*r*t**2 + hi_c8*t*r**2 + hi_c9*(t*r)**2

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

Avoid single-line method definitions.
Open

    def hi_c3;  10.14333127;          end

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

Use empty lines between method definitions.
Open

    def hi_c3;  10.14333127;          end

This cop checks whether method definitions are separated by one empty line.

NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

Example:

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

Extra empty line detected at module body beginning.
Open


    # https://en.wikipedia.org/wiki/Heat_index#Formula

This cops checks if empty lines around the bodies of modules match the configuration.

Example: EnforcedStyle: empty_lines

# good

module Foo

  def bar
    # ...
  end

end

Example: EnforcedStyle: emptylinesexcept_namespace

# good

module Foo
  module Bar

    # ...

  end
end

Example: EnforcedStyle: emptylinesspecial

# good
module Foo

  def bar; end

end

Example: EnforcedStyle: noemptylines (default)

# good

module Foo
  def bar
    # ...
  end
end

Extra blank line detected.
Open


    def hi_c1; -42.379;               end

This cops checks for two or more consecutive blank lines.

Example:

# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method

# good
some_method
# one empty line
some_method

Space around operator ** detected.
Open

    def hi_c9;  -1.99 * 10 ** -6;     end

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

Surrounding space missing for operator *.
Open

      hi = hi_c1 + hi_c2*t + hi_c3*r + hi_c4*t*r + hi_c5*t**2 + hi_c6*r**2 + hi_c7*r*t**2 + hi_c8*t*r**2 + hi_c9*(t*r)**2

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

Surrounding space missing for operator *.
Open

      hi = hi_c1 + hi_c2*t + hi_c3*r + hi_c4*t*r + hi_c5*t**2 + hi_c6*r**2 + hi_c7*r*t**2 + hi_c8*t*r**2 + hi_c9*(t*r)**2

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

Line is too long. [121/80]
Open

      hi = hi_c1 + hi_c2*t + hi_c3*r + hi_c4*t*r + hi_c5*t**2 + hi_c6*r**2 + hi_c7*r*t**2 + hi_c8*t*r**2 + hi_c9*(t*r)**2

Indent access modifiers like private.
Open

  private

Modifiers should be indented as deep as method definitions, or as deep as the class/module keyword, depending on configuration.

Example: EnforcedStyle: indent (default)

# bad
class Plumbus
private
  def smooth; end
end

# good
class Plumbus
  private
  def smooth; end
end

Example: EnforcedStyle: outdent

# bad
class Plumbus
  private
  def smooth; end
end

# good
class Plumbus
private
  def smooth; end
end

Surrounding space missing for operator *.
Open

      hi = hi_c1 + hi_c2*t + hi_c3*r + hi_c4*t*r + hi_c5*t**2 + hi_c6*r**2 + hi_c7*r*t**2 + hi_c8*t*r**2 + hi_c9*(t*r)**2

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

Missing top-level module documentation comment.
Open

  module HeatIndexCalculator

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

Redundant return detected.
Open

      return Unit.new(hi, heat_index_scale).convert_to(temperature)

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Avoid single-line method definitions.
Open

    def hi_c2;   2.04901523;          end

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

Avoid single-line method definitions.
Open

    def hi_c8;   8.5282 * 10 ** -4;   end

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

Unnecessary spacing detected.
Open

    def hi_c9;  -1.99 * 10 ** -6;     end

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"

Surrounding space missing for operator *.
Open

      hi = hi_c1 + hi_c2*t + hi_c3*r + hi_c4*t*r + hi_c5*t**2 + hi_c6*r**2 + hi_c7*r*t**2 + hi_c8*t*r**2 + hi_c9*(t*r)**2

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

Surrounding space missing for operator *.
Open

      hi = hi_c1 + hi_c2*t + hi_c3*r + hi_c4*t*r + hi_c5*t**2 + hi_c6*r**2 + hi_c7*r*t**2 + hi_c8*t*r**2 + hi_c9*(t*r)**2

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

Surrounding space missing for operator *.
Open

      hi = hi_c1 + hi_c2*t + hi_c3*r + hi_c4*t*r + hi_c5*t**2 + hi_c6*r**2 + hi_c7*r*t**2 + hi_c8*t*r**2 + hi_c9*(t*r)**2

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

Space around operator ** detected.
Open

    def hi_c7;   1.22874 * 10 ** -3;  end

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

Avoid single-line method definitions.
Open

    def hi_c4;  -0.22475541;          end

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

Avoid single-line method definitions.
Open

    def hi_c9;  -1.99 * 10 ** -6;     end

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

Surrounding space missing for operator *.
Open

      hi = hi_c1 + hi_c2*t + hi_c3*r + hi_c4*t*r + hi_c5*t**2 + hi_c6*r**2 + hi_c7*r*t**2 + hi_c8*t*r**2 + hi_c9*(t*r)**2

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

Surrounding space missing for operator *.
Open

      hi = hi_c1 + hi_c2*t + hi_c3*r + hi_c4*t*r + hi_c5*t**2 + hi_c6*r**2 + hi_c7*r*t**2 + hi_c8*t*r**2 + hi_c9*(t*r)**2

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

Avoid single-line method definitions.
Open

    def hi_c5;  -6.83783 * 10 ** -3;  end

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

Use empty lines between method definitions.
Open

    def hi_c5;  -6.83783 * 10 ** -3;  end

This cop checks whether method definitions are separated by one empty line.

NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

Example:

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

Space around operator ** detected.
Open

    def hi_c6;  -5.481717 * 10 ** -2; end

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

Avoid single-line method definitions.
Open

    def hi_c7;   1.22874 * 10 ** -3;  end

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

Use empty lines between method definitions.
Open

    def hi_c7;   1.22874 * 10 ** -3;  end

This cop checks whether method definitions are separated by one empty line.

NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

Example:

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

Use empty lines between method definitions.
Open

    def hi_c9;  -1.99 * 10 ** -6;     end

This cop checks whether method definitions are separated by one empty line.

NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

Example:

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

Surrounding space missing for operator *.
Open

      hi = hi_c1 + hi_c2*t + hi_c3*r + hi_c4*t*r + hi_c5*t**2 + hi_c6*r**2 + hi_c7*r*t**2 + hi_c8*t*r**2 + hi_c9*(t*r)**2

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

Avoid single-line method definitions.
Open

    def hi_c6;  -5.481717 * 10 ** -2; end

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

Use empty lines between method definitions.
Open

    def hi_c1; -42.379;               end

This cop checks whether method definitions are separated by one empty line.

NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

Example:

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

Use empty lines between method definitions.
Open

    def hi_c6;  -5.481717 * 10 ** -2; end

This cop checks whether method definitions are separated by one empty line.

NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

Example:

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

Space around operator ** detected.
Open

    def hi_c8;   8.5282 * 10 ** -4;   end

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

Use empty lines between method definitions.
Open

    def hi_c2;   2.04901523;          end

This cop checks whether method definitions are separated by one empty line.

NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

Example:

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

Surrounding space missing for operator *.
Open

      hi = hi_c1 + hi_c2*t + hi_c3*r + hi_c4*t*r + hi_c5*t**2 + hi_c6*r**2 + hi_c7*r*t**2 + hi_c8*t*r**2 + hi_c9*(t*r)**2

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

Surrounding space missing for operator *.
Open

      hi = hi_c1 + hi_c2*t + hi_c3*r + hi_c4*t*r + hi_c5*t**2 + hi_c6*r**2 + hi_c7*r*t**2 + hi_c8*t*r**2 + hi_c9*(t*r)**2

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

Avoid single-line method definitions.
Open

    def hi_c1; -42.379;               end

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

Extra empty line detected at module body end.
Open


  end

This cops checks if empty lines around the bodies of modules match the configuration.

Example: EnforcedStyle: empty_lines

# good

module Foo

  def bar
    # ...
  end

end

Example: EnforcedStyle: emptylinesexcept_namespace

# good

module Foo
  module Bar

    # ...

  end
end

Example: EnforcedStyle: emptylinesspecial

# good
module Foo

  def bar; end

end

Example: EnforcedStyle: noemptylines (default)

# good

module Foo
  def bar
    # ...
  end
end

Space around operator ** detected.
Open

    def hi_c5;  -6.83783 * 10 ** -3;  end

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

Use empty lines between method definitions.
Open

    def hi_c4;  -0.22475541;          end

This cop checks whether method definitions are separated by one empty line.

NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

Example:

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

Use empty lines between method definitions.
Open

    def hi_c8;   8.5282 * 10 ** -4;   end

This cop checks whether method definitions are separated by one empty line.

NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

Example:

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

There are no issues that match your filters.

Category
Status