Skip to content

Commit 6afc368

Browse files
committed
Suppress RuboCop output when there are no offenses in code generation
Follow up rails#51782. > But it's overkill for the default case where people use the default style guide, > and it introduces both delay and console output as a cost. When there are no offenses with the coding style generated by code generation, outputting RuboCop results to the console was redundant. Since RuboCop has `--format=quiet` option that suppresses console output when there are no offenses, this PR adds that option: https://docs.rubocop.org/rubocop/1.63/formatters.html#quiet-formatter While this PR doesn't resolve any added execution speed by RuboCop, the frequency of using the generator is not high within the development flow. Therefore, depending on the execution speed, it might be possible to uncomment rails#51782, but this PR respects the defaults in rails#51782 and doesn't address that.
1 parent dae4867 commit 6afc368

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

railties/lib/rails/configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def apply_rubocop_autocorrect_after_generate!
135135
after_generate do |files|
136136
parsable_files = files.filter { |file| File.exist?(file) && file.end_with?(".rb") }
137137
unless parsable_files.empty?
138-
system(RbConfig.ruby, "bin/rubocop", "-A", "--fail-level=E", *parsable_files, exception: true)
138+
system(RbConfig.ruby, "bin/rubocop", "-A", "--fail-level=E", "--format=quiet", *parsable_files, exception: true)
139139
end
140140
end
141141
end

railties/test/application/generators_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def check_expected
263263
end
264264

265265
output = rails("generate", "model", "post", "title:string", "body:string")
266-
assert_match(/3 files inspected, no offenses detected/, output)
266+
assert_no_match(/3 files inspected, no offenses detected/, output)
267267
end
268268

269269
test "generators with apply_rubocop_autocorrect_after_generate! and pretend" do

0 commit comments

Comments
 (0)