Skip to content

Commit 45fa826

Browse files
committed
dep(style): move dev deps into Gemfile and add rubocop
import a copy of .rubocop.yml from rails/rails
1 parent ba95790 commit 45fa826

File tree

3 files changed

+358
-6
lines changed

3 files changed

+358
-6
lines changed

Diff for: .rubocop.yml

+345
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,345 @@
1+
require:
2+
- rubocop-minitest
3+
- rubocop-packaging
4+
- rubocop-performance
5+
- rubocop-rails
6+
7+
AllCops:
8+
TargetRubyVersion: 2.7
9+
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
10+
# to ignore them, so only the ones explicitly set in this file are enabled.
11+
DisabledByDefault: true
12+
SuggestExtensions: false
13+
Exclude:
14+
- '**/tmp/**/*'
15+
- '**/templates/**/*'
16+
- '**/vendor/**/*'
17+
- 'actionpack/lib/action_dispatch/journey/parser.rb'
18+
- 'actionmailbox/test/dummy/**/*'
19+
- 'actiontext/test/dummy/**/*'
20+
- '**/node_modules/**/*'
21+
22+
Performance:
23+
Exclude:
24+
- '**/test/**/*'
25+
26+
# Prefer assert_not over assert !
27+
Rails/AssertNot:
28+
Include:
29+
- '**/test/**/*'
30+
31+
# Prefer assert_not_x over refute_x
32+
Rails/RefuteMethods:
33+
Include:
34+
- '**/test/**/*'
35+
36+
Rails/IndexBy:
37+
Enabled: true
38+
39+
Rails/IndexWith:
40+
Enabled: true
41+
42+
# Prefer &&/|| over and/or.
43+
Style/AndOr:
44+
Enabled: true
45+
46+
# Align `when` with `case`.
47+
Layout/CaseIndentation:
48+
Enabled: true
49+
50+
Layout/ClosingHeredocIndentation:
51+
Enabled: true
52+
53+
Layout/ClosingParenthesisIndentation:
54+
Enabled: true
55+
56+
# Align comments with method definitions.
57+
Layout/CommentIndentation:
58+
Enabled: true
59+
60+
Layout/ElseAlignment:
61+
Enabled: true
62+
63+
# Align `end` with the matching keyword or starting expression except for
64+
# assignments, where it should be aligned with the LHS.
65+
Layout/EndAlignment:
66+
Enabled: true
67+
EnforcedStyleAlignWith: variable
68+
AutoCorrect: true
69+
70+
Layout/EndOfLine:
71+
Enabled: true
72+
73+
Layout/EmptyLineAfterMagicComment:
74+
Enabled: true
75+
76+
Layout/EmptyLinesAroundAccessModifier:
77+
Enabled: true
78+
EnforcedStyle: only_before
79+
80+
Layout/EmptyLinesAroundBlockBody:
81+
Enabled: true
82+
83+
# In a regular class definition, no empty lines around the body.
84+
Layout/EmptyLinesAroundClassBody:
85+
Enabled: true
86+
87+
# In a regular method definition, no empty lines around the body.
88+
Layout/EmptyLinesAroundMethodBody:
89+
Enabled: true
90+
91+
# In a regular module definition, no empty lines around the body.
92+
Layout/EmptyLinesAroundModuleBody:
93+
Enabled: true
94+
95+
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
96+
Style/HashSyntax:
97+
Enabled: true
98+
99+
# Method definitions after `private` or `protected` isolated calls need one
100+
# extra level of indentation.
101+
Layout/IndentationConsistency:
102+
Enabled: true
103+
EnforcedStyle: indented_internal_methods
104+
105+
# Two spaces, no tabs (for indentation).
106+
Layout/IndentationWidth:
107+
Enabled: true
108+
109+
Layout/LeadingCommentSpace:
110+
Enabled: true
111+
112+
Layout/SpaceAfterColon:
113+
Enabled: true
114+
115+
Layout/SpaceAfterComma:
116+
Enabled: true
117+
118+
Layout/SpaceAfterSemicolon:
119+
Enabled: true
120+
121+
Layout/SpaceAroundEqualsInParameterDefault:
122+
Enabled: true
123+
124+
Layout/SpaceAroundKeyword:
125+
Enabled: true
126+
127+
Layout/SpaceAroundOperators:
128+
Enabled: true
129+
130+
Layout/SpaceBeforeComma:
131+
Enabled: true
132+
133+
Layout/SpaceBeforeComment:
134+
Enabled: true
135+
136+
Layout/SpaceBeforeFirstArg:
137+
Enabled: true
138+
139+
Style/DefWithParentheses:
140+
Enabled: true
141+
142+
# Defining a method with parameters needs parentheses.
143+
Style/MethodDefParentheses:
144+
Enabled: true
145+
146+
Style/ExplicitBlockArgument:
147+
Enabled: true
148+
149+
Style/FrozenStringLiteralComment:
150+
Enabled: true
151+
EnforcedStyle: always
152+
Exclude:
153+
- 'actionview/test/**/*.builder'
154+
- 'actionview/test/**/*.ruby'
155+
- 'actionpack/test/**/*.builder'
156+
- 'actionpack/test/**/*.ruby'
157+
- 'activestorage/db/migrate/**/*.rb'
158+
- 'activestorage/db/update_migrate/**/*.rb'
159+
- 'actionmailbox/db/migrate/**/*.rb'
160+
- 'actiontext/db/migrate/**/*.rb'
161+
162+
Style/MapToHash:
163+
Enabled: true
164+
165+
Style/RedundantFreeze:
166+
Enabled: true
167+
168+
# Use `foo {}` not `foo{}`.
169+
Layout/SpaceBeforeBlockBraces:
170+
Enabled: true
171+
172+
# Use `foo { bar }` not `foo {bar}`.
173+
Layout/SpaceInsideBlockBraces:
174+
Enabled: true
175+
EnforcedStyleForEmptyBraces: space
176+
177+
# Use `{ a: 1 }` not `{a:1}`.
178+
Layout/SpaceInsideHashLiteralBraces:
179+
Enabled: true
180+
181+
Layout/SpaceInsideParens:
182+
Enabled: true
183+
184+
# Check quotes usage according to lint rule below.
185+
Style/StringLiterals:
186+
Enabled: true
187+
EnforcedStyle: double_quotes
188+
189+
# Detect hard tabs, no hard tabs.
190+
Layout/IndentationStyle:
191+
Enabled: true
192+
193+
# Empty lines should not have any spaces.
194+
Layout/TrailingEmptyLines:
195+
Enabled: true
196+
197+
# No trailing whitespace.
198+
Layout/TrailingWhitespace:
199+
Enabled: true
200+
201+
# Use quotes for string literals when they are enough.
202+
Style/RedundantPercentQ:
203+
Enabled: true
204+
205+
Lint/AmbiguousOperator:
206+
Enabled: true
207+
208+
Lint/AmbiguousRegexpLiteral:
209+
Enabled: true
210+
211+
Lint/DuplicateRequire:
212+
Enabled: true
213+
214+
Lint/DuplicateMagicComment:
215+
Enabled: true
216+
217+
Lint/DuplicateMethods:
218+
Enabled: true
219+
220+
Lint/ErbNewArguments:
221+
Enabled: true
222+
223+
Lint/EnsureReturn:
224+
Enabled: true
225+
226+
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
227+
Lint/RequireParentheses:
228+
Enabled: true
229+
230+
Lint/RedundantStringCoercion:
231+
Enabled: true
232+
233+
Lint/UriEscapeUnescape:
234+
Enabled: true
235+
236+
Lint/UselessAssignment:
237+
Enabled: true
238+
239+
Lint/DeprecatedClassMethods:
240+
Enabled: true
241+
242+
Style/EvalWithLocation:
243+
Enabled: true
244+
Exclude:
245+
- '**/test/**/*'
246+
247+
Style/ParenthesesAroundCondition:
248+
Enabled: true
249+
250+
Style/HashTransformKeys:
251+
Enabled: true
252+
253+
Style/HashTransformValues:
254+
Enabled: true
255+
256+
Style/RedundantBegin:
257+
Enabled: true
258+
259+
Style/RedundantReturn:
260+
Enabled: true
261+
AllowMultipleReturnValues: true
262+
263+
Style/RedundantRegexpEscape:
264+
Enabled: true
265+
266+
Style/Semicolon:
267+
Enabled: true
268+
AllowAsExpressionSeparator: true
269+
270+
# Prefer Foo.method over Foo::method
271+
Style/ColonMethodCall:
272+
Enabled: true
273+
274+
Style/TrivialAccessors:
275+
Enabled: true
276+
277+
# Prefer a = b || c over a = b ? b : c
278+
Style/RedundantCondition:
279+
Enabled: true
280+
281+
Performance/BindCall:
282+
Enabled: true
283+
284+
Performance/FlatMap:
285+
Enabled: true
286+
287+
Performance/MapCompact:
288+
Enabled: true
289+
290+
Performance/SelectMap:
291+
Enabled: true
292+
293+
Performance/RedundantMerge:
294+
Enabled: true
295+
296+
Performance/StartWith:
297+
Enabled: true
298+
299+
Performance/EndWith:
300+
Enabled: true
301+
302+
Performance/RegexpMatch:
303+
Enabled: true
304+
305+
Performance/ReverseEach:
306+
Enabled: true
307+
308+
Performance/StringReplacement:
309+
Enabled: true
310+
311+
Performance/UnfreezeString:
312+
Enabled: true
313+
314+
Performance/DeletePrefix:
315+
Enabled: true
316+
317+
Performance/DeleteSuffix:
318+
Enabled: true
319+
320+
Performance/OpenStruct:
321+
Enabled: true
322+
323+
Performance/InefficientHashSearch:
324+
Enabled: true
325+
326+
Performance/ConstantRegexp:
327+
Enabled: true
328+
329+
Performance/RedundantStringChars:
330+
Enabled: true
331+
332+
Performance/StringInclude:
333+
Enabled: true
334+
335+
Minitest/AssertRaisesWithRegexpArgument:
336+
Enabled: true
337+
338+
Minitest/AssertWithExpectedArgument:
339+
Enabled: true
340+
341+
Minitest/SkipEnsure:
342+
Enabled: true
343+
344+
Minitest/UnreachableAssertion:
345+
Enabled: true

