diff --git a/.rubocop.yml b/.rubocop.yml index 7681dd0..da005a9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -11,3 +11,12 @@ Metrics/LineLength: # Allow classes longer than 100 lines of code ClassLength: Max: 250 + +Naming/UncommunicativeMethodParamName: + Enabled: false + +Lint/UnneededCopDisableDirective: + Enabled: false + +Layout/ClosingHeredocIndentation: + Enabled: false diff --git a/diplomat.gemspec b/diplomat.gemspec index 14fb050..fdf2e6d 100644 --- a/diplomat.gemspec +++ b/diplomat.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new 'diplomat', Diplomat::VERSION do |spec| spec.add_development_dependency 'pry', '~> 0.9' spec.add_development_dependency 'rake', '~> 12.0' spec.add_development_dependency 'rspec', '~> 3.2' - spec.add_development_dependency 'rubocop', '~> 0.47', '>= 0.47.1' + spec.add_development_dependency 'rubocop', '~> 0.49' spec.add_runtime_dependency 'faraday', '~> 0.9' spec.add_runtime_dependency 'json' if RUBY_VERSION < '1.9.3' diff --git a/lib/diplomat.rb b/lib/diplomat.rb index e18f451..30ad53f 100644 --- a/lib/diplomat.rb +++ b/lib/diplomat.rb @@ -23,8 +23,8 @@ def require_libs(*libs) raise 'Diplomat only supports ruby >= 2.0.0' unless RUBY_VERSION.to_f >= 2.0 - self.root_path = File.expand_path '..', __FILE__ - self.lib_path = File.expand_path '../diplomat', __FILE__ + self.root_path = File.expand_path __dir__ + self.lib_path = File.expand_path 'diplomat', __dir__ require_libs 'configuration', 'rest_client', 'api_options', 'kv', 'datacenter', 'service', 'members', 'node', 'nodes', 'check', 'health', 'session', 'lock', diff --git a/lib/diplomat/kv.rb b/lib/diplomat/kv.rb index 64c070b..9db65d6 100644 --- a/lib/diplomat/kv.rb +++ b/lib/diplomat/kv.rb @@ -256,7 +256,7 @@ def decode_transaction(transaction) # rubocop:disable Metrics/MethodLength next unless resp['KV']['Value'] begin resp['KV']['Value'] = Base64.decode64(resp['KV']['Value']) - rescue # rubocop:disable RescueWithoutErrorClass + rescue StandardError nil end end diff --git a/lib/diplomat/rest_client.rb b/lib/diplomat/rest_client.rb index efbee4a..414983c 100644 --- a/lib/diplomat/rest_client.rb +++ b/lib/diplomat/rest_client.rb @@ -143,7 +143,7 @@ def decode_values @raw.each_with_object([]) do |acc, el| begin acc['Value'] = Base64.decode64(acc['Value']) - rescue # rubocop:disable RescueWithoutErrorClass + rescue StandardError nil end el << acc diff --git a/lib/diplomat/service.rb b/lib/diplomat/service.rb index 30e1f80..fc2704a 100644 --- a/lib/diplomat/service.rb +++ b/lib/diplomat/service.rb @@ -117,6 +117,5 @@ def maintenance(service_id, options = { enable: true }) end maintenance.status == 200 end - # rubocop:enable AbcSize end end diff --git a/spec/agent_spec.rb b/spec/agent_spec.rb index 09f233d..e9a8052 100644 --- a/spec/agent_spec.rb +++ b/spec/agent_spec.rb @@ -1,13 +1,14 @@ require 'spec_helper' require 'json' require 'base64' - +# rubocop:disable describe Diplomat::Agent do let(:faraday) { fake } context 'agent' do it 'self' do - faraday.stub(:get).and_return(OpenStruct.new(body: <<-JSON)) + faraday.stub(:get) + .and_return(OpenStruct.new(body: <<-JSON)) { "Config": { "Bootstrap": true, @@ -73,7 +74,7 @@ "DelegateCur": 4 } } - JSON + JSON agent = Diplomat::Agent.new(faraday) @@ -81,7 +82,8 @@ end it 'checks' do - faraday.stub(:get).and_return(OpenStruct.new(body: <<-JSON)) + faraday.stub(:get) + .and_return(OpenStruct.new(body: <<-JSON)) { "service:redis": { "Node": "foobar", @@ -94,7 +96,7 @@ "ServiceName": "redis" } } - JSON + JSON agent = Diplomat::Agent.new(faraday) @@ -102,7 +104,8 @@ end it 'services' do - faraday.stub(:get).and_return(OpenStruct.new(body: <<-JSON)) + faraday.stub(:get) + .and_return(OpenStruct.new(body: <<-JSON)) { "redis": { "ID": "redis", @@ -112,7 +115,7 @@ "Port": 8000 } } - JSON + JSON agent = Diplomat::Agent.new(faraday) @@ -120,7 +123,8 @@ end it 'members' do - faraday.stub(:get).and_return(OpenStruct.new(body: <<-JSON)) + faraday.stub(:get) + .and_return(OpenStruct.new(body: <<-JSON)) [ { "Name": "foobar", @@ -141,7 +145,7 @@ "DelegateCur": 3 } ] - JSON + JSON agent = Diplomat::Agent.new(faraday) @@ -150,3 +154,4 @@ end end end +# rubocop:enable