Skip to content

Commit

Permalink
Update RuboCop 0.68.1 → 0.82.0
Browse files Browse the repository at this point in the history
This required explicitly enabling a few cops due to new RuboCop rules as
they prepare for a 1.0 release.
  • Loading branch information
sds committed Apr 27, 2020
1 parent d397cb3 commit 80c1297
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 19 deletions.
31 changes: 26 additions & 5 deletions .rubocop.yml
Expand Up @@ -3,10 +3,10 @@ inherit_from: .rubocop_todo.yml
AllCops:
TargetRubyVersion: 2.4

Layout/AlignArguments:
Layout/ArgumentAlignment:
Enabled: false

Layout/AlignParameters:
Layout/ParameterAlignment:
Enabled: false

Layout/DotPosition:
Expand All @@ -15,9 +15,21 @@ Layout/DotPosition:
Layout/EmptyLineAfterGuardClause:
Enabled: false

Layout/LineLength:
Max: 100

Layout/SpaceAroundMethodCallOperator:
Enabled: true

Lint/AssignmentInCondition:
Enabled: false

Lint/RaiseException:
Enabled: true

Lint/StructNewOverride:
Enabled: true

# We use this a lot in specs where it's perfectly valid
Lint/Void:
Exclude:
Expand All @@ -35,9 +47,6 @@ Metrics/CyclomaticComplexity:
Metrics/ClassLength:
Enabled: false

Metrics/LineLength:
Max: 100

Metrics/MethodLength:
Enabled: false

Expand All @@ -57,6 +66,18 @@ Style/Documentation:
Style/DoubleNegation:
Enabled: false

Style/ExponentialNotation:
Enabled: true

Style/HashEachMethods:
Enabled: true

Style/HashTransformKeys:
Enabled: true

Style/HashTransformValues:
Enabled: true

# We have too much code that relies on modifying strings
Style/FrozenStringLiteralComment:
Enabled: false
Expand Down
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Expand Up @@ -9,7 +9,7 @@
# Offense count: 17
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to, by, on, in, at, ip
Naming/UncommunicativeMethodParamName:
Naming/MethodParameterName:
Exclude:
- 'lib/mock_redis/database.rb'
- 'lib/mock_redis/expire_wrapper.rb'
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -7,6 +7,6 @@ gemspec
gem 'overcommit', '0.53.0'

# Pin tool versions (which are executed by Overcommit) for Travis builds
gem 'rubocop', '0.68.1'
gem 'rubocop', '0.82.0'

gem 'coveralls', require: false
4 changes: 2 additions & 2 deletions lib/mock_redis/database.rb
Expand Up @@ -35,7 +35,7 @@ def initialize(base, *_args)

def initialize_copy(_source)
@data = @data.clone
@data.keys.each { |k| @data[k] = @data[k].clone }
@data.each_key { |k| @data[k] = @data[k].clone }
@expire_times = @expire_times.map(&:clone)
end

Expand Down Expand Up @@ -120,7 +120,7 @@ def exists(key)
end

def flushdb
data.keys.each { |k| del(k) }
data.each_key { |k| del(k) }
'OK'
end

Expand Down
8 changes: 4 additions & 4 deletions lib/mock_redis/geospatial_methods.rb
Expand Up @@ -38,7 +38,7 @@ def geodist(key, member1, member2, unit = 'm')
lng2, lat2 = geohash_decode(hash2)

distance = geohash_distance(lng1, lat1, lng2, lat2) / to_meter
format('%.4f', distance)
format('%<distance>.4f', distance: distance)
end

def geohash(key, members)
Expand Down Expand Up @@ -95,8 +95,8 @@ def parse_point(point)
lat = Float(point[1])

unless LNG_RANGE.include?(lng) && LAT_RANGE.include?(lat)
lng = format('%.6f', lng)
lat = format('%.6f', lat)
lng = format('%<long>.6f', long: lng)
lat = format('%<lat>.6f', lat: lat)
raise Redis::CommandError,
"ERR invalid longitude,latitude pair #{lng},#{lat}"
end
Expand Down Expand Up @@ -201,7 +201,7 @@ def deinterleave(bits)
end

def format_decoded_coord(coord)
coord = format('%.17f', coord)
coord = format('%<coord>.17f', coord: coord)
l = 1
l += 1 while coord[-l] == '0'
coord = coord[0..-l]
Expand Down
4 changes: 2 additions & 2 deletions lib/mock_redis/info_method.rb
Expand Up @@ -83,7 +83,7 @@ module InfoMethod

# The Ruby Redis client returns commandstats differently when it's called as
# "INFO commandstats".
# rubocop:disable Metrics/LineLength
# rubocop:disable Layout/LineLength
COMMAND_STATS_SOLO_INFO = {
'auth' => { 'calls' => '572501', 'usec' => '2353163', 'usec_per_call' => '4.11' },
'client' => { 'calls' => '1', 'usec' => '80', 'usec_per_call' => '80.00' },
Expand Down Expand Up @@ -123,7 +123,7 @@ module InfoMethod
'cmdstat_smembers' => 'calls=58,usec=231,usec_per_call=3.98',
'cmdstat_sunionstore' => 'calls=4185027,usec=11762454022,usec_per_call=2810.60',
}.freeze
# rubocop:enable Metrics/LineLength
# rubocop:enable Layout/LineLength

DEFAULT_INFO = [
SERVER_INFO,
Expand Down
2 changes: 1 addition & 1 deletion lib/mock_redis/multi_db_wrapper.rb
Expand Up @@ -24,7 +24,7 @@ def method_missing(method, *args, &block)
def initialize_copy(source)
super
@databases = @databases.clone
@databases.keys.each do |k|
@databases.each_key do |k|
@databases[k] = @databases[k].clone
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/commands/geoadd_spec.rb
Expand Up @@ -33,7 +33,7 @@
context 'when coordinates are not in allowed range' do
let(:coords) { [181, 86] }
let(:message) do
formatted_coords = coords.map { |c| format('%.6f', c) }
formatted_coords = coords.map { |c| format('%<coords>.6f', coords: c) }
"ERR invalid longitude,latitude pair #{formatted_coords.join(',')}"
end

Expand Down
2 changes: 1 addition & 1 deletion spec/commands/srandmember_spec.rb
Expand Up @@ -37,7 +37,7 @@
@redises.send_without_checking(:srandmember, @key, 2).size.should == 2
end

it 'returns random members up to count from the set when count is negative even if count.abs is greater than the set size' do # rubocop:disable Metrics/LineLength
it 'returns random members up to count from the set when count is negative even if count.abs is greater than the set size' do # rubocop:disable Layout/LineLength
@redises.send_without_checking(:srandmember, @key, -5).size.should == 5
end

Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Expand Up @@ -15,7 +15,7 @@
require 'timecop'

$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..')))
Dir['spec/support/**/*.rb'].each { |x| require x }
Dir['spec/support/**/*.rb'].sort.each { |x| require x }

module TypeCheckingHelper
def method_from_description(example)
Expand Down

0 comments on commit 80c1297

Please sign in to comment.