visioncritical/consul_template

View on GitHub
libraries/nssm_helpers.rb

Summary

Maintainability
A
1 hr
Test Coverage

Method nssm_params has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def nssm_params
      %w(Application
         AppParameters
         AppDirectory
         AppExit
Severity: Minor
Found in libraries/nssm_helpers.rb - About 1 hr to fix

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

          exit_code == 0 ? true : false
    Severity: Minor
    Found in libraries/nssm_helpers.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

    This conditional expression can just be replaced by exit_code == 0.
    Open

          exit_code == 0 ? true : false
    Severity: Minor
    Found in libraries/nssm_helpers.rb by rubocop

    This cop checks for redundant returning of true/false in conditionals.

    Example:

    # bad
    x == y ? true : false
    
    # bad
    if x == y
      true
    else
      false
    end
    
    # good
    x == y
    
    # bad
    x == y ? false : true
    
    # good
    x != y

    Use 2 (not 4) spaces for indentation.
    Open

              extend ::ConsulTemplateCookbook::NSSMHelpers
    Severity: Minor
    Found in libraries/nssm_helpers.rb by rubocop

    This cops checks for indentation that doesn't use the specified number of spaces.

    See also the IndentationConsistency cop which is the companion to this one.

    Example:

    # bad
    class A
     def test
      puts 'hello'
     end
    end
    
    # good
    class A
      def test
        puts 'hello'
      end
    end

    Example: IgnoredPatterns: ['^\s*module']

    # bad
    module A
    class B
      def test
      puts 'hello'
      end
    end
    end
    
    # good
    module A
    class B
      def test
        puts 'hello'
      end
    end
    end

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

          %w(Application
             AppParameters
             AppDirectory
             AppExit
             AppAffinity
    Severity: Minor
    Found in libraries/nssm_helpers.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)

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

              only_if { nssm_service_installed? && nssm_service_status?(%w(SERVICE_RUNNING SERVICE_PAUSED)) }
    Severity: Minor
    Found in libraries/nssm_helpers.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)

    Re-enable Style/Documentation cop with # rubocop:enable after disabling it.
    Open

    # rubocop:disable Style/Documentation
    Severity: Minor
    Found in libraries/nssm_helpers.rb by rubocop

    There are no issues that match your filters.

    Category
    Status