Skip to content

Commit 033358a

Browse files
committed
Upgraded Rubocop to 0.27.1.
1 parent 4d347d7 commit 033358a

16 files changed

+433
-442
lines changed

.rubocop.yml

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -3,74 +3,4 @@ AllCops:
33
- vendor/**/*
44
- bin/**/*
55

6-
LineLength:
7-
Enabled: false
8-
9-
MethodLength:
10-
Enabled: false
11-
12-
ClassLength:
13-
Enabled: false
14-
15-
Documentation:
16-
# don't require classes to be documented
17-
Enabled: false
18-
19-
CollectionMethods:
20-
# don't prefer map to collect, recuce to inject
21-
Enabled: false
22-
23-
Encoding:
24-
# no need to always specify encoding
25-
Enabled: false
26-
27-
StringLiterals:
28-
# use single or double-quoted strings, as you please
29-
Enabled: false
30-
31-
Void:
32-
# == operator used in void context in specs
33-
Enabled: false
34-
35-
SignalException:
36-
# prefer raise to fail
37-
EnforcedStyle: only_raise
38-
39-
RaiseArgs:
40-
# don't care for what kind of raise
41-
Enabled: false
42-
43-
PerlBackrefs:
44-
# TODO: regular expression matching with $1, $2, etc.
45-
Enabled: false
46-
47-
BlockNesting:
48-
# TODO: fix too much nesting
49-
Max: 4
50-
51-
Lambda:
52-
# TODO: replace all lambda with -> or Proc
53-
Enabled: false
54-
55-
Blocks:
56-
# allow multi-line blocks like expect { }
57-
Enabled: false
58-
59-
WordArray:
60-
# %w vs. [ '', ... ]
61-
Enabled: false
62-
63-
CyclomaticComplexity:
64-
Enabled: false
65-
66-
HandleExceptions:
67-
Enabled: false
68-
69-
MultilineBlockChain:
70-
Enabled: false
71-
72-
FileName:
73-
Enabled: false
74-
75-
RegexpLiteral:
76-
Enabled: false
6+
inherit_from: .rubocop_todo.yml

.rubocop_todo.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This configuration was generated by `rubocop --auto-gen-config`
2+
# on 2014-12-09 07:20:55 -0500 using RuboCop version 0.27.1.
3+
# The point is for the user to remove these configuration records
4+
# one by one as the offenses are removed from the code base.
5+
# Note that changes in the inspected code, or installation of new
6+
# versions of RuboCop, may require this file to be generated again.
7+
8+
# Offense count: 3
9+
Lint/HandleExceptions:
10+
Enabled: false
11+
12+
# Offense count: 27
13+
Lint/Void:
14+
Enabled: false
15+
16+
# Offense count: 12
17+
Metrics/AbcSize:
18+
Max: 51
19+
20+
# Offense count: 4
21+
Metrics/CyclomaticComplexity:
22+
Max: 10
23+
24+
# Offense count: 181
25+
# Configuration parameters: AllowURI, URISchemes.
26+
Metrics/LineLength:
27+
Max: 688
28+
29+
# Offense count: 7
30+
# Configuration parameters: CountComments.
31+
Metrics/MethodLength:
32+
Max: 32
33+
34+
# Offense count: 4
35+
Metrics/PerceivedComplexity:
36+
Max: 12
37+
38+
# Offense count: 37
39+
Style/Documentation:
40+
Enabled: false
41+
42+
# Offense count: 6
43+
Style/EachWithObject:
44+
Enabled: false
45+
46+
# Offense count: 1
47+
# Configuration parameters: Exclude.
48+
Style/FileName:
49+
Enabled: false
50+
51+
# Offense count: 1
52+
Style/Lambda:
53+
Enabled: false
54+
55+
# Offense count: 3
56+
Style/MultilineBlockChain:
57+
Enabled: false
58+
59+
# Offense count: 2
60+
Style/RegexpLiteral:
61+
MaxSlashes: 0

Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ begin
33
Bundler.setup(:default, :development)
44
rescue Bundler::BundlerError => e
55
$stderr.puts e.message
6-
$stderr.puts "Run `bundle install` to install missing gems"
6+
$stderr.puts 'Run `bundle install` to install missing gems'
77
exit e.status_code
88
end
99

@@ -13,7 +13,7 @@ require 'rspec/core'
1313
require 'rspec/core/rake_task'
1414
RSpec::Core::RakeTask.new(:spec) do |spec|
1515
spec.pattern = FileList['spec/**/*_spec.rb']
16-
spec.rspec_opts = "--color --format progress"
16+
spec.rspec_opts = '--color --format progress'
1717
end
1818

1919
require 'rubocop/rake_task'

lib/mongoid-history.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
require 'mongoid/history/tracker'
77
require 'mongoid/history/trackable'
88

9-
Mongoid::History.modifier_class_name = "User"
9+
Mongoid::History.modifier_class_name = 'User'
1010
Mongoid::History.trackable_class_options = {}
1111
Mongoid::History.current_user_method ||= :current_user

lib/mongoid/history.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Mongoid
22
module History
3-
GLOBAL_TRACK_HISTORY_FLAG = "mongoid_history_trackable_enabled"
3+
GLOBAL_TRACK_HISTORY_FLAG = 'mongoid_history_trackable_enabled'
44

55
mattr_accessor :tracker_class_name
66
mattr_accessor :trackable_class_options

