From 77256ad10f30427c502767857e12eb07f34b0e23 Mon Sep 17 00:00:00 2001 From: Sean Collins Date: Thu, 20 Jan 2022 13:14:43 -0400 Subject: [PATCH] Fix rubocop violations --- lib/dry/files.rb | 3 ++- lib/dry/files/file_system.rb | 4 ++-- spec/support/matchers.rb | 2 +- spec/unit/dry/files/file_system_spec.rb | 2 +- spec/unit/dry/files/memory_file_system/node_spec.rb | 2 +- spec/unit/dry/files/memory_file_system_spec.rb | 2 +- spec/unit/dry/files/path_spec.rb | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/dry/files.rb b/lib/dry/files.rb index 229b3c6..fe7ae65 100644 --- a/lib/dry/files.rb +++ b/lib/dry/files.rb @@ -27,7 +27,8 @@ class Files # # @since 0.1.0 # @api public - def initialize(memory: false, adapter: Adapter.call(memory: memory, newline: $INPUT_RECORD_SEPARATOR)) + def initialize(memory: false, adapter: Adapter.call(memory: memory, + newline: $INPUT_RECORD_SEPARATOR)) @adapter = adapter end diff --git a/lib/dry/files/file_system.rb b/lib/dry/files/file_system.rb index 7748d9b..725060d 100644 --- a/lib/dry/files/file_system.rb +++ b/lib/dry/files/file_system.rb @@ -29,7 +29,7 @@ class FileSystem # @return [Dry::Files::FileSystem] # # @since 0.1.0 - def initialize(file: File, file_utils: FileUtils, newline:) + def initialize(newline:, file: File, file_utils: FileUtils) @file = file @file_utils = file_utils @newline = newline @@ -95,7 +95,7 @@ def readlines(path, *args) # The last item will be an empty string if the line has a # trailing newline. We don't want that in our contents, # especially since we append a newline to every line during `write` - if lines.last&.empty? + if lines.last && lines.last.empty? lines[0..-2] else lines diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index 6a4e0be..18c5463 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -28,6 +28,6 @@ end failure_message do |actual| - "expected that `#{actual}' would have content '#{expected}', but it has '#{subject.read(actual)}'" # rubocop:disable Layout/LineLength + "expected that `#{actual}' would have content '#{expected}', but it has '#{subject.read(actual)}'" end end diff --git a/spec/unit/dry/files/file_system_spec.rb b/spec/unit/dry/files/file_system_spec.rb index c91b33b..3a83ccf 100644 --- a/spec/unit/dry/files/file_system_spec.rb +++ b/spec/unit/dry/files/file_system_spec.rb @@ -88,7 +88,7 @@ path = root.join("readlines-file") subject.write(path, "hello#{newline}world") - expect(subject.readlines(path)).to eq(%W[hello world]) + expect(subject.readlines(path)).to eq(%w[hello world]) end it "reads empty file and returns empty array" do diff --git a/spec/unit/dry/files/memory_file_system/node_spec.rb b/spec/unit/dry/files/memory_file_system/node_spec.rb index cf5f819..b4f07ab 100644 --- a/spec/unit/dry/files/memory_file_system/node_spec.rb +++ b/spec/unit/dry/files/memory_file_system/node_spec.rb @@ -144,7 +144,7 @@ expect(subject.readlines).to eq(["foo"]) subject.write(%w[foo bar]) - expect(subject.readlines).to eq(["foo", "bar"]) + expect(subject.readlines).to eq(%w[foo bar]) end it "raises error when not file" do diff --git a/spec/unit/dry/files/memory_file_system_spec.rb b/spec/unit/dry/files/memory_file_system_spec.rb index f11f930..cb83e7b 100644 --- a/spec/unit/dry/files/memory_file_system_spec.rb +++ b/spec/unit/dry/files/memory_file_system_spec.rb @@ -74,7 +74,7 @@ path = subject.join("readlines-file") subject.write(path, "hello#{newline}world") - expect(subject.readlines(path)).to eq(%W[hello world]) + expect(subject.readlines(path)).to eq(%w[hello world]) end it "reads empty file and returns empty array" do diff --git a/spec/unit/dry/files/path_spec.rb b/spec/unit/dry/files/path_spec.rb index c29e5c1..76c160f 100644 --- a/spec/unit/dry/files/path_spec.rb +++ b/spec/unit/dry/files/path_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Dry::Files::Path do describe ".call" do let(:unix_file_separator) { "/" } - let(:windows_file_separator) { '\\' } + let(:windows_file_separator) { "\\" } context "when string" do it "recombines given path with system file separator" do