Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/code_metrics/statistics_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def add(code_metrics_calculator)
end

def add_by_file_path(file_path)
File.open(file_path) do |f|
file_flags = 'r:UTF-8'
file_flags << ':UTF-8' unless defined?(Encoding) && Encoding.default_internal == Encoding::UTF_8
File.open(file_path, file_flags) do |f|
self.add_by_io(f, file_type(file_path))
end
end
Expand All @@ -51,6 +53,7 @@ def add_by_io(io, file_type)
comment_started = false

while line = io.gets
line.encode!('UTF-8', 'UTF-8', :invalid => :replace) if line.respond_to?(:encode!)
@lines += 1

if comment_started
Expand Down