Skip to content

Commit dbfa2f4

Browse files
committed
Avoid puts to stdout
1 parent 8e45be3 commit dbfa2f4

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lib/query_packwerk/file_cache.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ def initialize
3636
def load!(*file_names, headers: true)
3737
file_count = file_names.size
3838

39-
puts "Prepopulating AST cache with #{file_count} files: " if headers
39+
warn "Prepopulating AST cache with #{file_count} files: " if headers
4040

4141
file_names.each do |f|
4242
get_file_ast(f)
43-
print '.'
43+
$stderr.print '.'
4444
end
4545

46-
puts '', 'AST cache loaded' if headers
46+
warn '', 'AST cache loaded' if headers
4747
end
4848

4949
sig { params(cache_name: Symbol, key: T.untyped, value: T.untyped).returns(T.untyped) }

lib/query_packwerk/violations.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ def initialize(original_collection, file_cache: QueryPackwerk::FileCache.new)
8383
def load_cache!
8484
return true if @cache_loaded
8585

86-
puts "Prepopulating AST cache with #{file_count} files: "
86+
warn "Prepopulating AST cache with #{file_count} files: "
8787
start_time = Time.now
8888

8989
@original_collection.each(&:load_cache!)
9090

9191
finish_time = Time.now - start_time
92-
puts '', "AST cache loaded in #{finish_time}"
92+
warn '', "AST cache loaded in #{finish_time}"
9393
@cache_loaded = true
9494
end
9595

@@ -99,19 +99,19 @@ def load_sources!
9999

100100
unless @cache_loaded
101101
load_cache!
102-
puts
102+
warn
103103
end
104104

105-
puts "Prepopulating sources cache with #{count} violations: "
105+
warn "Prepopulating sources cache with #{count} violations: "
106106
start_time = Time.now
107107

108108
total_sources_loaded = @original_collection.sum do |violation|
109-
print '.'
109+
$stderr.print '.'
110110
violation.sources.size
111111
end
112112

113113
finish_time = Time.now - start_time
114-
puts "Loaded #{total_sources_loaded} full sources in #{finish_time}"
114+
warn "Loaded #{total_sources_loaded} full sources in #{finish_time}"
115115

116116
@sources_loaded = true
117117
end

0 commit comments

Comments
 (0)