Diff for: Gemfile

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
source 'https://rubygems.org'
22

3-
# Specify your gem's dependencies in html-sanitizer.gemspec
43
gemspec
54

5+
gem "rake"
6+
gem "minitest"
7+
gem "rails-dom-testing"
8+
9+
group :rubocop do
10+
gem "rubocop", ">= 1.25.1", require: false
11+
gem "rubocop-minitest", require: false
12+
gem "rubocop-packaging", require: false
13+
gem "rubocop-performance", require: false
14+
gem "rubocop-rails", require: false
15+
end
16+
17+
# specify gem versions for old rubies
618
gem "nokogiri", RUBY_VERSION < "2.1" ? "~> 1.6.0" : ">= 1.7"
719
gem "activesupport", RUBY_VERSION < "2.2.2" ? "~> 4.2.0" : ">= 5"

Diff for: rails-html-sanitizer.gemspec

-5
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,4 @@ Gem::Specification.new do |spec|
2929
# NOTE: There's no need to update this dependency for Loofah CVEs
3030
# in minor releases when users can simply run `bundle update loofah`.
3131
spec.add_dependency "loofah", "~> 2.19", ">= 2.19.1"
32-
33-
spec.add_development_dependency "bundler", ">= 1.3"
34-
spec.add_development_dependency "rake"
35-
spec.add_development_dependency "minitest"
36-
spec.add_development_dependency "rails-dom-testing"
3732
end

0 commit comments

Comments
 (0)