Skip to content

Commit

Permalink
Fix rubocop violations
Browse files Browse the repository at this point in the history
  • Loading branch information
cllns committed Jan 20, 2022
1 parent 63ce067 commit 77256ad
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/dry/files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lib/dry/files/file_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/support/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/unit/dry/files/file_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/dry/files/memory_file_system/node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/dry/files/memory_file_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/dry/files/path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 77256ad

Please sign in to comment.