A RetroSearch Logo

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

Search Query:

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

Naming/PredicateMethod should not be triggered by nonzero? · Issue #14318 · rubocop/rubocop · GitHub

Expected behavior
def default_tax
  owner.tax.nonzero?
end

This code shouldn't suggest renaming the method to defalt_tax?. Despite its name, nonzero? is not a predicate; its protocol is "return a number if it isn't zero, or nil otherwise".

While many might consider it idiosyncratic, it is a Ruby core method, heavily used by some codebases 🤷

Actual behavior
Naming/PredicateMethod: Predicate method names should end with ?.
  def default_tax
      ^^^^^^^^^^^
RuboCop version
$ [bundle exec] rubocop -V
1.77.0 (using Parser 3.3.8.0, Prism 1.4.0, rubocop-ast 1.45.1, analyzing as Ruby 3.3, running on ruby 3.3.8) [x86_64-linux]
  - rubocop-rspec 3.6.0
  - rubocop-rails 2.32.0
  - rubocop-performance 1.25.0
  - rubocop-rake 0.7.1
  - rubocop-capybara 2.22.1
  - rubocop-rspec_rails 2.31.0
  - rubocop-factory_bot 2.27.1
  - rubocop-graphql 1.1.1

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