Assignment Branch Condition size for process_yaml_config is too high. [20.02/15] Open
def process_yaml_config
yaml_config.inject([]) do |config_array, listener_config|
debug "listener_config: #{listener_config}"
if listener_config.delete("listener_active")
config_array << CelluloidIOPGListener::SuperviseSignature.new(
- Read upRead up
- Exclude checks
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. [14/10] Open
def process_yaml_config
yaml_config.inject([]) do |config_array, listener_config|
debug "listener_config: #{listener_config}"
if listener_config.delete("listener_active")
config_array << CelluloidIOPGListener::SuperviseSignature.new(
- Read upRead up
- Exclude checks
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.
Prefer single-quoted strings inside interpolations. Open
info "Listener not active for channel '#{listener_config["args"]["channel"]}' on database '#{listener_config["args"]["dbname"]}'..."
- Read upRead up
- Exclude checks
This cop checks that quotes inside the string interpolation match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
result = "Tests #{success ? "PASS" : "FAIL"}"
# good
result = "Tests #{success ? 'PASS' : 'FAIL'}"
Example: EnforcedStyle: double_quotes
# bad
result = "Tests #{success ? 'PASS' : 'FAIL'}"
# good
result = "Tests #{success ? "PASS" : "FAIL"}"
Line is too long. [131/80] Open
info "Listening to channel '#{listener_config["args"]["channel"]}' on database '#{listener_config["args"]["dbname"]}'..."
- Exclude checks
Prefer single-quoted strings inside interpolations. Open
info "Listening to channel '#{listener_config["args"]["channel"]}' on database '#{listener_config["args"]["dbname"]}'..."
- Read upRead up
- Exclude checks
This cop checks that quotes inside the string interpolation match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
result = "Tests #{success ? "PASS" : "FAIL"}"
# good
result = "Tests #{success ? 'PASS' : 'FAIL'}"
Example: EnforcedStyle: double_quotes
# bad
result = "Tests #{success ? 'PASS' : 'FAIL'}"
# good
result = "Tests #{success ? "PASS" : "FAIL"}"
Use each_with_object
instead of inject
. Open
yaml_config.inject([]) do |config_array, listener_config|
- Read upRead up
- Exclude checks
This cop looks for inject / reduce calls where the passed in object is returned at the end and so could be replaced by eachwithobject without the need to return the object at the end.
However, we can't replace with eachwithobject if the accumulator parameter is assigned to within the block.
Example:
# bad
[1, 2].inject({}) { |a, e| a[e] = e; a }
# good
[1, 2].each_with_object({}) { |e, a| a[e] = e }
Line is too long. [142/80] Open
info "Listener not active for channel '#{listener_config["args"]["channel"]}' on database '#{listener_config["args"]["dbname"]}'..."
- Exclude checks
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
@yaml_config = @yaml_config["listening_group"] if @yaml_config["listening_group"]
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Prefer single-quoted strings inside interpolations. Open
info "Listening to channel '#{listener_config["args"]["channel"]}' on database '#{listener_config["args"]["dbname"]}'..."
- Read upRead up
- Exclude checks
This cop checks that quotes inside the string interpolation match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
result = "Tests #{success ? "PASS" : "FAIL"}"
# good
result = "Tests #{success ? 'PASS' : 'FAIL'}"
Example: EnforcedStyle: double_quotes
# bad
result = "Tests #{success ? 'PASS' : 'FAIL'}"
# good
result = "Tests #{success ? "PASS" : "FAIL"}"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
args: listener_config["args"]
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Indent the first parameter one step more than the start of the previous line. Open
type: listener_config["type"],
as: listener_config["as"],
args: listener_config["args"]
- Read upRead up
- Exclude checks
This cop checks the indentation of the first parameter in a method call. Parameters after the first one are checked by Style/AlignParameters, not by this cop.
Example:
# bad
some_method(
first_param,
second_param)
# good
some_method(
first_param,
second_param)
Line is too long. [92/80] Open
# supervision_config = Celluloid::Supervision::Configuration.define(*config_signature)
- Exclude checks
Prefer single-quoted strings inside interpolations. Open
info "Listening to channel '#{listener_config["args"]["channel"]}' on database '#{listener_config["args"]["dbname"]}'..."
- Read upRead up
- Exclude checks
This cop checks that quotes inside the string interpolation match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
result = "Tests #{success ? "PASS" : "FAIL"}"
# good
result = "Tests #{success ? 'PASS' : 'FAIL'}"
Example: EnforcedStyle: double_quotes
# bad
result = "Tests #{success ? 'PASS' : 'FAIL'}"
# good
result = "Tests #{success ? "PASS" : "FAIL"}"
Prefer single-quoted strings inside interpolations. Open
info "Listener not active for channel '#{listener_config["args"]["channel"]}' on database '#{listener_config["args"]["dbname"]}'..."
- Read upRead up
- Exclude checks
This cop checks that quotes inside the string interpolation match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
result = "Tests #{success ? "PASS" : "FAIL"}"
# good
result = "Tests #{success ? 'PASS' : 'FAIL'}"
Example: EnforcedStyle: double_quotes
# bad
result = "Tests #{success ? 'PASS' : 'FAIL'}"
# good
result = "Tests #{success ? "PASS" : "FAIL"}"
Line is too long. [85/80] Open
@yaml_config = yaml_hash || YAML::load(ERB.new(File.read(path_to_yaml)).result)
- Exclude checks
Prefer single-quoted strings inside interpolations. Open
info "Listening to channel '#{listener_config["args"]["channel"]}' on database '#{listener_config["args"]["dbname"]}'..."
- Read upRead up
- Exclude checks
This cop checks that quotes inside the string interpolation match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
result = "Tests #{success ? "PASS" : "FAIL"}"
# good
result = "Tests #{success ? 'PASS' : 'FAIL'}"
Example: EnforcedStyle: double_quotes
# bad
result = "Tests #{success ? 'PASS' : 'FAIL'}"
# good
result = "Tests #{success ? "PASS" : "FAIL"}"
Line is too long. [124/80] Open
# config_signature = CelluloidIOPGListener::SupervisionConfigurationSignature.new(path_to_yaml: config_path).signature
- Exclude checks
Prefer single-quoted strings inside interpolations. Open
info "Listener not active for channel '#{listener_config["args"]["channel"]}' on database '#{listener_config["args"]["dbname"]}'..."
- Read upRead up
- Exclude checks
This cop checks that quotes inside the string interpolation match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
result = "Tests #{success ? "PASS" : "FAIL"}"
# good
result = "Tests #{success ? 'PASS' : 'FAIL'}"
Example: EnforcedStyle: double_quotes
# bad
result = "Tests #{success ? 'PASS' : 'FAIL'}"
# good
result = "Tests #{success ? "PASS" : "FAIL"}"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
require "celluloid-io-pg-listener/supervise_signature"
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
as: listener_config["as"],
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
if listener_config.delete("listener_active")
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Line is too long. [90/80] Open
@yaml_config = @yaml_config.dup # Don't want to mutate anything that was passed in
- Exclude checks
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
@yaml_config = @yaml_config["listening_group"] if @yaml_config["listening_group"]
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
type: listener_config["type"],
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Line is too long. [87/80] Open
@yaml_config = @yaml_config["listening_group"] if @yaml_config["listening_group"]
- Exclude checks
Do not use ::
for method calls. Open
@yaml_config = yaml_hash || YAML::load(ERB.new(File.read(path_to_yaml)).result)
- Read upRead up
- Exclude checks
This cop checks for methods invoked via the :: operator instead of the . operator (like FileUtils::rmdir instead of FileUtils.rmdir).
Example:
# bad
Timeout::timeout(500) { do_something }
FileUtils::rmdir(dir)
Marshal::dump(obj)
# good
Timeout.timeout(500) { do_something }
FileUtils.rmdir(dir)
Marshal.dump(obj)
Prefer single-quoted strings inside interpolations. Open
info "Listener not active for channel '#{listener_config["args"]["channel"]}' on database '#{listener_config["args"]["dbname"]}'..."
- Read upRead up
- Exclude checks
This cop checks that quotes inside the string interpolation match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
result = "Tests #{success ? "PASS" : "FAIL"}"
# good
result = "Tests #{success ? 'PASS' : 'FAIL'}"
Example: EnforcedStyle: double_quotes
# bad
result = "Tests #{success ? 'PASS' : 'FAIL'}"
# good
result = "Tests #{success ? "PASS" : "FAIL"}"
Use a guard clause instead of wrapping the code inside a conditional expression. Open
unless @yaml_config.nil?
- Read upRead up
- Exclude checks
Use a guard clause instead of wrapping the code inside a conditional expression
Example:
# bad
def test
if something
work
end
end
# good
def test
return unless something
work
end
# also good
def test
work if something
end
# bad
if something
raise 'exception'
else
ok
end
# good
raise 'exception' if something
ok
Prefer using YAML.safe_load
over YAML.load
. Open
@yaml_config = yaml_hash || YAML::load(ERB.new(File.read(path_to_yaml)).result)
- Read upRead up
- Exclude checks
This cop checks for the use of YAML class methods which have potential security issues leading to remote code execution when loading from an untrusted source.
Example:
# bad
YAML.load("--- foo")
# good
YAML.safe_load("--- foo")
YAML.dump("foo")