-
-
Notifications
You must be signed in to change notification settings - Fork 285
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I'm using phlex(https://github.com/phlex-ruby/phlex-rails) as HTML page renderer, as full replacement of the ActionView for Rails 7 view templates.
Expected behavior
Rails/Output cop should skip replacement of the p tag wrapper method with 'Rails.logger.debug' for templates of phlex-rails gem. As I suppose, for cases when it is not methods writing to the stdout, with predefined implementation class/module.
Actual behavior
Rubocop-Rails recognises p method wrapping paragraph tag as an stdout writer method p, so replaces it with Rails.logger.debug:
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
Outup of the command bundle exec rubocop -A
app/views/components/component_partials/example_partial.rb:19:13: C: [Corrected] Rails/Output: Do not write to stdout. Use Rails's logger if you want to log.
Solved it excluding Rails/Output cop as next at the .rubocop.yml:
require:
- rubocop
- rubocop-rspec
- rubocop-rails
#...
Rails/Output:
Enabled: true
Exclude:
- app/views/**/*.rb
Steps to reproduce the problem
- Add
phlex-rails,rubocopandrubocop-railsgems to the Ruby on Rails project. - Generate any controller using
rails g phlex:controller Hello index. - Add line
p { "Some text" }to thetemplatemethod of theindexaction of theHellocontroller, expected file path is/app/views/hello/index_view.rb. - Execute
$ bundle exec rubocop -Aat the root of the project. - See results at the console and browser.
RuboCop version
- rubocop-capybara 2.18.0
- rubocop-factory_bot 2.23.1
- rubocop-rails 2.20.2
- rubocop-rake 0.6.0
- rubocop-rspec 2.22.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working