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

Lint/Debugger should not allow pry #11658

Closed
ThHareau opened this issue Mar 3, 2023 · 6 comments
Closed

Lint/Debugger should not allow pry #11658

ThHareau opened this issue Mar 3, 2023 · 6 comments

Comments

@ThHareau
Copy link
Contributor

ThHareau commented Mar 3, 2023

Is your feature request related to a problem? Please describe.

Lint/Debugger is allowing pry. This is annoying because it should not go to production, and I would rather have it rejected, similary to a binding.pry

Describe the solution you'd like

Rubocop is unhappy when pry is in the code

Describe alternatives you've considered

Additional context

I think a solution would be to include the pry keyword in the config : https://github.com/rubocop/rubocop/blob/master/config/default.yml#LL1654-L1661.

If you're ok with this I can do a PR. It seems also, according to the tests, that it was left out on purpose. Is there a specific reason for it?

@fatkodima
Copy link
Contributor

From which library pry is coming from?

@koic
Copy link
Member

koic commented Mar 4, 2023

It seems also, according to the tests, that it was left out on purpose. Is there a specific reason for it?

@dvandersluis It looks like the test added in the following PR. Do you remember why expect_no_offenses('pry') was written?
https://github.com/rubocop/rubocop/pull/9504/files#diff-6b94f0f83e7ddc601d87c0822fd77f0b55746b8f73324b79f1e7f3a355f48bf8R186-R188

@dvandersluis
Copy link
Member

The pry gem doesn’t add pry as a top level method as far as I’m aware. Is it coming from somewhere else?

I don’t remember specifically but the test was probably added to make sure methods defined in the config with receivers are not registered without them.

@koic
Copy link
Member

koic commented Mar 4, 2023

Pry gem has Object#pry that starts a Pry REPL.
https://github.com/pry/pry/blob/v0.14.2/lib/pry/core_extensions.rb#L43-L49

It can be confirmed with the code below:

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'

  gem 'pry'
end

forty_two = 42
pry
% ruby example.rb
[1] pry(main)> forty_two
=> 42

@dvandersluis
Copy link
Member

Fair enough! Generally people would use binding.pry there instead of just pry.

@ThHareau
Copy link
Contributor Author

ThHareau commented Mar 6, 2023

PR is here if someone wants to have a look :) #11669

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

No branches or pull requests

4 participants