-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Write a Rubocop Cop to ensure no #p
or #puts
calls get committed to master.
#6615
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
Conversation
I love this conceptually, and presumably this would also become enabled in plugins that inherit Jekyll’s Rubocop config. (Won’t have time to do an in-depth code review today, but I am a +1) |
Oh, unclear actually. I think we'd have to add this directory to |
👍 |
Replaced remaining |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your help, @DirtyF!
lib/jekyll/commands/help.rb
Outdated
@@ -12,9 +12,9 @@ def init_with_program(prog) | |||
c.action do |args, _| | |||
cmd = (args.first || "").to_sym | |||
if args.empty? | |||
puts prog | |||
Jekyll.logger.info prog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might have to call prog.to_s
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LogAdapter converts all parameters to strings..
jekyll/lib/jekyll/log_adapter.rb
Lines 114 to 122 in 1691685
# Internal: Format the topic | |
# | |
# topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc. | |
# colon - | |
# | |
# Returns the formatted topic statement | |
def formatted_topic(topic, colon = false) | |
"#{topic}#{colon ? ": " : " "}".rjust(20) | |
end |
lib/jekyll/commands/help.rb
Outdated
elsif prog.has_command? cmd | ||
puts prog.commands[cmd] | ||
Jekyll.logger.info prog.commands[cmd] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might have to call to_s
on prog.commands[cmd]
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
rubocop/jekyll/no_p_allowed.rb
Outdated
module Cop | ||
module Jekyll | ||
class NoPAllowed < Cop | ||
MSG = "Avoid using p to print things".freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use the same message as in no_puts_allowed
that suggests Jekyll.logger instead?
test/test_filters.rb
Outdated
@@ -779,7 +779,7 @@ def to_liquid | |||
should "include the size of each grouping" do | |||
grouping = @filter.group_by(@filter.site.pages, "layout") | |||
grouping.each do |g| | |||
p< 8000 /span> g | |||
Jekyll.logger.info g |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be just removed. It's debugging.
added a output:
works fine! |
this needs some tests.. especially one for the following scenario: File.open("foo", "wb") do |f|
f.puts heredoc
end |
@jekyllbot: merge +dev |
Using
puts
orp
should be disallowed, in favor of always usingJekyll.logger
.puts
andp
are useful for debugging, but should never land on themaster
branch.In order to merge this, we need to fix a few instances of
puts
andp
!