Skip to content

Commit

Permalink
Enable rubocop Style/MultilineBlockChain
Browse files Browse the repository at this point in the history
  • Loading branch information
ntkme committed Sep 20, 2023
1 parent 38aed32 commit dc5671b
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 130 deletions.
3 changes: 0 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,3 @@ RSpec/MultipleExpectations:

RSpec/NestedGroups:
Enabled: false

Style/MultilineBlockChain:
Enabled: false
6 changes: 4 additions & 2 deletions ext/sass/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,11 @@ module SassConfig

uri
rescue Gem::RemoteFetcher::FetchError
Gem::SpecFetcher.fetcher.detect do |name_tuple|
tuples = Gem::SpecFetcher.fetcher.detect(:released) do |name_tuple|
name_tuple.name == spec.name && name_tuple.platform == 'ruby'
end.reverse_each do |name_tuple, _|
end

tuples.sort.reverse_each do |name_tuple, _source|
uri = "#{repo}/#{name_tuple.version}/protoc-#{name_tuple.version}-#{os}-#{cpu}.exe"

Gem::RemoteFetcher.fetcher.fetch_https(URI.parse("#{uri}.sha1"))
Expand Down
5 changes: 3 additions & 2 deletions lib/sass/embedded/dispatcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ def initialize
loop do
receive_proto
rescue IOError, Errno::EBADF, Errno::EPROTO => e
@mutex.synchronize do
values = @mutex.synchronize do
@id = UINT_MAX
@observers.values
end.each do |observer|
end
values.each do |observer|
observer.error(e)
end
break
Expand Down
9 changes: 4 additions & 5 deletions spec/sass/value/argument_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,10 @@
'foo($arg...)': fn
}
).css
end.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.span.start.line).to eq(0)
expect(error.span.url).to be_nil
end
end.to raise_error(an_instance_of(Sass::CompileError).and(
having_attributes(span: having_attributes(start: having_attributes(line: 0),
url: nil))
))

expect(fn).to have_received(:call)
end
Expand Down
9 changes: 2 additions & 7 deletions spec/sass/value/calculation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,7 @@
expect do
Sass.compile_string('a {b: foo()}',
functions: { 'foo()': fn }).css
end.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.full_message).to match(/SassString or CalculationInterpolation/)
end
end.to raise_error(Sass::CompileError, /SassString or CalculationInterpolation/)
end

it 'an unknown calculation function' do
Expand All @@ -311,9 +308,7 @@
expect do
Sass.compile_string('a {b: foo()}',
functions: { 'foo()': fn }).css
end.to raise_error do |error|
expect(error.full_message).to match(/"foo" is not a recognized calculation type/)
end
end.to raise_error(/"foo" is not a recognized calculation type/)
end
end

Expand Down
9 changes: 4 additions & 5 deletions spec/sass/value/function_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@
'foo()': fn
}
)
end.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.span.start.line).to eq(0)
expect(error.span.url).to be_nil
end
end.to raise_error(an_instance_of(Sass::CompileError).and(
having_attributes(span: having_attributes(start: having_attributes(line: 0),
url: nil))
))

expect(fn).to have_received(:call)
end
Expand Down
85 changes: 37 additions & 48 deletions spec/sass_compile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,34 +228,31 @@
describe 'error' do
it 'requires plain CSS with explicit syntax' do
expect { described_class.compile_string('$a: b; c {d: $a}', syntax: 'css') }
.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.span.start.line).to eq(0)
expect(error.span.url).to be_nil
end
.to raise_error(an_instance_of(Sass::CompileError).and(
having_attributes(span: having_attributes(start: having_attributes(line: 0),
url: nil))
))
end

it 'relative loads fail without a URL' do
sandbox do |dir|
dir.write({ '_other.scss' => 'a {b: c}' })
expect { described_class.compile_string("@use \"#{dir.relative_url('other')}\";") }
.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.span.start.line).to eq(0)
expect(error.span.url).to be_nil
end
.to raise_error(an_instance_of(Sass::CompileError).and(
having_attributes(span: having_attributes(start: having_attributes(line: 0),
url: nil))
))
end
end

it 'relative loads fail with a non-file: URL' do
sandbox do |dir|
dir.write({ '_other.scss' => 'a {b: c}' })
expect { described_class.compile_string("@use \"#{dir.relative_url('other')}\";", url: 'unknown:style.scss') }
.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.span.start.line).to eq(0)
expect(error.span.url).to eq('unknown:style.scss')
end
.to raise_error(an_instance_of(Sass::CompileError).and(
having_attributes(span: having_attributes(start: having_attributes(line: 0),
url: 'unknown:style.scss'))
))
end
end

