mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
rubocop: fix offences of the Layout/SpaceInsideHashLiteralBraces cop
This commit is contained in:
parent
3f094ab428
commit
8ccb53dd72
7 changed files with 26 additions and 39 deletions
|
@ -13,21 +13,6 @@ Gemspec/RequiredRubyVersion:
|
|||
Exclude:
|
||||
- 'pry.gemspec'
|
||||
|
||||
# Offense count: 42
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
|
||||
# SupportedStyles: space, no_space, compact
|
||||
# SupportedStylesForEmptyBraces: space, no_space
|
||||
Layout/SpaceInsideHashLiteralBraces:
|
||||
Exclude:
|
||||
- 'lib/pry/commands/gem_stats.rb'
|
||||
- 'lib/pry/commands/help.rb'
|
||||
- 'spec/command_set_spec.rb'
|
||||
- 'spec/commands/gist_spec.rb'
|
||||
- 'spec/config_spec.rb'
|
||||
- 'spec/method_spec.rb'
|
||||
- 'spec/sticky_locals_spec.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
|
|
|
@ -63,12 +63,14 @@ VVVVVVVVVVVVVVVVVVVVV
|
|||
#{red('Dependencies')} (development)
|
||||
%{ddependencies}
|
||||
FORMAT
|
||||
format_str % {name: green(h.name),
|
||||
version: bold("v#{h.version}"),
|
||||
downloads: h.downloads,
|
||||
version_downloads: h.version_downloads,
|
||||
rdependencies: format_dependencies(h.dependencies.runtime),
|
||||
ddependencies: format_dependencies(h.dependencies.development)}
|
||||
format_str % {
|
||||
name: green(h.name),
|
||||
version: bold("v#{h.version}"),
|
||||
downloads: h.downloads,
|
||||
version_downloads: h.version_downloads,
|
||||
rdependencies: format_dependencies(h.dependencies.runtime),
|
||||
ddependencies: format_dependencies(h.dependencies.development)
|
||||
}
|
||||
end
|
||||
|
||||
def format_dependencies(rdeps)
|
||||
|
|
|
@ -113,7 +113,7 @@ class Pry
|
|||
if filtered.size == 1
|
||||
display_command(filtered.values.first)
|
||||
else
|
||||
display_index({"'#{search}' commands" => filtered.values})
|
||||
display_index({ "'#{search}' commands" => filtered.values })
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -138,7 +138,7 @@ class Pry
|
|||
hash.each_pair do |key, value|
|
||||
next unless key.is_a?(String)
|
||||
if normalize(key) == normalize(search)
|
||||
return {key => value}
|
||||
return { key => value }
|
||||
elsif normalize(key).start_with?(normalize(search))
|
||||
matching[key] = value
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ describe 'gist' do
|
|||
|
||||
def gist(*args)
|
||||
Pad.gist_calls[:gist_args] = args
|
||||
{'html_url' => 'http://gist.blahblah'}
|
||||
{ 'html_url' => 'http://gist.blahblah' }
|
||||
end
|
||||
|
||||
def copy(content); Pad.gist_calls[:copy_args] = content end
|
||||
|
|
|
@ -12,14 +12,14 @@ RSpec.describe Pry::Config do
|
|||
end
|
||||
|
||||
it "recursively walks a Hash" do
|
||||
h = {'foo1' => {'foo2' => {'foo3' => 'foobar'}}}
|
||||
h = { 'foo1' => { 'foo2' => { 'foo3' => 'foobar' } } }
|
||||
default = described_class.from_hash(h)
|
||||
expect(default.foo1).to be_instance_of(described_class)
|
||||
expect(default.foo1.foo2).to be_instance_of(described_class)
|
||||
end
|
||||
|
||||
it "recursively walks an Array" do
|
||||
c = described_class.from_hash(ary: [{number: 2}, Object, BasicObject.new])
|
||||
c = described_class.from_hash(ary: [{ number: 2 }, Object, BasicObject.new])
|
||||
expect(c.ary[0].number).to eq(2)
|
||||
expect(c.ary[1]).to eq(Object)
|
||||
expect(BasicObject === c.ary[2]).to be(true)
|
||||
|
@ -64,7 +64,7 @@ RSpec.describe Pry::Config do
|
|||
end
|
||||
|
||||
it "traverses through a chain of parents" do
|
||||
root = described_class.from_hash({foo: 21})
|
||||
root = described_class.from_hash({ foo: 21 })
|
||||
local1 = described_class.new(root)
|
||||
local2 = described_class.new(local1)
|
||||
local3 = described_class.new(local2)
|
||||
|
@ -128,8 +128,8 @@ RSpec.describe Pry::Config do
|
|||
|
||||
describe "#keys" do
|
||||
it "returns an array of local keys" do
|
||||
root = described_class.from_hash({zoo: "boo"}, nil)
|
||||
local = described_class.from_hash({foo: "bar"}, root)
|
||||
root = described_class.from_hash({ zoo: "boo" }, nil)
|
||||
local = described_class.from_hash({ foo: "bar" }, root)
|
||||
expect(local.keys).to eq(["foo"])
|
||||
end
|
||||
end
|
||||
|
@ -158,8 +158,8 @@ RSpec.describe Pry::Config do
|
|||
describe '#forget' do
|
||||
it 'restores a key to its default value' do
|
||||
last_default = described_class.from_hash(a: 'c')
|
||||
middle_default = described_class.from_hash({a: 'b'}, last_default)
|
||||
c = described_class.from_hash({a: 'a'}, middle_default)
|
||||
middle_default = described_class.from_hash({ a: 'b' }, last_default)
|
||||
c = described_class.from_hash({ a: 'a' }, middle_default)
|
||||
c.forget(:a)
|
||||
expect(c.a).to eq('c')
|
||||
end
|
||||
|
@ -185,13 +185,13 @@ RSpec.describe Pry::Config do
|
|||
end
|
||||
|
||||
it "merges an object who returns a Hash through #to_hash" do
|
||||
obj = Class.new { def to_hash() {epoch: 1} end }.new
|
||||
obj = Class.new { def to_hash() { epoch: 1 } end }.new
|
||||
@config.merge!(obj)
|
||||
expect(@config.epoch).to eq(1)
|
||||
end
|
||||
|
||||
it "merges an object who returns a Hash through #to_h" do
|
||||
obj = Class.new { def to_h() {epoch: 2} end }.new
|
||||
obj = Class.new { def to_h() { epoch: 2 } end }.new
|
||||
@config.merge!(obj)
|
||||
expect(@config.epoch).to eq(2)
|
||||
end
|
||||
|
@ -232,13 +232,13 @@ RSpec.describe Pry::Config do
|
|||
|
||||
describe "#[]" do
|
||||
it "traverses back to a default" do
|
||||
default = described_class.from_hash({k: 1})
|
||||
default = described_class.from_hash({ k: 1 })
|
||||
local = described_class.new(default)
|
||||
expect(local['k']).to eq(1)
|
||||
end
|
||||
|
||||
it "traverses back to a default (2 deep)" do
|
||||
default1 = described_class.from_hash({k: 1})
|
||||
default1 = described_class.from_hash({ k: 1 })
|
||||
default2 = described_class.from_hash({}, default1)
|
||||
local = described_class.new(default2)
|
||||
expect(local['k']).to eq(1)
|
||||
|
|
|
@ -35,7 +35,7 @@ describe Pry::Method do
|
|||
|
||||
def self.hello; end
|
||||
end
|
||||
meth = Pry::Method.from_str(:hello, Pry.binding_for(klass), {"instance-methods" => true})
|
||||
meth = Pry::Method.from_str(:hello, Pry.binding_for(klass), { "instance-methods" => true })
|
||||
expect(meth).to eq klass.instance_method(:hello)
|
||||
end
|
||||
|
||||
|
@ -45,7 +45,7 @@ describe Pry::Method do
|
|||
|
||||
def self.hello; end
|
||||
end
|
||||
meth = Pry::Method.from_str(:hello, Pry.binding_for(klass), {methods: true})
|
||||
meth = Pry::Method.from_str(:hello, Pry.binding_for(klass), { methods: true })
|
||||
expect(meth).to eq klass.method(:hello)
|
||||
end
|
||||
|
||||
|
@ -541,7 +541,7 @@ describe Pry::Method do
|
|||
class Object
|
||||
private
|
||||
|
||||
def my_top_level_method ; end
|
||||
def my_top_level_method; end
|
||||
alias my_other_top_level_method my_top_level_method
|
||||
end
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ describe "Sticky locals (_file_ and friends)" do
|
|||
o = Object.new
|
||||
redirect_pry_io(InputTester.new("@value = test_local",
|
||||
"exit-all")) do
|
||||
Pry.start(o, extra_sticky_locals: { test_local: proc { :john }} )
|
||||
Pry.start(o, extra_sticky_locals: { test_local: proc { :john } } )
|
||||
end
|
||||
|
||||
expect(o.instance_variable_get(:@value)).to eq :john
|
||||
|
|
Loading…
Add table
Reference in a new issue