Skip to content

Commit 71039f2

Browse files
Merge pull request #154 from activeadmin/feature/rubocop
Introduce rubocop
2 parents 119d9fc + cf8b73a commit 71039f2

40 files changed

+192
-106
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ spec/reports
2121
/test_app/.sass-cache
2222
/test_app/config/mongoid.yml
2323
/spec/rails
24+
.ruby-version

.rubocop.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
AllCops:
2+
DisabledByDefault: true
3+
TargetRubyVersion: 2.4
4+
5+
DisplayCopNames: true
6+
7+
StyleGuideCopsOnly: false
8+
9+
Layout/EndAlignment:
10+
Enabled: true
11+
12+
Lint/ParenthesesAsGroupedExpression:
13+
Enabled: true
14+
15+
Layout/AccessModifierIndentation:
16+
Enabled: true
17+
18+
Layout/CaseIndentation:
19+
Enabled: true
20+
21+
Layout/CommentIndentation:
22+
Enabled: true
23+
24+
Layout/ElseAlignment:
25+
Enabled: true
26+
27+
Layout/EmptyLines:
28+
Enabled: true
29+
30+
Layout/EmptyLinesAroundBlockBody:
31+
Enabled: true
32+
33+
Layout/EndOfLine:
34+
Enabled: true
35+
36+
Layout/ExtraSpacing:
37+
Enabled: true
38+
39+
Style/Dir:
40+
Enabled: true
41+
42+
Style/Encoding:
43+
Enabled: true
44+
45+
Style/ExpandPathArguments:
46+
Enabled: true
47+
48+
Style/FrozenStringLiteralComment:
49+
Enabled: true
50+
EnforcedStyle: never
51+
52+
Style/HashSyntax:
53+
Enabled: true
54+
55+
Style/ParallelAssignment:
56+
Enabled: true
57+
58+
Layout/IndentationConsistency:
59+
Enabled: true
60+
61+
Layout/IndentationWidth:
62+
Enabled: true
63+
64+
Naming/PredicateName:
65+
Enabled: true
66+
67+
ForbiddenPrefixes:
68+
- is_
69+
- have_
70+
71+
AllowedMethods:
72+
- has_many
73+
- has_many_actions
74+
- is_association?
75+
76+
Style/TrailingCommaInArguments:
77+
Enabled: true
78+
79+
Layout/TrailingEmptyLines:
80+
Enabled: true
81+
82+
Layout/TrailingWhitespace:
83+
Enabled: true
84+
85+
Layout/SpaceAfterComma:
86+
Enabled: true
87+
88+
Layout/SpaceAroundEqualsInParameterDefault:
89+
Enabled: true
90+
91+
Layout/SpaceAroundOperators:
92+
Enabled: true
93+
94+
Layout/SpaceBeforeBlockBraces:
95+
Enabled: true
96+
97+
Layout/SpaceInsideBlockBraces:
98+
Enabled: true
99+
100+
Layout/SpaceInsideHashLiteralBraces:
101+
Enabled: true
102+
103+
Layout/SpaceInsideParens:
104+
Enabled: true

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ before_install:
55
- gem update --system
66
- gem install bundler
77
- bundle update --bundler
8+
after_script:
9+
- bundle exec rubocop
810
rvm:
911
- 2.4
1012
- 2.5

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ group :test do
2020
gem 'launchy'
2121
gem 'simplecov', require: false
2222
end
23+
24+
group :lint do
25+
gem 'rubocop', '0.80.0'
26+
end

