Use response.blank?
instead of response.nil? || response.empty?
. Open
return nil if response.nil? || response.empty?
- Read upRead up
- Exclude checks
This cops checks for code that can be changed to blank?
.
Settings:
NilOrEmpty: Convert checks for nil
or empty?
to blank?
NotPresent: Convert usages of not present?
to blank?
UnlessPresent: Convert usages of unless
present?
to blank?
Example:
# NilOrEmpty: true
# bad
foo.nil? || foo.empty?
foo == nil || foo.empty?
# good
foo.blank?
# NotPresent: true
# bad
!foo.present?
# good
foo.blank?
# UnlessPresent: true
# bad
something unless foo.present?
unless foo.present?
something
end
# good
something if foo.blank?
if foo.blank?
something
end
Use response.blank?
instead of response.nil? || response.empty?
. Open
return 0, 0 if response.nil? || response.empty?
- Read upRead up
- Exclude checks
This cops checks for code that can be changed to blank?
.
Settings:
NilOrEmpty: Convert checks for nil
or empty?
to blank?
NotPresent: Convert usages of not present?
to blank?
UnlessPresent: Convert usages of unless
present?
to blank?
Example:
# NilOrEmpty: true
# bad
foo.nil? || foo.empty?
foo == nil || foo.empty?
# good
foo.blank?
# NotPresent: true
# bad
!foo.present?
# good
foo.blank?
# UnlessPresent: true
# bad
something unless foo.present?
unless foo.present?
something
end
# good
something if foo.blank?
if foo.blank?
something
end
TODO found Open
# TODO: remove unexisting/cancelled event. Need administration
- Exclude checks
TODO found Open
# TODO: write tests for class
- Exclude checks
Use performances.results.count.positive?
instead of performances.results.count > 0
. Open
next unless performances.status == 'ok' && performances.results.count > 0
- Read upRead up
- Exclude checks
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
Missing magic comment # frozen_string_literal: true
. Open
require 'songkickr'
- Read upRead up
- Exclude checks
This cop is designed to help upgrade to Ruby 3.0. It will add the
comment # frozen_string_literal: true
to the top of files to
enable frozen string literals. Frozen string literals may be default
in Ruby 3.0. The comment will be added below a shebang and encoding
comment. The frozen string literal comment is only valid in Ruby 2.3+.
Example: EnforcedStyle: when_needed (default)
# The `when_needed` style will add the frozen string literal comment
# to files only when the `TargetRubyVersion` is set to 2.3+.
# bad
module Foo
# ...
end
# good
# frozen_string_literal: true
module Foo
# ...
end
Example: EnforcedStyle: always
# The `always` style will always add the frozen string literal comment
# to a file, regardless of the Ruby version or if `freeze` or `<<` are
# called on a string literal.
# bad
module Bar
# ...
end
# good
# frozen_string_literal: true
module Bar
# ...
end
Example: EnforcedStyle: never
# The `never` will enforce that the frozen string literal comment does
# not exist in a file.
# bad
# frozen_string_literal: true
module Baz
# ...
end
# good
module Baz
# ...
end