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

Fix a false positive for Naming/AccessorMethodName with type of the first argument is other than arg #10674

Merged

Conversation

ydah
Copy link
Member

@ydah ydah commented May 27, 2022

This PR is fixed based on a similar problem: #10574

Naming/AccessorMethodName should only inform offense
if the type of the first argument is arg.

# Bad
def set_something(arg)
  # ...
end

# Good
def set_something(arg = :default)
  # ...
end

def set_something(*args)
  # ...
end

def set_something(k: v)
  # ...
end

def set_something(k:)
  # ...
end

def set_something(**options)
  # ...
end

def set_something(&block)
  # ...
end

def set_something(...)
  # ...
end

Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
    * [ ] Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@ydah ydah force-pushed the fix_a_false_positive_accessor_method_name branch from 0b0e017 to 707d927 Compare May 27, 2022 11:37
@ydah ydah marked this pull request as ready for review May 27, 2022 11:40
@ydah ydah force-pushed the fix_a_false_positive_accessor_method_name branch from 707d927 to f05460d Compare May 31, 2022 21:54
@ydah ydah changed the title Fix a false positive for Naming/AccessorMethodName with arguments forwarding Fix a false positive for Naming/AccessorMethodName with type of the first argument is other than arg May 31, 2022
@ydah ydah requested a review from koic May 31, 2022 21:58
… first argument is other than `arg`

`Naming/AccessorMethodName` should only inform offense
if the type of the first argument is `arg`.

```ruby
# Bad
def set_something(arg)
  # ...
end

# Good
def set_something(arg = :default)
  # ...
end

def set_something(*args)
  # ...
end

def set_something(k: v)
  # ...
end

def set_something(k:)
  # ...
end

def set_something(**options)
  # ...
end

def set_something(&block)
  # ...
end

def set_something(...)
  # ...
end
```
@ydah ydah force-pushed the fix_a_false_positive_accessor_method_name branch from a2cc5f0 to a83732b Compare June 1, 2022 04:54
@ydah ydah requested a review from koic June 1, 2022 04:55
@koic koic merged commit a5de777 into rubocop:master Jun 1, 2022
@koic
Copy link
Member

koic commented Jun 1, 2022

Thanks!

@ydah ydah deleted the fix_a_false_positive_accessor_method_name branch June 1, 2022 10:15
@ydah ydah restored the fix_a_false_positive_accessor_method_name branch June 1, 2022 10:15
@ydah ydah deleted the fix_a_false_positive_accessor_method_name branch January 26, 2023 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants