Skip to content

Commit d8360ec

Browse files
committed
Lint; mostly code reformatting
1 parent 7aea7af commit d8360ec

24 files changed

+240
-221
lines changed

.rubocop.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ inherit_from: .rubocop_todo.yml
44

55
AllCops:
66
TargetRubyVersion: 1.9
7+
Exclude:
8+
- 'spec/**/*'
9+
- 'benchmarking/**/*'
10+
- 'support/**/*'
11+
- 'integration/**/*'
12+
- 'features/**/*'
13+
- 'tmp/**/*'
714

815
# We shouldn't rescue Exception!
916
Lint/RescueException:
@@ -20,6 +27,12 @@ Metrics/ModuleLength:
2027
Metrics/ClassLength:
2128
Enabled: false
2229

30+
Metrics/ParameterLists:
31+
Enabled: false
32+
33+
Style/MultilineBlockLayout:
34+
Enabled: false
35+
2336
Style/MultilineTernaryOperator:
2437
Enabled: false
2538

Gemfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ source 'https://rubygems.org/'
22

33
gemspec
44

5-
gem 'snappy', :group => [:development, :test]
6-
gem 'lz4-ruby', :group => [:development, :test]
7-
gem 'rake-compiler', :group => [:development, :test]
8-
gem 'cliver', :group => [:development, :test]
5+
gem 'snappy', group: [:development, :test]
6+
gem 'lz4-ruby', group: [:development, :test]
7+
gem 'rake-compiler', group: [:development, :test]
8+
gem 'cliver', group: [:development, :test]
99

1010
group :development do
1111
platforms :mri_19 do

Rakefile

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ require 'cucumber/rake/task'
77
require 'rake/testtask'
88
require 'bundler/gem_tasks'
99

10-
ENV["FAIL_FAST"] ||= 'Y'
10+
ENV['FAIL_FAST'] ||= 'Y'
1111

12-
RSpec::Core::RakeTask.new(:rspec => :compile)
12+
RSpec::Core::RakeTask.new(rspec: :compile)
1313

14-
Cucumber::Rake::Task.new(:cucumber => :compile)
14+
Cucumber::Rake::Task.new(cucumber: :compile)
1515

1616
desc 'Run all tests'
17-
task :test => [:rspec, :integration, :cucumber]
17+
task test: [:rspec, :integration, :cucumber]
1818

19-
ruby_engine = defined?(RUBY_ENGINE)? RUBY_ENGINE : 'ruby'
19+
ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
2020

2121
case ruby_engine
2222
when 'jruby'
@@ -29,19 +29,19 @@ else
2929
Rake::ExtensionTask.new('cassandra_murmur3')
3030
end
3131

32-
Rake::TestTask.new(:integration => :compile) do |t|
33-
t.libs.push "lib"
32+
Rake::TestTask.new(integration: :compile) do |t|
33+
t.libs.push 'lib'
3434
t.test_files = FileList['integration/*_test.rb',
35-
'integration/security/*_test.rb',
36-
'integration/load_balancing/*_test.rb',
37-
'integration/types/*_test.rb',
38-
'integration/functions/*_test.rb',
39-
'integration/indexes/*_test.rb']
35+
'integration/security/*_test.rb',
36+
'integration/load_balancing/*_test.rb',
37+
'integration/types/*_test.rb',
38+
'integration/functions/*_test.rb',
39+
'integration/indexes/*_test.rb']
4040
t.verbose = true
4141
end
4242

43-
Rake::TestTask.new(:stress => :compile) do |t|
44-
t.libs.push "lib"
43+
Rake::TestTask.new(stress: :compile) do |t|
44+
t.libs.push 'lib'
4545
t.test_files = FileList['integration/stress_tests/*_test.rb']
4646
t.verbose = true
4747
end

cassandra-driver.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# encoding: utf-8
22

3-
$: << File.expand_path('../lib', __FILE__)
3+
$LOAD_PATH << File.expand_path('../lib', __FILE__)
44

55
require 'cassandra/version'
66

@@ -10,8 +10,8 @@ Gem::Specification.new do |s|
1010
s.authors = ['Theo Hultberg', 'Bulat Shakirzyanov', 'Sandeep Tamhankar']
1111
1212
s.homepage = 'http://datastax.github.io/ruby-driver'
13-
s.summary = %q{Datastax Ruby Driver for Apache Cassandra}
14-
s.description = %q{A pure Ruby driver for Apache Cassandra}
13+
s.summary = 'Datastax Ruby Driver for Apache Cassandra'
14+
s.description = 'A pure Ruby driver for Apache Cassandra'
1515
s.license = 'Apache License 2.0'
1616
s.files = Dir['lib/**/*.rb', 'README.md', '.yardopts']
1717
s.require_paths = %w(lib)

docs.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ rewrites:
2323
replace: http://docs.datastax.com/en/cql/3.3/cql/cql_using/useAboutCQL.html
2424
- search: https://datastax.github.io/java-driver/features
2525
replace: https://datastax.github.io/java-driver/manual
26+
- search: http://dsdocs30_java
27+
replace: http://docs.datastax.com/en/developer/java-driver/3.0
2628
links:
2729
- title: Code
2830
href: https://github.com/datastax/ruby-driver/

lib/cassandra.rb

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -528,12 +528,11 @@ def self.validate_and_massage_options(options)
528528
if options.key?(:execution_profiles)
529529
options[:execution_profiles].each do |name, profile|
530530
timeout = profile.timeout
531-
unless timeout.nil?
532-
Util.assert_instance_of(::Numeric, timeout,
533-
":timeout of execution profile #{name} must be a number of seconds, " \
534-
"#{timeout.inspect} given")
535-
Util.assert(timeout > 0, ":timeout of execution profile #{name} must be greater than 0, #{timeout} given")
536-
end
531+
next if timeout.nil?
532+
Util.assert_instance_of(::Numeric, timeout,
533+
":timeout of execution profile #{name} must be a number of seconds, " \
534+
"#{timeout.inspect} given")
535+
Util.assert(timeout > 0, ":timeout of execution profile #{name} must be greater than 0, #{timeout} given")
537536
end
538537
end
539538

@@ -599,12 +598,11 @@ def self.validate_and_massage_options(options)
599598
:distance, :plan]
600599
options[:execution_profiles].each do |name, profile|
601600
load_balancing_policy = profile.load_balancing_policy
602-
unless load_balancing_policy.nil?
603-
Util.assert_responds_to_all(methods, load_balancing_policy,
604-
":load_balancing_policy in execution profile #{name} #{load_balancing_policy.inspect} must respond " \
605-
"to #{methods.inspect}, but doesn't"
606-
)
607-
end
601+
next if load_balancing_policy.nil?
602+
Util.assert_responds_to_all(methods, load_balancing_policy,
603+
":load_balancing_policy in execution profile #{name} " \
604+
"#{load_balancing_policy.inspect} must respond " \
605+
"to #{methods.inspect}, but doesn't")
608606
end
609607
end
610608

@@ -629,12 +627,10 @@ def self.validate_and_massage_options(options)
629627
methods = [:read_timeout, :write_timeout, :unavailable]
630628
options[:execution_profiles].each do |name, profile|
631629
retry_policy = profile.retry_policy
632-
unless retry_policy.nil?
633-
Util.assert_responds_to_all(methods, retry_policy,
634-
":retry_policy in execution profile #{name} #{retry_policy.inspect} must " \
635-
"respond to #{methods.inspect}, but doesn't"
636-
)
637-
end
630+
next if retry_policy.nil?
631+
Util.assert_responds_to_all(methods, retry_policy,
632+
":retry_policy in execution profile #{name} #{retry_policy.inspect} must " \
633+
"respond to #{methods.inspect}, but doesn't")
638634
end
639635
end
640636

@@ -643,19 +639,16 @@ def self.validate_and_massage_options(options)
643639
if options.key?(:consistency)
644640
consistency = options[:consistency]
645641
Util.assert_one_of(CONSISTENCIES, consistency,
646-
":consistency must be one of #{CONSISTENCIES.inspect}, " \
647-
"#{consistency.inspect} given"
648-
)
642+
":consistency must be one of #{CONSISTENCIES.inspect}, " \
643+
"#{consistency.inspect} given")
649644
end
650645
if options.key?(:execution_profiles)
651646
options[:execution_profiles].each do |name, profile|
652647
consistency = profile.consistency
653-
unless consistency.nil?
654-
Util.assert_one_of(CONSISTENCIES, consistency,
655-
":consistency in execution profile #{name} must be one of #{CONSISTENCIES.inspect}, " \
656-
"#{consistency.inspect} given"
657-
)
658-
end
648+
next if consistency.nil?
649+
Util.assert_one_of(CONSISTENCIES, consistency,
650+
":consistency in execution profile #{name} must be one of #{CONSISTENCIES.inspect}, " \
651+
"#{consistency.inspect} given")
659652
end
660653
end
661654

@@ -681,9 +674,8 @@ def self.validate_and_massage_options(options)
681674
unless protocol_version.nil?
682675
Util.assert_instance_of(::Integer, protocol_version)
683676
Util.assert_one_of(1..Cassandra::Protocol::Versions::MAX_SUPPORTED_VERSION, protocol_version,
684-
':protocol_version must be a positive integer between 1 and ' \
685-
"#{Cassandra::Protocol::Versions::MAX_SUPPORTED_VERSION}, #{protocol_version.inspect} given"
686-
)
677+
':protocol_version must be a positive integer between 1 and ' \
678+
"#{Cassandra::Protocol::Versions::MAX_SUPPORTED_VERSION}, #{protocol_version.inspect} given")
687679
end
688680
end
689681

0 commit comments

Comments
 (0)