Method action_enable
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def action_enable
notifying_block do
directories = %W(#{new_resource.data_dir}
#{::File.dirname(new_resource.nssm_params['AppStdout'])}
#{::File.dirname(new_resource.nssm_params['AppStderr'])}).uniq.compact
Block has too many lines. [41/25] Open
notifying_block do
directories = %W(#{new_resource.data_dir}
#{::File.dirname(new_resource.nssm_params['AppStdout'])}
#{::File.dirname(new_resource.nssm_params['AppStderr'])}).uniq.compact
directories.delete_if { |i| i.eql? '.' }.each do |dir|
- Read upRead up
- Exclude checks
This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.
Method action_enable
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def action_enable
notifying_block do
directories = %W(#{new_resource.data_dir}
#{::File.dirname(new_resource.nssm_params['AppStdout'])}
#{::File.dirname(new_resource.nssm_params['AppStderr'])}).uniq.compact
- Read upRead up
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
Parenthesize the param new_resource.nssm_params.select { |_k, v| v != '' }
to make sure that the block will be associated with the new_resource.nssm_params.select
method call. Open
parameters new_resource.nssm_params.select { |_k, v| v != '' }
- Read upRead up
- Exclude checks
This cop checks for ambiguous block association with method when param passed without parentheses.
Example:
# bad
some_method a { |val| puts val }
Example:
# good
# With parentheses, there's no ambiguity.
some_method(a) { |val| puts val }
# good
# Operator methods require no disambiguation
foo == bar { |b| b.baz }
# good
# Lambda arguments require no disambiguation
foo = ->(bar) { bar.baz }
%w
-literals should be delimited by [
and ]
. Open
not_if { nssm_service_status?(%w(SERVICE_RUNNING)) && mismatch_params.empty? }
- Read upRead up
- Exclude checks
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
directories = %W(#{new_resource.data_dir}
#{::File.dirname(new_resource.nssm_params['AppStdout'])}
#{::File.dirname(new_resource.nssm_params['AppStderr'])}).uniq.compact
- Read upRead up
- Exclude checks
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
provides(:consul_template_service, os: %w(windows))
- Read upRead up
- Exclude checks
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)