Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation for Lint/UselessSetterCall #7702

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* [#7641](https://github.com/rubocop-hq/rubocop/issues/7641): **(Breaking)** Remove `Style/BracesAroundHashParameters` cop. ([@pocke][])
* Add the method name to highlight area of `Layout/EmptyLineBetweenDefs` to help provide more context. ([@rrosenblum][])
* [#7652](https://github.com/rubocop-hq/rubocop/pull/7652): Allow `pp` to allowed names of `Naming/MethodParameterName` cop in default config. ([@masarakki][])
* [#7309](https://github.com/rubocop-hq/rubocop/pull/7309): Mark `Lint/UselessSetterCall` an "not safe" and improve documentation. ([@jonas054][])

## 0.79.0 (2020-01-06)

Expand Down
2 changes: 2 additions & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,8 @@ Lint/UselessSetterCall:
Description: 'Checks for useless setter call to a local variable.'
Enabled: true
VersionAdded: '0.13'
VersionChanged: '0.80'
Safe: false

Lint/Void:
Description: 'Possible use of operator/literal/variable in void context.'
Expand Down
4 changes: 4 additions & 0 deletions lib/rubocop/cop/lint/useless_setter_call.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ module Lint
# This cop checks for setter call to local variable as the final
# expression of a function definition.
#
# Note: There are edge cases in which the local variable references a
# value that is also accessible outside the local scope. This is not
# detected by the cop, and it can yield a false positive.
#
# @example
#
# # bad
Expand Down
6 changes: 5 additions & 1 deletion manual/cops_lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -2946,11 +2946,15 @@ end

Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
--- | --- | --- | --- | ---
Enabled | Yes | No | 0.13 | -
Enabled | No | No | 0.13 | 0.80

This cop checks for setter call to local variable as the final
expression of a function definition.

Note: There are edge cases in which the local variable references a
value that is also accessible outside the local scope. This is not
detected by the cop, and it can yield a false positive.

### Examples

```ruby
Expand Down