lib/coverband/adapters/file_store.rb in coverband-1.5.4 vs lib/coverband/adapters/file_store.rb in coverband-2.0.0.alpha
- old
+ new
@@ -1,30 +1,30 @@
+# frozen_string_literal: true
+
module Coverband
module Adapters
class FileStore
attr_accessor :path
- def initialize(path, opts = {})
+ def initialize(path, _opts = {})
@path = path
config_dir = File.dirname(@path)
Dir.mkdir config_dir unless File.exist?(config_dir)
end
def clear!
- if File.exist?(path)
- File.delete(path)
- end
+ File.delete(path) if File.exist?(path)
end
def save_report(report)
results = existing_data(path)
report.each_pair do |file, values|
- if results.has_key?(file)
+ if results.key?(file)
# convert the keys to "3" opposed to 3
values = JSON.parse(values.to_json)
- results[file].merge!( values ){|k, old_v, new_v| old_v.to_i + new_v.to_i}
+ results[file].merge!(values) { |_k, old_v, new_v| old_v.to_i + new_v.to_i }
else
results[file] = values
end
end
File.open(path, 'w') { |f| f.write(results.to_json) }
@@ -51,9 +51,8 @@
JSON.parse(File.read(path))
else
{}
end
end
-
end
end
end