Skip to content

Commit

Permalink
Mark RSpec/RedundantPredicateMatcher as Safe: false
Browse files Browse the repository at this point in the history
`RSpec/RedundantPredicateMatcher` cop is marked as unsafe because false positives occur
when `be_start_with` is used as a legitimate predicate matcher for `start_with?` method.

e.g., rubocop/rubocop-ast@f9e6682
  • Loading branch information
koic committed Jan 5, 2024
1 parent 297a3a2 commit e6b9bfc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Master (Unreleased)

- Mark `RSpec/RedundantPredicateMatcher` as `Safe: false`. ([@koic])

## 2.26.1 (2024-01-05)

- Fix an error for `RSpec/SharedExamples` when using examples without argument. ([@ydah])
Expand Down
1 change: 1 addition & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ RSpec/RedundantAround:
RSpec/RedundantPredicateMatcher:
Description: Checks for redundant predicate matcher.
Enabled: pending
Safe: false
VersionAdded: '2.26'
Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RedundantPredicateMatcher

Expand Down
10 changes: 8 additions & 2 deletions docs/modules/ROOT/pages/cops_rspec.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4500,14 +4500,20 @@ end
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed

| Pending
| Yes
| Yes
| No
| Yes (Unsafe)
| 2.26
| -
|===

Checks for redundant predicate matcher.

=== Safety

This cop is marked as unsafe because false positives occur
when `be_start_with` is used as a legitimate predicate matcher
for `start_with?` method.

=== Examples

[source,ruby]
Expand Down
5 changes: 5 additions & 0 deletions lib/rubocop/cop/rspec/redundant_predicate_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ module Cop
module RSpec
# Checks for redundant predicate matcher.
#
# @safety
# This cop is marked as unsafe because false positives occur
# when `be_start_with` is used as a legitimate predicate matcher
# for `start_with?` method.
#
# @example
# # bad
# expect(foo).to be_exist(bar)
Expand Down

0 comments on commit e6b9bfc

Please sign in to comment.