lib/mongoid/history/trackable.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ def get_versions_criteria(options_or_version)
120120
if options[:from] && options[:to]
121121
lower = options[:from] >= options[:to] ? options[:to] : options[:from]
122122
upper = options[:from] < options[:to] ? options[:to] : options[:from]
123-
versions = history_tracks.where(:version.in => (lower .. upper).to_a)
123+
versions = history_tracks.where(:version.in => (lower..upper).to_a)
124124
elsif options[:last]
125125
versions = history_tracks.limit(options[:last])
126126
else
127-
raise "Invalid options, please specify (:from / :to) keys or :last key."
127+
fail 'Invalid options, please specify (:from / :to) keys or :last key.'
128128
end
129129
else
130130
options_or_version = options_or_version.to_a if options_or_version.is_a?(Range)
@@ -308,7 +308,7 @@ def tracked_fields
308308
#
309309
# @return [ Array < String > ] the list of reserved database field names
310310
def reserved_tracked_fields
311-
@reserved_tracked_fields ||= ["_id", history_trackable_options[:version_field].to_s, "#{history_trackable_options[:modifier_field]}_id"]
311+
@reserved_tracked_fields ||= ['_id', history_trackable_options[:version_field].to_s, "#{history_trackable_options[:modifier_field]}_id"]
312312
end
313313

314314
def history_trackable_options

lib/mongoid/history/tracker.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,18 @@ def tracked_edits
140140
# { field_1: value, field_2: value }
141141
def affected
142142
target = action.to_sym == :destroy ? :from : :to
143-
@affected ||= tracked_changes.inject(HashWithIndifferentAccess.new) { |h, (k, v)|
143+
@affected ||= tracked_changes.inject(HashWithIndifferentAccess.new) do |h, (k, v)|
144144
h[k] = v[target]
145145
h
146-
}
146+
end
147147
end
148148

149149
# Returns the class of the trackable, irrespective of whether the trackable object
150150
# has been destroyed.
151151
#
152152
# @return [ Class ] the class of the trackable
153153
def trackable_parent_class
154-
association_chain.first["name"].constantize
154+
association_chain.first['name'].constantize
155155
end
156156

157157
private
@@ -166,18 +166,18 @@ def re_destroy
166166

167167
def create_standalone
168168
restored = trackable_parent_class.new(localize_keys(original))
169-
restored.id = original["_id"]
169+
restored.id = original['_id']
170170
restored.save!
171171
end
172172

173173
def create_on_parent
174-
name = association_chain.last["name"]
174+
name = association_chain.last['name']
175175
if trackable_parent.class.embeds_one?(name)
176176
trackable_parent.create_embedded(name, localize_keys(original))
177177
elsif trackable_parent.class.embeds_many?(name)
178178
trackable_parent.get_embedded(name).create!(localize_keys(original))
179179
else
180-
raise "This should never happen. Please report bug!"
180+
fail 'This should never happen. Please report bug!'
181181
end
182182
end
183183

@@ -202,7 +202,7 @@ def traverse_association_chain
202202
elsif doc.class.embeds_many?(name)
203203
doc.get_embedded(name).unscoped.where(_id: node['id']).first
204204
else
205-
raise "This should never happen. Please report bug."
205+
fail 'This should never happen. Please report bug.'
206206
end
207207
documents << doc
208208
break if chain.empty?
@@ -211,7 +211,7 @@ def traverse_association_chain
211211
end
212212

213213
def localize_keys(hash)
214-
klass = association_chain.first["name"].constantize
214+
klass = association_chain.first['name'].constantize
215215
klass.localized_fields.keys.each do |name|
216216
hash["#{name}_translations"] = hash.delete(name) if hash[name].present?
217217
end if klass.respond_to?(:localized_fields)

mongoid-history.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
2525
s.add_development_dependency 'rake'
2626
s.add_development_dependency 'rspec', '>= 3.0'
2727
s.add_development_dependency 'bundler'
28-
s.add_development_dependency 'rubocop', '0.21.0'
28+
s.add_development_dependency 'rubocop', '0.27.1'
2929
s.add_development_dependency 'yard'
3030
s.add_development_dependency 'gem-release'
3131
s.add_development_dependency 'coveralls'

spec/integration/embedded_in_polymorphic_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ class User
7878
end
7979
end
8080

81-
it "tracks history for nested embedded documents with polymorphic relations" do
81+
it 'tracks history for nested embedded documents with polymorphic relations' do
8282
user = User.new
8383
user.save!
8484

8585
real_state = user.real_states.build(name: 'rs_name')
8686
real_state.save!
87-
real_state.build_address(address: "Main Street #123", city: "Highland Park", state: 'IL').save!
87+
real_state.build_address(address: 'Main Street #123', city: 'Highland Park', state: 'IL').save!
8888
expect(real_state.history_tracks.count).to eq(2)
8989
expect(real_state.address.history_tracks.count).to eq(1)
9090

@@ -102,7 +102,7 @@ class User
102102

103103
company = user.companies.build(name: 'co_name')
104104
company.save!
105-
company.build_address(address: "Main Street #456", city: "Evanston", state: 'IL').save!
105+
company.build_address(address: 'Main Street #456', city: 'Evanston', state: 'IL').save!
106106
expect(company.history_tracks.count).to eq(2)
107107
expect(company.address.history_tracks.count).to eq(1)
108108

@@ -112,7 +112,7 @@ class User
112112
expect(company.address.history_tracks.count).to eq(2)
113113
expect(company.history_tracks.last.action).to eq('update')
114114

115-
company.build_second_address(address: "Main Street #789", city: "Highland Park", state: 'IL').save!
115+
company.build_second_address(address: 'Main Street #789', city: 'Highland Park', state: 'IL').save!
116116
expect(company.history_tracks.count).to eq(4)
117117
expect(company.second_address.history_tracks.count).to eq(1)
118118
expect(company.history_tracks.last.action).to eq('create')

0 commit comments

Comments
 (0)