Showing 528 of 528 total issues
Use SCREAMING_SNAKE_CASE for constants. Open
Asterisk = '*'.freeze
- Read upRead up
- Exclude checks
This cop checks whether constant names are written using SCREAMINGSNAKECASE.
To avoid false positives, it ignores cases in which we cannot know for certain the type of value that would be assigned to a constant.
Example:
# bad
InchInCm = 2.54
INCHinCM = 2.54
Inch_In_Cm = 2.54
# good
INCH_IN_CM = 2.54
Carriage return character detected. Open
module Fog
module Network
- Exclude checks
Avoid rescuing without specifying an error class. Open
rescue => ex
- Read upRead up
- Exclude checks
This cop checks for rescuing StandardError
. There are two supported
styles implicit
and explicit
. This cop will not register an offense
if any error other than StandardError
is specified.
Example: EnforcedStyle: implicit
# `implicit` will enforce using `rescue` instead of
# `rescue StandardError`.
# bad
begin
foo
rescue StandardError
bar
end
# good
begin
foo
rescue
bar
end
# good
begin
foo
rescue OtherError
bar
end
# good
begin
foo
rescue StandardError, SecurityError
bar
end
Example: EnforcedStyle: explicit (default)
# `explicit` will enforce using `rescue StandardError`
# instead of `rescue`.
# bad
begin
foo
rescue
bar
end
# good
begin
foo
rescue StandardError
bar
end
# good
begin
foo
rescue OtherError
bar
end
# good
begin
foo
rescue StandardError, SecurityError
bar
end
Favor a normal unless-statement over a modifier clause in a multiline statement. Open
gateway.frontend_ipconfigurations.each do |frontend_ip_config|
frontend_ip_configuration = Fog::ApplicationGateway::AzureRM::FrontendIPConfiguration.new
hash['frontend_ip_configurations'] << frontend_ip_configuration.merge_attributes(Fog::ApplicationGateway::AzureRM::FrontendIPConfiguration.parse(frontend_ip_config))
end unless gateway.frontend_ipconfigurations.nil?
- Read upRead up
- Exclude checks
Checks for uses of if/unless modifiers with multiple-lines bodies.
Example:
# bad
{
result: 'this should not happen'
} unless cond
# good
{ result: 'ok' } if cond
Use %i
or %I
for an array of symbols. Open
required_params = [
:name,
:protocol,
:frontend_port_range_start,
:frontend_port_range_end,
- Read upRead up
- Exclude checks
This cop can check for array literals made up of symbols that are not using the %i() syntax.
Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.
Configuration option: MinSize
If set, arrays with fewer elements than this value will not trigger the
cop. For example, a MinSize of
3` will not enforce a style on an array
of 2 or fewer elements.
Example: EnforcedStyle: percent (default)
# good
%i[foo bar baz]
# bad
[:foo, :bar, :baz]
Example: EnforcedStyle: brackets
# good
[:foo, :bar, :baz]
# bad
%i[foo bar baz]
Use a guard clause instead of wrapping the code inside a conditional expression. Open
unless ip_configuration.key?(:subnet_id) || ip_configuration.key?(:public_ipaddress_id)
- 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
Favor a normal unless-statement over a modifier clause in a multiline statement. Open
circuit.peerings.each do |peering|
circuit_peering = Fog::Network::AzureRM::ExpressRouteCircuitPeering.new
express_route_circuit['peerings'] << circuit_peering.merge_attributes(Fog::Network::AzureRM::ExpressRouteCircuitPeering.parse(peering))
end unless circuit.peerings.nil?
- Read upRead up
- Exclude checks
Checks for uses of if/unless modifiers with multiple-lines bodies.
Example:
# bad
{
result: 'this should not happen'
} unless cond
# good
{ result: 'ok' } if cond
Use SCREAMING_SNAKE_CASE for constants. Open
Udp = 'Udp'.freeze
- Read upRead up
- Exclude checks
This cop checks whether constant names are written using SCREAMINGSNAKECASE.
To avoid false positives, it ignores cases in which we cannot know for certain the type of value that would be assigned to a constant.
Example:
# bad
InchInCm = 2.54
INCHinCM = 2.54
Inch_In_Cm = 2.54
# good
INCH_IN_CM = 2.54
Use a guard clause instead of wrapping the code inside a conditional expression. Open
unless creation_data.key?(:create_option)
- 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
Use %i
or %I
for an array of symbols. Open
invalid_attr = [:resource_group, :name, :traffic_manager_profile_name, :id]
- Read upRead up
- Exclude checks
This cop can check for array literals made up of symbols that are not using the %i() syntax.
Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.
Configuration option: MinSize
If set, arrays with fewer elements than this value will not trigger the
cop. For example, a MinSize of
3` will not enforce a style on an array
of 2 or fewer elements.
Example: EnforcedStyle: percent (default)
# good
%i[foo bar baz]
# bad
[:foo, :bar, :baz]
Example: EnforcedStyle: brackets
# good
[:foo, :bar, :baz]
# bad
%i[foo bar baz]
Use a guard clause instead of wrapping the code inside a conditional expression. Open
if request_routing_rule.is_a?(Hash)
- 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
Favor a normal unless-statement over a modifier clause in a multiline statement. Open
gateway.ssl_certificates.each do |certificate|
ssl_certificate = Fog::ApplicationGateway::AzureRM::SslCertificate.new
hash['ssl_certificates'] << ssl_certificate.merge_attributes(Fog::ApplicationGateway::AzureRM::SslCertificate.parse(certificate))
end unless gateway.ssl_certificates.nil?
- Read upRead up
- Exclude checks
Checks for uses of if/unless modifiers with multiple-lines bodies.
Example:
# bad
{
result: 'this should not happen'
} unless cond
# good
{ result: 'ok' } if cond
Favor a normal unless-statement over a modifier clause in a multiline statement. Open
gateway.url_path_maps.each do |map|
url_path_map = Fog::ApplicationGateway::AzureRM::UrlPathMap.new
hash['url_path_maps'] << url_path_map.merge_attributes(Fog::ApplicationGateway::AzureRM::UrlPathMap.parse(map))
end unless gateway.url_path_maps.nil?
- Read upRead up
- Exclude checks
Checks for uses of if/unless modifiers with multiple-lines bodies.
Example:
# bad
{
result: 'this should not happen'
} unless cond
# good
{ result: 'ok' } if cond
Use %i
or %I
for an array of symbols. Open
required_params = [
:name,
:protocol,
:host,
:path,
- Read upRead up
- Exclude checks
This cop can check for array literals made up of symbols that are not using the %i() syntax.
Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.
Configuration option: MinSize
If set, arrays with fewer elements than this value will not trigger the
cop. For example, a MinSize of
3` will not enforce a style on an array
of 2 or fewer elements.
Example: EnforcedStyle: percent (default)
# good
%i[foo bar baz]
# bad
[:foo, :bar, :baz]
Example: EnforcedStyle: brackets
# good
[:foo, :bar, :baz]
# bad
%i[foo bar baz]
Favor a normal unless-statement over a modifier clause in a multiline statement. Open
backend_addresses.each do |ip_address|
hash['ip_addresses'] << ip_address
end unless backend_addresses.nil?
- Read upRead up
- Exclude checks
Checks for uses of if/unless modifiers with multiple-lines bodies.
Example:
# bad
{
result: 'this should not happen'
} unless cond
# good
{ result: 'ok' } if cond
Use a guard clause instead of wrapping the code inside a conditional expression. Open
if inbound_nat_rules.is_a?(Array)
- 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
Favor a normal unless-statement over a modifier clause in a multiline statement. Open
load_balancer.probes.each do |prb|
prob = Fog::Network::AzureRM::Probe.new
hash['probes'] << prob.merge_attributes(Fog::Network::AzureRM::Probe.parse(prb))
end unless load_balancer.probes.nil?
- Read upRead up
- Exclude checks
Checks for uses of if/unless modifiers with multiple-lines bodies.
Example:
# bad
{
result: 'this should not happen'
} unless cond
# good
{ result: 'ok' } if cond
Favor a normal unless-statement over a modifier clause in a multiline statement. Open
vpn_client_config.vpn_client_address_pool.each do |address_prefix|
hash['address_pool'] << address_prefix
end unless vpn_client_config.vpn_client_address_pool.nil?
- Read upRead up
- Exclude checks
Checks for uses of if/unless modifiers with multiple-lines bodies.
Example:
# bad
{
result: 'this should not happen'
} unless cond
# good
{ result: 'ok' } if cond
Use %i
or %I
for an array of symbols. Open
required_params = [
:name,
:protocol,
:source_port_range,
:destination_port_range,
- Read upRead up
- Exclude checks
This cop can check for array literals made up of symbols that are not using the %i() syntax.
Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.
Configuration option: MinSize
If set, arrays with fewer elements than this value will not trigger the
cop. For example, a MinSize of
3` will not enforce a style on an array
of 2 or fewer elements.
Example: EnforcedStyle: percent (default)
# good
%i[foo bar baz]
# bad
[:foo, :bar, :baz]
Example: EnforcedStyle: brackets
# good
[:foo, :bar, :baz]
# bad
%i[foo bar baz]
%w
-literals should be delimited by [
and ]
. Open
attribute :create_mode, aliases: %w(createMode)
- 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)