Gemfile.lock

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ GEM
7474
arbre (1.2.1)
7575
activesupport (>= 3.0.0)
7676
arel (9.0.0)
77+
ast (2.4.0)
7778
bcrypt (3.1.13)
7879
bson (4.7.1)
7980
builder (3.2.3)
@@ -114,6 +115,7 @@ GEM
114115
has_scope (~> 0.6)
115116
railties (>= 5.0, < 6.1)
116117
responders (>= 2, < 4)
118+
jaro_winkler (1.5.4)
117119
jquery-rails (4.3.3)
118120
rails-dom-testing (>= 1, < 3)
119121
railties (>= 4.2.0)
@@ -161,6 +163,9 @@ GEM
161163
nokogiri (1.10.5)
162164
mini_portile2 (~> 2.4.0)
163165
orm_adapter (0.5.0)
166+
parallel (1.19.1)
167+
parser (2.7.0.2)
168+
ast (~> 2.4.0)
164169
poltergeist (1.18.1)
165170
capybara (>= 2.1, < 4)
166171
cliver (~> 0.3.1)
@@ -200,6 +205,7 @@ GEM
200205
method_source
201206
rake (>= 0.8.7)
202207
thor (>= 0.19.0, < 2.0)
208+
rainbow (3.0.0)
203209
rake (12.3.3)
204210
ransack (2.3.2)
205211
activerecord (>= 5.2.1)
@@ -210,6 +216,7 @@ GEM
210216
responders (2.4.1)
211217
actionpack (>= 4.2.0, < 6.0)
212218
railties (>= 4.2.0, < 6.0)
219+
rexml (3.2.4)
213220
rspec-core (3.8.0)
214221
rspec-support (~> 3.8.0)
215222
rspec-expectations (3.8.2)
@@ -227,6 +234,15 @@ GEM
227234
rspec-mocks (~> 3.8.0)
228235
rspec-support (~> 3.8.0)
229236
rspec-support (3.8.0)
237+
rubocop (0.80.0)
238+
jaro_winkler (~> 1.5.1)
239+
parallel (~> 1.10)
240+
parser (>= 2.7.0.1)
241+
rainbow (>= 2.2.2, < 4.0)
242+
rexml
243+
ruby-progressbar (~> 1.7)
244+
unicode-display_width (>= 1.4.0, < 1.7)
245+
ruby-progressbar (1.10.1)
230246
sass-rails (6.0.0)
231247
sassc-rails (~> 2.1, >= 2.1.1)
232248
sassc (2.2.1)
@@ -254,6 +270,7 @@ GEM
254270
tilt (2.0.10)
255271
tzinfo (1.2.5)
256272
thread_safe (~> 0.1)
273+
unicode-display_width (1.6.1)
257274
warden (1.2.8)
258275
rack (>= 2.0.6)
259276
websocket-driver (0.7.0)
@@ -278,6 +295,7 @@ DEPENDENCIES
278295
rails (>= 5.2, < 6.1)
279296
ransack-mongoid!
280297
rspec-rails (~> 3.6)
298+
rubocop (= 0.80.0)
281299
simplecov
282300

283301
BUNDLED WITH

activeadmin-mongoid.gemspec

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# coding: utf-8
2-
lib = File.expand_path('../lib', __FILE__)
1+
lib = File.expand_path('lib', __dir__)
32
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
43
require 'active_admin/mongoid/version'
54

@@ -10,7 +9,7 @@ Gem::Specification.new do |gem|
109
gem.summary = %q{ActiveAdmin hacks to support Mongoid}
1110
gem.homepage = ''
1211

13-
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12+
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
1413
gem.files = `git ls-files`.split("\n")
1514
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
1615
gem.name = 'activeadmin-mongoid'
@@ -24,7 +23,7 @@ Gem::Specification.new do |gem|
2423
gem.add_runtime_dependency 'activeadmin', '>= 1.4.3'
2524
gem.add_runtime_dependency 'kaminari-mongoid'
2625
gem.add_runtime_dependency 'jquery-rails'
27-
gem.add_runtime_dependency 'sass-rails', ['>= 3.1.4']
26+
gem.add_runtime_dependency 'sass-rails', ['>= 3.1.4']
2827

29-
gem.add_development_dependency 'rspec-rails', '~> 3.6'
28+
gem.add_development_dependency 'rspec-rails', '~> 3.6'
3029
end

lib/active_admin/mongoid/association/relatable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ def foreign_key
1111
return if embeds?
1212
foreign_key.to_sym rescue nil
1313
end
14-
end
14+
end

lib/active_admin/mongoid/controllers/resource_controller.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require 'active_admin/engine'
22

33
ActiveAdmin::Engine.module_eval do
4-
54
initializer 'active_admin.mongoid.resource_controller' do
65
class ActiveAdmin::ResourceController
76
def build_new_resource

lib/active_admin/mongoid/criteria.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ def from(*a)
1919
end
2020
end
2121
end
22-

lib/active_admin/mongoid/csv_builder.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def build(controller, csv)
1111
csv << bom if bom
1212

1313
if column_names
14-
csv << CSV.generate_line(columns.map{ |c| encode c.name, options }, csv_options)
14+
csv << CSV.generate_line(columns.map { |c| encode c.name, options }, csv_options)
1515
end
1616

1717
(1..paginated_collection.total_pages).each do |page|

0 commit comments

Comments
 (0)