A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/rubocop/rubocop/issues/14333 below:

The `Naming/PredicateMethod` cop ignores implicit nil return. · Issue #14333 · rubocop/rubocop · GitHub

A method that returns true, false and implicit nil is flagged as a predicate method.

def foo
  case @foo
  when "bar" then true
  when "baz" then false
  end
end

Changing the method body to an explicit nil return fixes the offence.

def foo
  case @foo
  when "bar" then true
  when "baz" then false
  else nil
  end
end

But raises the Style/EmptyElse offence.

Expected behavior

My expectation is there for the foo not to cause the Naming/PredicateMethod offence. This is a conversion method that, for certain values, returns a boolean value.

Actual behavior

The foo method causes the Naming/PredicateMethod offence despite not being a predicate method.

Steps to reproduce the problem

Please see the description.

RuboCop version
$ [bundle exec] rubocop -V
1.77.0 (using Parser 3.3.8.0, rubocop-ast 1.45.1, analyzing as Ruby 3.4, running on ruby 3.4.2)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4