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

Make Lint/RedundantStringCoercion aware of print method arguments #11779

Conversation

koic
Copy link
Member

@koic koic commented Apr 9, 2023

This PR makes Lint/RedundantStringCoercion aware of print method arguments. The name of this cop is "RedundantStringCoercion", so it makes more sense to extend the feature than to provide a new cop I think.


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.

@koic koic force-pushed the make_lint_redundant_string_coercion_aware_of_print_method_arguments branch 2 times, most recently from b8019cd to f19a214 Compare April 10, 2023 02:15
# which is redundant.
#
# @example
#
# # bad
#
# "result is #{something.to_s}"
# print something.to_s
# puts something.to_s
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems you forgot warn something.to_s here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I've added it.

@bbatsov
Copy link
Collaborator

bbatsov commented Apr 10, 2023

The name of this cop is "RedundantStringCoercion", so it makes more sense to extend the feature than to provide a new cop I think.

Totally agree.

This PR makes `Lint/RedundantStringCoercion` aware of print method arguments.
The name of this cop is "RedundantStringCoercion", so it makes more sense to
extend the feature than to provide a new cop I think.
@koic koic force-pushed the make_lint_redundant_string_coercion_aware_of_print_method_arguments branch from f19a214 to d3d7061 Compare April 11, 2023 01:56
@bbatsov bbatsov merged commit d2bbe3a into rubocop:master Apr 11, 2023
11 checks passed
@koic koic deleted the make_lint_redundant_string_coercion_aware_of_print_method_arguments branch April 11, 2023 05:05
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