Expand All @@ -264,35 +261,32 @@
sandbox do |dir|
url = dir.url('foo.scss')
expect { described_class.compile_string('a {b:', url: url) }
.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.span.start.line).to eq(0)
expect(error.span.url).to eq(url)
end
.to raise_error(an_instance_of(Sass::CompileError).and(
having_attributes(span: having_attributes(start: having_attributes(line: 0),
url: url))
))
end
end

it 'in runtime errors' do
sandbox do |dir|
url = dir.url('foo.scss')
expect { described_class.compile_string('@error "oh no"', url: url) }
.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.span.start.line).to eq(0)
expect(error.span.url).to eq(url)
end
.to raise_error(an_instance_of(Sass::CompileError).and(
having_attributes(span: having_attributes(start: having_attributes(line: 0),
url: url))
))
end
end

it 'with multi-span errors' do
sandbox do |dir|
url = dir.url('foo.scss')
expect { described_class.compile_string('@use "sass:math"; @use "sass:math"', url: url) }
.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.span.start.line).to eq(0)
expect(error.span.url).to eq(url)
end
.to raise_error(an_instance_of(Sass::CompileError).and(
having_attributes(span: having_attributes(start: having_attributes(line: 0),
url: url))
))
end
end
end
Expand All @@ -304,9 +298,7 @@

it "doesn't throw a Sass exception for an argument error" do
expect { described_class.compile_string('a {b: c}', style: 'unrecognized style') }
.to raise_error do |error|
expect(error).not_to be_a(Sass::CompileError)
end
.not_to raise_error(Sass::CompileError)
end

it 'is an instance of StandardError' do
Expand Down Expand Up @@ -428,11 +420,10 @@
sandbox do |dir|
dir.write({ 'input.css' => '$a: b; c {d: $a}' })
expect { described_class.compile(dir.path('input.css')) }
.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.span.start.line).to eq(0)
expect(error.span.url).to eq(dir.url('input.css'))
end
.to raise_error(an_instance_of(Sass::CompileError).and(
having_attributes(span: having_attributes(start: having_attributes(line: 0),
url: dir.url('input.css')))
))
end
end

Expand All @@ -441,23 +432,21 @@
sandbox do |dir|
dir.write({ 'input.scss' => 'a {b:' })
expect { described_class.compile(dir.path('input.scss')) }
.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.span.start.line).to eq(0)
expect(error.span.url).to eq(dir.url('input.scss'))
end
.to raise_error(an_instance_of(Sass::CompileError).and(
having_attributes(span: having_attributes(start: having_attributes(line: 0),
url: dir.url('input.scss')))
))
end
end

it 'in runtime errors' do
sandbox do |dir|
dir.write({ 'input.scss' => '@error "oh no"' })
expect { described_class.compile(dir.path('input.scss')) }
.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.span.start.line).to eq(0)
expect(error.span.url).to eq(dir.url('input.scss'))
end
.to raise_error(an_instance_of(Sass::CompileError).and(
having_attributes(span: having_attributes(start: having_attributes(line: 0),
url: dir.url('input.scss')))
))
end
end
end
Expand Down
28 changes: 12 additions & 16 deletions spec/sass_function_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@
'foo()': ->(_args) { raise 'heck' }
}
)
end.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.span.start.line).to eq(0)
end
end.to raise_error(an_instance_of(Sass::CompileError).and(
having_attributes(span: having_attributes(start: having_attributes(line: 0)))
))
end

it 'not returning' do
Expand All @@ -107,10 +106,9 @@
'foo()': ->(_args) {}
}
)
end.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.span.start.line).to eq(0)
end
end.to raise_error(an_instance_of(Sass::CompileError).and(
having_attributes(span: having_attributes(start: having_attributes(line: 0)))
))
end

describe 'returning a non-Value' do
Expand All @@ -122,10 +120,9 @@
'foo()': ->(_args) { 'wrong' }
}
)
end.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.span.start.line).to eq(0)
end
end.to raise_error(an_instance_of(Sass::CompileError).and(
having_attributes(span: having_attributes(start: having_attributes(line: 0)))
))
end

it 'in a calculation' do
Expand All @@ -136,10 +133,9 @@
'foo()': ->(_args) { Sass::Value::Calculation.calc('wrong') }
}
)
end.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.span.start.line).to eq(0)
end
end.to raise_error(an_instance_of(Sass::CompileError).and(
having_attributes(span: having_attributes(start: having_attributes(line: 0)))
))
end
end
end
Expand Down
Loading

0 comments on commit dc5671b

Please sign in to comment.