Skip to content

Commit

Permalink
Fix Performance/FixedSize cop.
Browse files Browse the repository at this point in the history
Slightly refactored the offending code to make it more maintainable.
  • Loading branch information
hainesr committed May 1, 2018
1 parent 02674c9 commit 9f40d08
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
5 changes: 0 additions & 5 deletions .rubocop_rubyzip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ Naming/UncommunicativeMethodParamName:
Naming/VariableName:
Enabled: false

# Offense count: 2
Performance/FixedSize:
Exclude:
- 'test/ioextras/abstract_output_stream_test.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
Expand Down
16 changes: 9 additions & 7 deletions test/ioextras/abstract_output_stream_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ def teardown
end

def test_write
count = @output_stream.write('a little string')
assert_equal('a little string', @output_stream.buffer)
assert_equal('a little string'.length, count)

count = @output_stream.write('. a little more')
assert_equal('a little string. a little more', @output_stream.buffer)
assert_equal('. a little more'.length, count)
s1 = 'a little string'
count = @output_stream.write(s1)
assert_equal(s1, @output_stream.buffer)
assert_equal(s1.length, count)

s2 = '. a little more'
count = @output_stream.write(s2)
assert_equal(s1 + s2, @output_stream.buffer)
assert_equal(s2.length, count)
end

def test_print
Expand Down

0 comments on commit 9f40d08

Please sign in to comment.