brundage/thermostat

View on GitHub
lib/thermostat/logger.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Class Logger has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Logger < ::Logger

    autoload :Formatter, File.join('thermostat', 'logger', 'formatter')

    module Subsystem
Severity: Minor
Found in lib/thermostat/logger.rb - About 2 hrs to fix

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

        def add(severity, subsystem, message=nil)
          severity = lookup_severity(severity)
          subsystem = lookup_subsystem(subsystem)
          if @logdev.nil? or (severity < @level and subsystem < @subsystem)
            return true
    Severity: Minor
    Found in lib/thermostat/logger.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.

    Cyclomatic complexity for add is too high. [7/6]
    Open

        def add(severity, subsystem, message=nil)
          severity = lookup_severity(severity)
          subsystem = lookup_subsystem(subsystem)
          if @logdev.nil? or (severity < @level and subsystem < @subsystem)
            return true
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Perceived complexity for add is too high. [8/7]
    Open

        def add(severity, subsystem, message=nil)
          severity = lookup_severity(severity)
          subsystem = lookup_subsystem(subsystem)
          if @logdev.nil? or (severity < @level and subsystem < @subsystem)
            return true
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

    Example:

    def my_method                   # 1
      if cond                       # 1
        case var                    # 2 (0.8 + 4 * 0.2, rounded)
        when 1 then func_one
        when 2 then func_two
        when 3 then func_three
        when 4..10 then func_other
        end
      else                          # 1
        do_something until a && b   # 2
      end                           # ===
    end                             # 7 complexity points

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

        def add(severity, subsystem, message=nil)
          severity = lookup_severity(severity)
          subsystem = lookup_subsystem(subsystem)
          if @logdev.nil? or (severity < @level and subsystem < @subsystem)
            return true
    Severity: Minor
    Found in lib/thermostat/logger.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

    Use empty lines between method definitions.
    Open

        def debug(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 fatal(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 warn(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 blank line detected.
    Open

    
        def error(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Extra blank line detected.
    Open

    
        def unknown(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Extra blank line detected.
    Open

    
        def lookup_severity(s)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Surrounding space missing in default value assignment.
    Open

        def fatal(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Surrounding space missing in default value assignment.
    Open

        def state_machine(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Space inside parentheses detected.
    Open

            @logdev.write format_message(format_severity(severity), format_subsystem(subsystem), Time.now, message )
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks for spaces inside ordinary round parentheses.

    Example:

    # bad
    f( 3)
    g = (a + 3 )
    
    # good
    f(3)
    g = (a + 3)

    Extra blank line detected.
    Open

    
        def debug(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Extra blank line detected.
    Open

    
        def initialize(*)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Extra blank line detected.
    Open

    
        def sensor(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Surrounding space missing in default value assignment.
    Open

        def debug(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Trailing whitespace detected.
    Open

        end 
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Use empty lines between method definitions.
    Open

        def state_machine(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 missing after comma.
    Open

        def lookup(s,m,d)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks for comma (,) not followed by some kind of space.

    Example:

    # bad
    [1,2]
    { foo:bar,}
    
    # good
    [1, 2]
    { foo:bar, }

    Surrounding space missing in default value assignment.
    Open

        def controller(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Surrounding space missing in default value assignment.
    Open

        def unknown(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Line is too long. [98/80]
    Open

                             fatal: FATAL,     # An unhandleable error that results in a program crash
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Line is too long. [96/80]
    Open

                             info: INFO,       # Generic (useful) information about system operation
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Extra blank line detected.
    Open

    
        def thermostat(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Surrounding space missing in default value assignment.
    Open

        def hardware(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Use empty lines between method definitions.
    Open

        def subsystem=(s)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 class body beginning.
    Open

    
        autoload :Formatter, File.join('thermostat', 'logger', 'formatter')
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

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

    Example: EnforcedStyle: empty_lines

    # good
    
    class Foo
    
      def bar
        # ...
      end
    
    end

    Example: EnforcedStyle: emptylinesexcept_namespace

    # good
    
    class Foo
      class Bar
    
        # ...
    
      end
    end

    Example: EnforcedStyle: emptylinesspecial

    # good
    class Foo
    
      def bar; end
    
    end

    Example: EnforcedStyle: noemptylines (default)

    # good
    
    class Foo
      def bar
        # ...
      end
    end

    Extra blank line detected.
    Open

    
        def fatal(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Surrounding space missing in default value assignment.
    Open

        def state_machine(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Freeze mutable objects assigned to constants.
    Open

        SEVERITY_MAPPING = { debug: DEBUG,     # Low-level information for developers
                             error: ERROR,     # A handleable error condition
                             fatal: FATAL,     # An unhandleable error that results in a program crash
                             info: INFO,       # Generic (useful) information about system operation
                             unknown: UNKNOWN, # An unknown message that should always be logged
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

    Example:

    # bad
    CONST = [1, 2, 3]
    
    # good
    CONST = [1, 2, 3].freeze

    Use empty lines between method definitions.
    Open

        def sensor(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 lookup_severity(s)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 lookup_subsystem(s)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 blank line detected.
    Open

    
        def format_message(severity, subsystem, time, message)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Extra blank line detected.
    Open

    
        def lookup_subsystem(s)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Surrounding space missing in default value assignment.
    Open

        def debug(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Freeze mutable objects assigned to constants.
    Open

        SUBSYSTEM_MAPPING = { controller:    CONTROLLER,
                              hartware:      HARDWARE,
                              none:          NONE,
                              quiet:         QUIET,
                              sensor:        SENSOR,
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

    Example:

    # bad
    CONST = [1, 2, 3]
    
    # good
    CONST = [1, 2, 3].freeze

    Use empty lines between method definitions.
    Open

        def subsystem_mapping; SUBSYSTEM_MAPPING; end
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 blank line detected.
    Open

    
    
    
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Surrounding space missing in default value assignment.
    Open

        def warn(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Avoid single-line method definitions.
    Open

        def severity_mapping; SEVERITY_MAPPING; end
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 blank line detected.
    Open

    
        def info(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Surrounding space missing in default value assignment.
    Open

        def thermostat(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Line is too long. [110/80]
    Open

        SUBSYSTEM_LABEL = %w(HARDWARE STATE_MACHINE CONTROLLER SENSOR THERMOSTAT NONE QUIET).each(&:freeze).freeze
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Use empty lines between method definitions.
    Open

        def format_subsystem(s)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 in default value assignment.
    Open

        def hardware(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Trailing whitespace detected.
    Open

        end 
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Trailing whitespace detected.
    Open

        end 
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Use && instead of and.
    Open

          if @logdev.nil? or (severity < @level and subsystem < @subsystem)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

    Example: EnforcedStyle: always (default)

    # bad
    foo.save and return
    
    # bad
    if foo and bar
    end
    
    # good
    foo.save && return
    
    # good
    if foo && bar
    end

    Example: EnforcedStyle: conditionals

    # bad
    if foo and bar
    end
    
    # good
    foo.save && return
    
    # good
    foo.save and return
    
    # good
    if foo && bar
    end

    Extra blank line detected.
    Open

    
        def warn(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
    Open

          if message.nil? && block_given?
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

    Example:

    # bad
    if condition
      do_stuff(bar)
    end
    
    unless qux.empty?
      Foo.do_something
    end
    
    # good
    do_stuff(bar) if condition
    Foo.do_something unless qux.empty?

    %w-literals should be delimited by [ and ].
    Open

        SUBSYSTEM_LABEL = %w(HARDWARE STATE_MACHINE CONTROLLER SENSOR THERMOSTAT NONE QUIET).each(&:freeze).freeze
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    This cop enforces the consistent usage of %-literal delimiters.

    Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

    Example:

    # Style/PercentLiteralDelimiters:
    #   PreferredDelimiters:
    #     default: '[]'
    #     '%i':    '()'
    
    # good
    %w[alpha beta] + %i(gamma delta)
    
    # bad
    %W(alpha #{beta})
    
    # bad
    %I(alpha beta)

    Use empty lines between method definitions.
    Open

        def controller(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Avoid single-line method definitions.
    Open

        def subsystem_mapping; SUBSYSTEM_MAPPING; end
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 blank line detected.
    Open

    
        def subsystem=(s)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Closing hash brace must be on the same line as the last hash element when opening brace is on the same line as the first hash element.
    Open

                            }
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    This cop checks that the closing brace in a hash literal is either on the same line as the last hash element, or a new line.

    When using the symmetrical (default) style:

    If a hash's opening brace is on the same line as the first element of the hash, then the closing brace should be on the same line as the last element of the hash.

    If a hash's opening brace is on the line above the first element of the hash, then the closing brace should be on the line below the last element of the hash.

    When using the new_line style:

    The closing brace of a multi-line hash literal must be on the line after the last element of the hash.

    When using the same_line style:

    The closing brace of a multi-line hash literal must be on the same line as the last element of the hash.

    Example: EnforcedStyle: symmetrical (default)

    # bad
      { a: 1,
        b: 2
      }
      # bad
      {
        a: 1,
        b: 2 }
    
      # good
      { a: 1,
        b: 2 }
    
      # good
      {
        a: 1,
        b: 2
      }

    Example: EnforcedStyle: new_line

    # bad
      {
        a: 1,
        b: 2 }
    
      # bad
      { a: 1,
        b: 2 }
    
      # good
      { a: 1,
        b: 2
      }
    
      # good
      {
        a: 1,
        b: 2
      }

    Example: EnforcedStyle: same_line

    # bad
      { a: 1,
        b: 2
      }
    
      # bad
      {
        a: 1,
        b: 2
      }
    
      # good
      {
        a: 1,
        b: 2 }
    
      # good
      { a: 1,
        b: 2 }

    Surrounding space missing in default value assignment.
    Open

        def fatal(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Indent access modifiers like private.
    Open

      private
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Use empty lines between method definitions.
    Open

        def error(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 thermostat(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 unknown(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 blank line detected.
    Open

    
        def hardware(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Use empty lines between method definitions.
    Open

        def hardware(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 lookup(s,m,d)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 blank line detected.
    Open

    
        def level=(l)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Closing hash brace must be on the same line as the last hash element when opening brace is on the same line as the first hash element.
    Open

                           }
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    This cop checks that the closing brace in a hash literal is either on the same line as the last hash element, or a new line.

    When using the symmetrical (default) style:

    If a hash's opening brace is on the same line as the first element of the hash, then the closing brace should be on the same line as the last element of the hash.

    If a hash's opening brace is on the line above the first element of the hash, then the closing brace should be on the line below the last element of the hash.

    When using the new_line style:

    The closing brace of a multi-line hash literal must be on the line after the last element of the hash.

    When using the same_line style:

    The closing brace of a multi-line hash literal must be on the same line as the last element of the hash.

    Example: EnforcedStyle: symmetrical (default)

    # bad
      { a: 1,
        b: 2
      }
      # bad
      {
        a: 1,
        b: 2 }
    
      # good
      { a: 1,
        b: 2 }
    
      # good
      {
        a: 1,
        b: 2
      }

    Example: EnforcedStyle: new_line

    # bad
      {
        a: 1,
        b: 2 }
    
      # bad
      { a: 1,
        b: 2 }
    
      # good
      { a: 1,
        b: 2
      }
    
      # good
      {
        a: 1,
        b: 2
      }

    Example: EnforcedStyle: same_line

    # bad
      { a: 1,
        b: 2
      }
    
      # bad
      {
        a: 1,
        b: 2
      }
    
      # good
      {
        a: 1,
        b: 2 }
    
      # good
      { a: 1,
        b: 2 }

    Extra blank line detected.
    Open

    
        def controller(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Surrounding space missing in default value assignment.
    Open

        def error(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Surrounding space missing in default value assignment.
    Open

        def sensor(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Line is too long. [81/80]
    Open

        SEVERITY_MAPPING = { debug: DEBUG,     # Low-level information for developers
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Surrounding space missing in default value assignment.
    Open

        def sensor(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Use || instead of or.
    Open

          if @logdev.nil? or (severity < @level and subsystem < @subsystem)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

    Example: EnforcedStyle: always (default)

    # bad
    foo.save and return
    
    # bad
    if foo and bar
    end
    
    # good
    foo.save && return
    
    # good
    if foo && bar
    end

    Example: EnforcedStyle: conditionals

    # bad
    if foo and bar
    end
    
    # good
    foo.save && return
    
    # good
    foo.save and return
    
    # good
    if foo && bar
    end

    Use empty lines between method definitions.
    Open

        def format_message(severity, subsystem, time, message)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 level=(l)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 blank line detected.
    Open

    
        def state_machine(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Extra blank line detected.
    Open

    
        def format_subsystem(s)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Extra blank line detected.
    Open

    
        def lookup(s,m,d)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Surrounding space missing in default value assignment.
    Open

        def add(severity, subsystem, message=nil)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Surrounding space missing in default value assignment.
    Open

        def controller(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Surrounding space missing in default value assignment.
    Open

        def error(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Surrounding space missing in default value assignment.
    Open

        def info(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Surrounding space missing in default value assignment.
    Open

        def thermostat(severity=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Surrounding space missing in default value assignment.
    Open

        def warn(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Line is too long. [112/80]
    Open

            @logdev.write format_message(format_severity(severity), format_subsystem(subsystem), Time.now, message )
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Use empty lines between method definitions.
    Open

        def info(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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

    Missing top-level class documentation comment.
    Open

      class Logger < ::Logger
    Severity: Minor
    Found in lib/thermostat/logger.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 empty lines between method definitions.
    Open

        def initialize(*)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    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 class body end.
    Open

    
      end
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

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

    Example: EnforcedStyle: empty_lines

    # good
    
    class Foo
    
      def bar
        # ...
      end
    
    end

    Example: EnforcedStyle: emptylinesexcept_namespace

    # good
    
    class Foo
      class Bar
    
        # ...
    
      end
    end

    Example: EnforcedStyle: emptylinesspecial

    # good
    class Foo
    
      def bar; end
    
    end

    Example: EnforcedStyle: noemptylines (default)

    # good
    
    class Foo
      def bar
        # ...
      end
    end

    Space missing after comma.
    Open

        def lookup(s,m,d)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks for comma (,) not followed by some kind of space.

    Example:

    # bad
    [1,2]
    { foo:bar,}
    
    # good
    [1, 2]
    { foo:bar, }

    Surrounding space missing in default value assignment.
    Open

        def info(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Surrounding space missing in default value assignment.
    Open

        def unknown(subsystem=nil, msg=nil, &block)
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Checks that the equals signs in parameter default assignments have or don't have surrounding space depending on configuration.

    Example:

    # bad
    def some_method(arg1=:default, arg2=nil, arg3=[])
      # do something...
    end
    
    # good
    def some_method(arg1 = :default, arg2 = nil, arg3 = [])
      # do something...
    end

    Trailing whitespace detected.
    Open

        end 
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    Line is too long. [92/80]
    Open

                             unknown: UNKNOWN, # An unknown message that should always be logged
    Severity: Minor
    Found in lib/thermostat/logger.rb by rubocop

    There are no issues that match your filters.

    Category
    Status