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

Rubocop replaces tag p method, with Rails.logger.debug #100

Closed
sbezugliy opened this issue Jul 1, 2023 · 3 comments
Closed

Rubocop replaces tag p method, with Rails.logger.debug #100

sbezugliy opened this issue Jul 1, 2023 · 3 comments

Comments

@sbezugliy
Copy link

sbezugliy commented Jul 1, 2023

Rubocop recognizes p wrapper method of the HTML paragraph tag as a stdout writer method p.

As, example:

div do  
  p { "Some text" }
  p(){ "Some text" }
end

Replaces with:

div do  
  Rails.logger.debug { "Some text" }
  Rails.logger.debug { "Some text" }
end
app/views/components/footer_partials/copyrights_section.rb:19:13: C: [Corrected] Rails/Output: Do not write to stdout. Use Rails's logger if you want to log.

Solution to Exclude Rails/Output cop as next at the .rubocop.yml:

require:
  - rubocop
  - rubocop-rspec
  - rubocop-rails

#...

Rails/Output:
  Enabled: true
  Exclude:
    - app/views/**/*.rb

May redefinition of stdout method p with tag method p create some potential problems?

Also I did open issue at the rubcop-rails (rubocop/rubocop-rails#1041)

@joeldrapper
Copy link
Collaborator

Thanks for opening the issue with Rubocop. They seem to have some very aggressive rules by default. I’d be open to adding an alias for p such as para for folks that want to be able to use p for debugging.

@sbezugliy
Copy link
Author

I'll look at rubocop-rails on part of adding check at this cop to skip instances of Plex-Ruby.

@joeldrapper
Copy link
Collaborator

@sbezugliy I’m going to close this for now. If rubocop-rails don't want to add a special case, I recommend getting around it by just adding alias_method :para, :p to your ApplicationView and then using para instead of p.

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

2 participants