Skip to content

Commit 3c97d9f

Browse files
committedOct 23, 2018
Setup rubocop and apply Rails style guide
1 parent 1361957 commit 3c97d9f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+934
-690
lines changed
 

‎.rubocop.yml

+222
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
AllCops:
2+
TargetRubyVersion: 2.5
3+
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
4+
# to ignore them, so only the ones explicitly set in this file are enabled.
5+
DisabledByDefault: true
6+
Exclude:
7+
- '**/templates/**/*'
8+
- '**/vendor/**/*'
9+
- 'actionpack/lib/action_dispatch/journey/parser.rb'
10+
- 'railties/test/fixtures/tmp/**/*'
11+
- 'node_modules/**/*'
12+
- 'bin/*'
13+
14+
Performance:
15+
Exclude:
16+
- '**/test/**/*'
17+
18+
Rails:
19+
Enabled: true
20+
21+
# Prefer assert_not over assert !
22+
Rails/AssertNot:
23+
Include:
24+
- '**/test/**/*'
25+
26+
# Prefer assert_not_x over refute_x
27+
Rails/RefuteMethods:
28+
Include:
29+
- '**/test/**/*'
30+
31+
# Prefer &&/|| over and/or.
32+
Style/AndOr:
33+
Enabled: true
34+
35+
# Do not use braces for hash literals when they are the last argument of a
36+
# method call.
37+
Style/BracesAroundHashParameters:
38+
Enabled: true
39+
EnforcedStyle: context_dependent
40+
41+
# Align `when` with `case`.
42+
Layout/CaseIndentation:
43+
Enabled: true
44+
45+
# Align comments with method definitions.
46+
Layout/CommentIndentation:
47+
Enabled: true
48+
49+
Layout/ElseAlignment:
50+
Enabled: true
51+
52+
# Align `end` with the matching keyword or starting expression except for
53+
# assignments, where it should be aligned with the LHS.
54+
Layout/EndAlignment:
55+
Enabled: true
56+
EnforcedStyleAlignWith: variable
57+
AutoCorrect: true
58+
59+
Layout/EmptyLineAfterMagicComment:
60+
Enabled: true
61+
62+
Layout/EmptyLinesAroundBlockBody:
63+
Enabled: true
64+
65+
# In a regular class definition, no empty lines around the body.
66+
Layout/EmptyLinesAroundClassBody:
67+
Enabled: true
68+
69+
# In a regular method definition, no empty lines around the body.
70+
Layout/EmptyLinesAroundMethodBody:
71+
Enabled: true
72+
73+
# In a regular module definition, no empty lines around the body.
74+
Layout/EmptyLinesAroundModuleBody:
75+
Enabled: true
76+
77+
Layout/FirstParameterIndentation:
78+
Enabled: true
79+
80+
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
81+
Style/HashSyntax:
82+
Enabled: true
83+
84+
# Method definitions after `private` or `protected` isolated calls need one
85+
# extra level of indentation.
86+
Layout/IndentationConsistency:
87+
Enabled: true
88+
EnforcedStyle: rails
89+
90+
# Two spaces, no tabs (for indentation).
91+
Layout/IndentationWidth:
92+
Enabled: true
93+
94+
Layout/LeadingCommentSpace:
95+
Enabled: true
96+
97+
Layout/SpaceAfterColon:
98+
Enabled: true
99+
100+
Layout/SpaceAfterComma:
101+
Enabled: true
102+
103+
Layout/SpaceAroundEqualsInParameterDefault:
104+
Enabled: true
105+
106+
Layout/SpaceAroundKeyword:
107+
Enabled: true
108+
109+
Layout/SpaceAroundOperators:
110+
Enabled: true
111+
112+
Layout/SpaceBeforeComma:
113+
Enabled: true
114+
115+
Layout/SpaceBeforeFirstArg:
116+
Enabled: true
117+
118+
Style/DefWithParentheses:
119+
Enabled: true
120+
121+
# Defining a method with parameters needs parentheses.
122+
Style/MethodDefParentheses:
123+
Enabled: true
124+
125+
Style/FrozenStringLiteralComment:
126+
Enabled: true
127+
EnforcedStyle: always
128+
Exclude:
129+
- 'actionview/test/**/*.builder'
130+
- 'actionview/test/**/*.ruby'
131+
- 'actionpack/test/**/*.builder'
132+
- 'actionpack/test/**/*.ruby'
133+
- 'activestorage/db/migrate/**/*.rb'
134+
135+
Style/RedundantFreeze:
136+
Enabled: true
137+
Exclude:
138+
- 'actionpack/lib/action_dispatch/journey/router/utils.rb'
139+
- 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb'
140+
141+
# Use `foo {}` not `foo{}`.
142+
Layout/SpaceBeforeBlockBraces:
143+
Enabled: true
144+
145+
# Use `foo { bar }` not `foo {bar}`.
146+
Layout/SpaceInsideBlockBraces:
147+
Enabled: true
148+
EnforcedStyleForEmptyBraces: space
149+
150+
# Use `{ a: 1 }` not `{a:1}`.
151+
Layout/SpaceInsideHashLiteralBraces:
152+
Enabled: true
153+
154+
Layout/SpaceInsideParens:
155+
Enabled: true
156+
157+
# Check quotes usage according to lint rule below.
158+
Style/StringLiterals:
159+
Enabled: true
160+
EnforcedStyle: double_quotes
161+
162+
# Detect hard tabs, no hard tabs.
163+
Layout/Tab:
164+
Enabled: true
165+
166+
# Blank lines should not have any spaces.
167+
Layout/TrailingBlankLines:
168+
Enabled: true
169+
170+
# No trailing whitespace.
171+
Layout/TrailingWhitespace:
172+
Enabled: true
173+
174+
# Use quotes for string literals when they are enough.
175+
Style/UnneededPercentQ:
176+
Enabled: true
177+
178+
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
179+
Lint/RequireParentheses:
180+
Enabled: true
181+
182+
Lint/StringConversionInInterpolation:
183+
Enabled: true
184+
185+
Lint/UriEscapeUnescape:
186+
Enabled: true
187+
188+
Style/ParenthesesAroundCondition:
189+
Enabled: true
190+
191+
Style/RedundantReturn:
192+
Enabled: true
193+
AllowMultipleReturnValues: true
194+
195+
Style/Semicolon:
196+
Enabled: true
197+
AllowAsExpressionSeparator: true
198+
199+
# Prefer Foo.method over Foo::method
200+
Style/ColonMethodCall:
201+
Enabled: true
202+
203+
Style/TrivialAccessors:
204+
Enabled: true
205+
206+
Performance/FlatMap:
207+
Enabled: true
208+
209+
Performance/RedundantMerge:
210+
Enabled: true
211+
212+
Performance/StartWith:
213+
Enabled: true
214+
215+
Performance/EndWith:
216+
Enabled: true
217+
218+
Performance/RegexpMatch:
219+
Enabled: true
220+
221+
Performance/UnfreezeString:
222+
Enabled: true

‎Gemfile

+41-38
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,55 @@
1-
source 'https://rubygems.org'
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
24
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
35

4-
ruby '2.5.3'
6+
ruby "2.5.3"
57

6-
gem 'active_link_to', '~> 1.0.5'
7-
gem 'bootsnap', '>= 1.1.0', require: false
8-
gem 'cable_ready', '~> 2.0.6'
9-
gem 'country_select'
10-
gem 'devise'
11-
gem 'jbuilder', '~> 2.5'
12-
gem 'pg', '>= 0.18', '< 2.0'
13-
gem 'puma', '~> 3.11'
14-
gem 'rails', '~> 5.2.1'
15-
gem 'redis', '~> 4.0'
16-
gem 'sass-rails', '~> 5.0'
17-
gem 'simple_form', '~> 4.0'
18-
gem 'stimulus_reflex', '~> 0.1.8'
19-
gem 'tag_columns', '~> 0.1.6'
20-
gem 'turbolinks', '~> 5'
21-
gem 'uglifier', '>= 1.3.0'
22-
gem 'webpacker', '~> 3.5'
8+
gem "active_link_to", "~> 1.0.5"
9+
gem "bootsnap", ">= 1.1.0", require: false
10+
gem "cable_ready", "~> 2.0.6"
11+
gem "country_select"
12+
gem "devise"
13+
gem "jbuilder", "~> 2.5"
14+
gem "pg", ">= 0.18", "< 2.0"
15+
gem "puma", "~> 3.11"
16+
gem "rails", "~> 5.2.1"
17+
gem "redis", "~> 4.0"
18+
gem "sass-rails", "~> 5.0"
19+
gem "simple_form", "~> 4.0"
20+
gem "stimulus_reflex", "~> 0.1.8"
21+
gem "tag_columns", "~> 0.1.6"
22+
gem "turbolinks", "~> 5"
23+
gem "uglifier", ">= 1.3.0"
24+
gem "webpacker", "~> 3.5"
2325

2426
group :development, :test do
25-
gem 'awesome_print'
26-
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
27-
gem 'dotenv'
28-
gem 'pry'
29-
gem 'pry-byebug'
30-
gem 'pry-rails'
27+
gem "awesome_print"
28+
gem "byebug", platforms: [:mri, :mingw, :x64_mingw]
29+
gem "dotenv"
30+
gem "pry"
31+
gem "pry-byebug"
32+
gem "pry-rails"
3133
end
3234

3335
group :development do
34-
#gem 'spring'
35-
#gem 'spring-watcher-listen', '~> 2.0.0'
36-
gem 'annotate'
37-
gem 'listen', '>= 3.0.5', '< 3.2'
38-
gem 'magic_frozen_string_literal'
39-
gem 'model_probe'
40-
gem 'rufo'
41-
gem 'teamocil'
42-
gem 'web-console', '>= 3.3.0'
36+
# gem 'spring'
37+
# gem 'spring-watcher-listen', '~> 2.0.0'
38+
gem "annotate"
39+
gem "listen", ">= 3.0.5", "< 3.2"
40+
gem "magic_frozen_string_literal"
41+
gem "model_probe"
42+
gem "rubocop"
43+
gem "rufo"
44+
gem "teamocil"
45+
gem "web-console", ">= 3.3.0"
4346
end
4447

4548
group :test do
46-
gem 'capybara', '>= 2.15'
47-
gem 'chromedriver-helper'
48-
gem 'selenium-webdriver'
49+
gem "capybara", ">= 2.15"
50+
gem "chromedriver-helper"
51+
gem "selenium-webdriver"
4952
end
5053

5154
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
52-
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
55+
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]

0 commit comments

Comments
 (0)
Please sign in to comment.