synchronized_model 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.codeclimate.yml +5 -0
- data/.rubocop.yml +319 -8
- data/Rakefile +1 -0
- data/lib/synchronized_model/message_receive.rb +13 -3
- data/lib/synchronized_model/model_message.rb +1 -0
- data/lib/synchronized_model/publish_mixin.rb +5 -1
- data/lib/synchronized_model/railtie.rb +1 -0
- data/lib/synchronized_model/support.rb +1 -0
- data/lib/synchronized_model/version.rb +1 -1
- data/lib/tasks/publish.rake +1 -0
- metadata +3 -4
- data/.hound-rubocop.yml +0 -323
- data/.hound.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c45e6ac25dbd0a76b8055f2f95f2866c2f2323f
|
4
|
+
data.tar.gz: 0eaf775192425626f0fbc5813f31f3436f362581
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 951014d39dfada40cfd584b055393ae24be8f87eb85ef861e61912d5a8a3ae3d62b3f5164c7118ad592f0b90ce57305ae1d733c36e5fdc889abad38550f7a6b7
|
7
|
+
data.tar.gz: a74870fba1bc1bc229b8a6599da0fdfea87ed7169bfc3bcb9f30349ffc7ae53bade84cdd05ac3c610f5fa2ed128e5dbfc6f541aca06110b19e0da93d2104006d
|
data/.codeclimate.yml
ADDED
data/.rubocop.yml
CHANGED
@@ -1,14 +1,328 @@
|
|
1
|
-
inherit_from: .hound-rubocop.yml
|
2
|
-
|
3
|
-
Rails:
|
4
|
-
Enabled: true
|
5
1
|
AllCops:
|
6
|
-
TargetRubyVersion: 2.4
|
2
|
+
TargetRubyVersion: 2.4.1
|
7
3
|
Exclude:
|
8
4
|
- "vendor/**/*"
|
9
5
|
- "db/schema.rb"
|
10
6
|
- "node_modules/**/*"
|
11
7
|
- bin/*
|
8
|
+
Layout/DotPosition:
|
9
|
+
Description: Checks the position of the dot in multi-line method calls.
|
10
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
|
11
|
+
Enabled: true
|
12
|
+
EnforcedStyle: leading
|
13
|
+
SupportedStyles:
|
14
|
+
- leading
|
15
|
+
- trailing
|
16
|
+
Layout/EmptyLineAfterMagicComment:
|
17
|
+
Description: 'Add an empty line after magic comments to separate them from code.'
|
18
|
+
StyleGuide: '#separate-magic-comments-from-code'
|
19
|
+
Enabled: true
|
20
|
+
Lint/AmbiguousBlockAssociation:
|
21
|
+
Exclude:
|
22
|
+
- "spec/**/*"
|
23
|
+
Style/CollectionMethods:
|
24
|
+
Description: Preferred collection methods.
|
25
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
|
26
|
+
Enabled: true
|
27
|
+
PreferredMethods:
|
28
|
+
collect: map
|
29
|
+
collect!: map!
|
30
|
+
find: detect
|
31
|
+
find_all: select
|
32
|
+
reduce: inject
|
33
|
+
Naming/FileName:
|
34
|
+
Description: Use snake_case for source file names.
|
35
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
|
36
|
+
Enabled: false
|
37
|
+
Exclude: []
|
38
|
+
Style/GuardClause:
|
39
|
+
Description: Check for conditionals that can be replaced with guard clauses
|
40
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
|
41
|
+
Enabled: false
|
42
|
+
MinBodyLength: 1
|
43
|
+
Style/IfUnlessModifier:
|
44
|
+
Description: Favor modifier if/unless usage when you have a single-line body.
|
45
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
|
46
|
+
Enabled: false
|
47
|
+
Style/OptionHash:
|
48
|
+
Description: Don't use option hashes when you can use keyword arguments.
|
49
|
+
Enabled: false
|
50
|
+
Style/PercentLiteralDelimiters:
|
51
|
+
Description: Use `%`-literal delimiters consistently
|
52
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
|
53
|
+
Enabled: false
|
54
|
+
PreferredDelimiters:
|
55
|
+
"%": "()"
|
56
|
+
"%i": "()"
|
57
|
+
"%q": "()"
|
58
|
+
"%Q": "()"
|
59
|
+
"%r": "{}"
|
60
|
+
"%s": "()"
|
61
|
+
"%w": "()"
|
62
|
+
"%W": "()"
|
63
|
+
"%x": "()"
|
64
|
+
Naming/PredicateName:
|
65
|
+
Description: Check the names of predicate methods.
|
66
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
|
67
|
+
Enabled: true
|
68
|
+
NamePrefix:
|
69
|
+
- is_
|
70
|
+
- has_
|
71
|
+
- have_
|
72
|
+
NamePrefixBlacklist:
|
73
|
+
- is_
|
74
|
+
Exclude:
|
75
|
+
- spec/**/*
|
76
|
+
Style/RaiseArgs:
|
77
|
+
Description: Checks the arguments passed to raise/fail.
|
78
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
|
79
|
+
Enabled: false
|
80
|
+
EnforcedStyle: exploded
|
81
|
+
SupportedStyles:
|
82
|
+
- compact
|
83
|
+
- exploded
|
84
|
+
Style/SignalException:
|
85
|
+
Description: Checks for proper usage of fail and raise.
|
86
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
|
87
|
+
Enabled: true
|
88
|
+
EnforcedStyle: semantic
|
89
|
+
SupportedStyles:
|
90
|
+
- only_raise
|
91
|
+
- only_fail
|
92
|
+
- semantic
|
93
|
+
Style/SingleLineBlockParams:
|
94
|
+
Description: Enforces the names of some block params.
|
95
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
|
96
|
+
Enabled: false
|
97
|
+
Methods:
|
98
|
+
- reduce:
|
99
|
+
- a
|
100
|
+
- e
|
101
|
+
- inject:
|
102
|
+
- a
|
103
|
+
- e
|
104
|
+
Style/SingleLineMethods:
|
105
|
+
Description: Avoid single-line methods.
|
106
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
|
107
|
+
Enabled: false
|
108
|
+
AllowIfMethodIsEmpty: true
|
109
|
+
Style/StringLiterals:
|
110
|
+
Description: Checks if uses of quotes match the configured preference.
|
111
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
|
112
|
+
Enabled: true
|
113
|
+
EnforcedStyle: single_quotes
|
114
|
+
SupportedStyles:
|
115
|
+
- single_quotes
|
116
|
+
- double_quotes
|
117
|
+
Style/StringLiteralsInInterpolation:
|
118
|
+
Description: Checks if uses of quotes inside expressions in interpolated strings
|
119
|
+
match the configured preference.
|
120
|
+
Enabled: true
|
121
|
+
EnforcedStyle: single_quotes
|
122
|
+
SupportedStyles:
|
123
|
+
- single_quotes
|
124
|
+
- double_quotes
|
125
|
+
Style/TrailingCommaInArguments:
|
126
|
+
Description: 'Checks for trailing comma in argument lists.'
|
127
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
128
|
+
Enabled: true
|
129
|
+
EnforcedStyleForMultiline: no_comma
|
130
|
+
Style/TrailingCommaInArrayLiteral:
|
131
|
+
Description: 'Checks for trailing comma in array literals.'
|
132
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
133
|
+
Enabled: true
|
134
|
+
EnforcedStyleForMultiline: no_comma
|
135
|
+
Style/TrailingCommaInHashLiteral:
|
136
|
+
Description: 'Checks for trailing comma in hash literals.'
|
137
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
138
|
+
Enabled: true
|
139
|
+
EnforcedStyleForMultiline: no_comma
|
140
|
+
Metrics/AbcSize:
|
141
|
+
Description: A calculated magnitude based on number of assignments, branches, and
|
142
|
+
conditions.
|
143
|
+
Enabled: false
|
144
|
+
Max: 15
|
145
|
+
Metrics/ClassLength:
|
146
|
+
Description: Avoid classes longer than 100 lines of code.
|
147
|
+
Enabled: false
|
148
|
+
CountComments: false
|
149
|
+
Max: 100
|
150
|
+
Metrics/ModuleLength:
|
151
|
+
CountComments: false
|
152
|
+
Max: 100
|
153
|
+
Description: Avoid modules longer than 100 lines of code.
|
154
|
+
Enabled: false
|
155
|
+
Metrics/CyclomaticComplexity:
|
156
|
+
Description: A complexity metric that is strongly correlated to the number of test
|
157
|
+
cases needed to validate a method.
|
158
|
+
Enabled: false
|
159
|
+
Max: 6
|
160
|
+
Metrics/MethodLength:
|
161
|
+
Description: Avoid methods longer than 10 lines of code.
|
162
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
|
163
|
+
Enabled: false
|
164
|
+
CountComments: false
|
165
|
+
Max: 10
|
166
|
+
Metrics/ParameterLists:
|
167
|
+
Description: Avoid parameter lists longer than three or four parameters.
|
168
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
|
169
|
+
Enabled: false
|
170
|
+
Max: 5
|
171
|
+
CountKeywordArgs: true
|
172
|
+
Metrics/PerceivedComplexity:
|
173
|
+
Description: A complexity metric geared towards measuring complexity for a human
|
174
|
+
reader.
|
175
|
+
Enabled: false
|
176
|
+
Max: 7
|
177
|
+
Lint/AssignmentInCondition:
|
178
|
+
Description: Don't use assignment in conditions.
|
179
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
|
180
|
+
Enabled: false
|
181
|
+
AllowSafeAssignment: true
|
182
|
+
Style/InlineComment:
|
183
|
+
Description: Avoid inline comments.
|
184
|
+
Enabled: false
|
185
|
+
Naming/AccessorMethodName:
|
186
|
+
Description: Check the naming of accessor methods for get_/set_.
|
187
|
+
Enabled: false
|
188
|
+
Style/Alias:
|
189
|
+
Description: Use alias_method instead of alias.
|
190
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
|
191
|
+
Enabled: false
|
192
|
+
Style/Documentation:
|
193
|
+
Description: Document classes and non-namespace modules.
|
194
|
+
Enabled: false
|
195
|
+
Style/DoubleNegation:
|
196
|
+
Description: Checks for uses of double negation (!!).
|
197
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
|
198
|
+
Enabled: false
|
199
|
+
Style/EachWithObject:
|
200
|
+
Description: Prefer `each_with_object` over `inject` or `reduce`.
|
201
|
+
Enabled: false
|
202
|
+
Style/EmptyLiteral:
|
203
|
+
Description: Prefer literals to Array.new/Hash.new/String.new.
|
204
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
|
205
|
+
Enabled: false
|
206
|
+
Style/ModuleFunction:
|
207
|
+
Description: Checks for usage of `extend self` in modules.
|
208
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
|
209
|
+
Enabled: false
|
210
|
+
Style/OneLineConditional:
|
211
|
+
Description: Favor the ternary operator(?:) over if/then/else/end constructs.
|
212
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
|
213
|
+
Enabled: false
|
214
|
+
Style/PerlBackrefs:
|
215
|
+
Description: Avoid Perl-style regex back references.
|
216
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
|
217
|
+
Enabled: false
|
218
|
+
Style/Send:
|
219
|
+
Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
|
220
|
+
may overlap with existing methods.
|
221
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
|
222
|
+
Enabled: false
|
223
|
+
Style/SpecialGlobalVars:
|
224
|
+
Description: Avoid Perl-style global variables.
|
225
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
|
226
|
+
Enabled: false
|
227
|
+
Style/VariableInterpolation:
|
228
|
+
Description: Don't interpolate global, instance and class variables directly in
|
229
|
+
strings.
|
230
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
|
231
|
+
Enabled: false
|
232
|
+
Style/WhenThen:
|
233
|
+
Description: Use when x then ... for one-line cases.
|
234
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
|
235
|
+
Enabled: false
|
236
|
+
Lint/EachWithObjectArgument:
|
237
|
+
Description: Check for immutable argument given to each_with_object.
|
238
|
+
Enabled: true
|
239
|
+
Lint/HandleExceptions:
|
240
|
+
Description: Don't suppress exception.
|
241
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
|
242
|
+
Enabled: false
|
243
|
+
Lint/LiteralAsCondition:
|
244
|
+
Description: Checks of literals used in conditions.
|
245
|
+
Enabled: false
|
246
|
+
Lint/LiteralInInterpolation:
|
247
|
+
Description: Checks for literals used in interpolation.
|
248
|
+
Enabled: false
|
249
|
+
|
250
|
+
##################### Rails ##################################
|
251
|
+
|
252
|
+
Rails/ActionFilter:
|
253
|
+
Description: 'Enforces consistent use of action filter methods.'
|
254
|
+
Enabled: true
|
255
|
+
Rails/Date:
|
256
|
+
Description: >-
|
257
|
+
Checks the correct usage of date aware methods,
|
258
|
+
such as Date.today, Date.current etc.
|
259
|
+
Enabled: true
|
260
|
+
Rails/Delegate:
|
261
|
+
Description: 'Prefer delegate method for delegations.'
|
262
|
+
Enabled: true
|
263
|
+
Rails/Exit:
|
264
|
+
Description: >-
|
265
|
+
Favor `fail`, `break`, `return`, etc. over `exit` in
|
266
|
+
application or library code outside of Rake files to avoid
|
267
|
+
exits during unit testing or running in production.
|
268
|
+
Enabled: true
|
269
|
+
Rails/FindBy:
|
270
|
+
Description: 'Prefer find_by over where.first.'
|
271
|
+
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find_by'
|
272
|
+
Enabled: true
|
273
|
+
Rails/FindEach:
|
274
|
+
Description: 'Prefer all.find_each over all.find.'
|
275
|
+
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find-each'
|
276
|
+
Enabled: true
|
277
|
+
Rails/HasAndBelongsToMany:
|
278
|
+
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
|
279
|
+
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has-many-through'
|
280
|
+
Enabled: true
|
281
|
+
Rails/HttpPositionalArguments:
|
282
|
+
Description: 'Rails 5 only, disabled to keep Hound quiet'
|
283
|
+
Enabled: false
|
284
|
+
Rails/NotNullColumn:
|
285
|
+
Description: 'Do not add a NOT NULL column without a default value'
|
286
|
+
Enabled: false
|
287
|
+
Rails/Output:
|
288
|
+
Description: 'Checks for calls to puts, print, etc.'
|
289
|
+
Enabled: true
|
290
|
+
Rails/OutputSafety:
|
291
|
+
Description: 'The use of `html_safe` or `raw` may be a security risk.'
|
292
|
+
Enabled: true
|
293
|
+
Rails/PluralizationGrammar:
|
294
|
+
Description: 'Checks for incorrect grammar when using methods like `3.day.ago`.'
|
295
|
+
Enabled: true
|
296
|
+
Rails/ReadWriteAttribute:
|
297
|
+
Description: >-
|
298
|
+
Checks for read_attribute(:attr) and
|
299
|
+
write_attribute(:attr, val).
|
300
|
+
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#read-attribute'
|
301
|
+
Enabled: true
|
302
|
+
Rails/RequestReferer:
|
303
|
+
Description: 'Use consistent syntax for request.referer.'
|
304
|
+
Enabled: true
|
305
|
+
Rails/SafeNavigation:
|
306
|
+
Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`"
|
307
|
+
Enabled: true
|
308
|
+
Rails/ScopeArgs:
|
309
|
+
Description: 'Checks the arguments of ActiveRecord scopes.'
|
310
|
+
Enabled: true
|
311
|
+
Rails/TimeZone:
|
312
|
+
Description: 'Checks the correct usage of time zone aware methods.'
|
313
|
+
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
|
314
|
+
Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
|
315
|
+
Enabled: true
|
316
|
+
Rails/UniqBeforePluck:
|
317
|
+
Description: 'Prefer the use of uniq or distinct before pluck.'
|
318
|
+
Enabled: true
|
319
|
+
Rails/Validation:
|
320
|
+
Description: 'Use validates :attribute, hash of validations.'
|
321
|
+
Enabled: true
|
322
|
+
Security/JSONLoad:
|
323
|
+
Description : 'Prefer usage of JSON.parse'
|
324
|
+
Enabled: true
|
325
|
+
|
12
326
|
Layout/DotPosition:
|
13
327
|
Description: Checks the position of the dot in multi-line method calls.
|
14
328
|
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
|
@@ -43,6 +357,3 @@ Style/StringLiterals:
|
|
43
357
|
SupportedStyles:
|
44
358
|
- single_quotes
|
45
359
|
- double_quotes
|
46
|
-
Rails/DynamicFindBy:
|
47
|
-
Exclude:
|
48
|
-
- "spec/features/**/*"
|
data/Rakefile
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module SynchronizedModel
|
3
4
|
class MessageReceive
|
4
5
|
attr_reader :message
|
@@ -19,7 +20,7 @@ module SynchronizedModel
|
|
19
20
|
|
20
21
|
def update_model
|
21
22
|
if chronological_update?(model)
|
22
|
-
model.
|
23
|
+
model.updated_at = updated_dates[:was]
|
23
24
|
model.save!
|
24
25
|
else
|
25
26
|
log_message = "Outdated message for #{model.class} " \
|
@@ -28,8 +29,17 @@ module SynchronizedModel
|
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
|
-
def chronological_update?(
|
32
|
-
!(
|
32
|
+
def chronological_update?(_model)
|
33
|
+
!(updated_dates[:was] && updated_dates[:was] >= updated_dates[:current])
|
34
|
+
end
|
35
|
+
|
36
|
+
def updated_dates
|
37
|
+
if model.respond_to? :updated_at_was
|
38
|
+
{ was: model.updated_at_was, current: model.updated_at }
|
39
|
+
else
|
40
|
+
change = model.column_change(:updated_at)
|
41
|
+
{ was: change[0], current: change[1] }
|
42
|
+
end
|
33
43
|
end
|
34
44
|
|
35
45
|
def model
|
@@ -3,7 +3,11 @@
|
|
3
3
|
module SynchronizedModel
|
4
4
|
module PublishMixin
|
5
5
|
def to_message_payload
|
6
|
-
attributes
|
6
|
+
if defined? attributes
|
7
|
+
attributes.merge(additional_message_attributes)
|
8
|
+
else
|
9
|
+
values.merge(additional_message_attributes)
|
10
|
+
end
|
7
11
|
end
|
8
12
|
|
9
13
|
private
|
data/lib/tasks/publish.rake
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synchronized_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Cranston
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -116,9 +116,8 @@ extensions: []
|
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
118
|
- ".circleci/config.yml"
|
119
|
+
- ".codeclimate.yml"
|
119
120
|
- ".gitignore"
|
120
|
-
- ".hound-rubocop.yml"
|
121
|
-
- ".hound.yml"
|
122
121
|
- ".rspec"
|
123
122
|
- ".rubocop.yml"
|
124
123
|
- CODE_OF_CONDUCT.md
|
data/.hound-rubocop.yml
DELETED
@@ -1,323 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 2.2
|
3
|
-
Exclude:
|
4
|
-
- "vendor/**/*"
|
5
|
-
- "db/schema.rb"
|
6
|
-
UseCache: false
|
7
|
-
Layout/DotPosition:
|
8
|
-
Description: Checks the position of the dot in multi-line method calls.
|
9
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
|
10
|
-
Enabled: true
|
11
|
-
EnforcedStyle: trailing
|
12
|
-
SupportedStyles:
|
13
|
-
- leading
|
14
|
-
- trailing
|
15
|
-
Layout/EmptyLineAfterMagicComment:
|
16
|
-
Description: 'Add an empty line after magic comments to separate them from code.'
|
17
|
-
StyleGuide: '#separate-magic-comments-from-code'
|
18
|
-
Enabled: false
|
19
|
-
Lint/AmbiguousBlockAssociation:
|
20
|
-
Exclude:
|
21
|
-
- "spec/**/*"
|
22
|
-
Style/CollectionMethods:
|
23
|
-
Description: Preferred collection methods.
|
24
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
|
25
|
-
Enabled: true
|
26
|
-
PreferredMethods:
|
27
|
-
collect: map
|
28
|
-
collect!: map!
|
29
|
-
find: detect
|
30
|
-
find_all: select
|
31
|
-
reduce: inject
|
32
|
-
Naming/FileName:
|
33
|
-
Description: Use snake_case for source file names.
|
34
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
|
35
|
-
Enabled: false
|
36
|
-
Exclude: []
|
37
|
-
Style/GuardClause:
|
38
|
-
Description: Check for conditionals that can be replaced with guard clauses
|
39
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
|
40
|
-
Enabled: false
|
41
|
-
MinBodyLength: 1
|
42
|
-
Style/IfUnlessModifier:
|
43
|
-
Description: Favor modifier if/unless usage when you have a single-line body.
|
44
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
|
45
|
-
Enabled: false
|
46
|
-
Style/OptionHash:
|
47
|
-
Description: Don't use option hashes when you can use keyword arguments.
|
48
|
-
Enabled: false
|
49
|
-
Style/PercentLiteralDelimiters:
|
50
|
-
Description: Use `%`-literal delimiters consistently
|
51
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
|
52
|
-
Enabled: false
|
53
|
-
PreferredDelimiters:
|
54
|
-
"%": "()"
|
55
|
-
"%i": "()"
|
56
|
-
"%q": "()"
|
57
|
-
"%Q": "()"
|
58
|
-
"%r": "{}"
|
59
|
-
"%s": "()"
|
60
|
-
"%w": "()"
|
61
|
-
"%W": "()"
|
62
|
-
"%x": "()"
|
63
|
-
Naming/PredicateName:
|
64
|
-
Description: Check the names of predicate methods.
|
65
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
|
66
|
-
Enabled: true
|
67
|
-
NamePrefix:
|
68
|
-
- is_
|
69
|
-
- has_
|
70
|
-
- have_
|
71
|
-
NamePrefixBlacklist:
|
72
|
-
- is_
|
73
|
-
Exclude:
|
74
|
-
- spec/**/*
|
75
|
-
Style/RaiseArgs:
|
76
|
-
Description: Checks the arguments passed to raise/fail.
|
77
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
|
78
|
-
Enabled: false
|
79
|
-
EnforcedStyle: exploded
|
80
|
-
SupportedStyles:
|
81
|
-
- compact
|
82
|
-
- exploded
|
83
|
-
Style/SignalException:
|
84
|
-
Description: Checks for proper usage of fail and raise.
|
85
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
|
86
|
-
Enabled: true
|
87
|
-
EnforcedStyle: semantic
|
88
|
-
SupportedStyles:
|
89
|
-
- only_raise
|
90
|
-
- only_fail
|
91
|
-
- semantic
|
92
|
-
Style/SingleLineBlockParams:
|
93
|
-
Description: Enforces the names of some block params.
|
94
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
|
95
|
-
Enabled: false
|
96
|
-
Methods:
|
97
|
-
- reduce:
|
98
|
-
- a
|
99
|
-
- e
|
100
|
-
- inject:
|
101
|
-
- a
|
102
|
-
- e
|
103
|
-
Style/SingleLineMethods:
|
104
|
-
Description: Avoid single-line methods.
|
105
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
|
106
|
-
Enabled: false
|
107
|
-
AllowIfMethodIsEmpty: true
|
108
|
-
Style/StringLiterals:
|
109
|
-
Description: Checks if uses of quotes match the configured preference.
|
110
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
|
111
|
-
Enabled: true
|
112
|
-
EnforcedStyle: double_quotes
|
113
|
-
SupportedStyles:
|
114
|
-
- single_quotes
|
115
|
-
- double_quotes
|
116
|
-
Style/StringLiteralsInInterpolation:
|
117
|
-
Description: Checks if uses of quotes inside expressions in interpolated strings
|
118
|
-
match the configured preference.
|
119
|
-
Enabled: true
|
120
|
-
EnforcedStyle: single_quotes
|
121
|
-
SupportedStyles:
|
122
|
-
- single_quotes
|
123
|
-
- double_quotes
|
124
|
-
Style/TrailingCommaInArguments:
|
125
|
-
Description: 'Checks for trailing comma in argument lists.'
|
126
|
-
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
127
|
-
Enabled: true
|
128
|
-
EnforcedStyleForMultiline: no_comma
|
129
|
-
Style/TrailingCommaInArrayLiteral:
|
130
|
-
Description: 'Checks for trailing comma in array literals.'
|
131
|
-
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
132
|
-
Enabled: true
|
133
|
-
EnforcedStyleForMultiline: no_comma
|
134
|
-
Style/TrailingCommaInHashLiteral:
|
135
|
-
Description: 'Checks for trailing comma in hash literals.'
|
136
|
-
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
137
|
-
Enabled: true
|
138
|
-
EnforcedStyleForMultiline: no_comma
|
139
|
-
Metrics/AbcSize:
|
140
|
-
Description: A calculated magnitude based on number of assignments, branches, and
|
141
|
-
conditions.
|
142
|
-
Enabled: false
|
143
|
-
Max: 15
|
144
|
-
Metrics/ClassLength:
|
145
|
-
Description: Avoid classes longer than 100 lines of code.
|
146
|
-
Enabled: false
|
147
|
-
CountComments: false
|
148
|
-
Max: 100
|
149
|
-
Metrics/ModuleLength:
|
150
|
-
CountComments: false
|
151
|
-
Max: 100
|
152
|
-
Description: Avoid modules longer than 100 lines of code.
|
153
|
-
Enabled: false
|
154
|
-
Metrics/CyclomaticComplexity:
|
155
|
-
Description: A complexity metric that is strongly correlated to the number of test
|
156
|
-
cases needed to validate a method.
|
157
|
-
Enabled: false
|
158
|
-
Max: 6
|
159
|
-
Metrics/MethodLength:
|
160
|
-
Description: Avoid methods longer than 10 lines of code.
|
161
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
|
162
|
-
Enabled: false
|
163
|
-
CountComments: false
|
164
|
-
Max: 10
|
165
|
-
Metrics/ParameterLists:
|
166
|
-
Description: Avoid parameter lists longer than three or four parameters.
|
167
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
|
168
|
-
Enabled: false
|
169
|
-
Max: 5
|
170
|
-
CountKeywordArgs: true
|
171
|
-
Metrics/PerceivedComplexity:
|
172
|
-
Description: A complexity metric geared towards measuring complexity for a human
|
173
|
-
reader.
|
174
|
-
Enabled: false
|
175
|
-
Max: 7
|
176
|
-
Lint/AssignmentInCondition:
|
177
|
-
Description: Don't use assignment in conditions.
|
178
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
|
179
|
-
Enabled: false
|
180
|
-
AllowSafeAssignment: true
|
181
|
-
Style/InlineComment:
|
182
|
-
Description: Avoid inline comments.
|
183
|
-
Enabled: false
|
184
|
-
Naming/AccessorMethodName:
|
185
|
-
Description: Check the naming of accessor methods for get_/set_.
|
186
|
-
Enabled: false
|
187
|
-
Style/Alias:
|
188
|
-
Description: Use alias_method instead of alias.
|
189
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
|
190
|
-
Enabled: false
|
191
|
-
Style/Documentation:
|
192
|
-
Description: Document classes and non-namespace modules.
|
193
|
-
Enabled: false
|
194
|
-
Style/DoubleNegation:
|
195
|
-
Description: Checks for uses of double negation (!!).
|
196
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
|
197
|
-
Enabled: false
|
198
|
-
Style/EachWithObject:
|
199
|
-
Description: Prefer `each_with_object` over `inject` or `reduce`.
|
200
|
-
Enabled: false
|
201
|
-
Style/EmptyLiteral:
|
202
|
-
Description: Prefer literals to Array.new/Hash.new/String.new.
|
203
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
|
204
|
-
Enabled: false
|
205
|
-
Style/ModuleFunction:
|
206
|
-
Description: Checks for usage of `extend self` in modules.
|
207
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
|
208
|
-
Enabled: false
|
209
|
-
Style/OneLineConditional:
|
210
|
-
Description: Favor the ternary operator(?:) over if/then/else/end constructs.
|
211
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
|
212
|
-
Enabled: false
|
213
|
-
Style/PerlBackrefs:
|
214
|
-
Description: Avoid Perl-style regex back references.
|
215
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
|
216
|
-
Enabled: false
|
217
|
-
Style/Send:
|
218
|
-
Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
|
219
|
-
may overlap with existing methods.
|
220
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
|
221
|
-
Enabled: false
|
222
|
-
Style/SpecialGlobalVars:
|
223
|
-
Description: Avoid Perl-style global variables.
|
224
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
|
225
|
-
Enabled: false
|
226
|
-
Style/VariableInterpolation:
|
227
|
-
Description: Don't interpolate global, instance and class variables directly in
|
228
|
-
strings.
|
229
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
|
230
|
-
Enabled: false
|
231
|
-
Style/WhenThen:
|
232
|
-
Description: Use when x then ... for one-line cases.
|
233
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
|
234
|
-
Enabled: false
|
235
|
-
Lint/EachWithObjectArgument:
|
236
|
-
Description: Check for immutable argument given to each_with_object.
|
237
|
-
Enabled: true
|
238
|
-
Lint/HandleExceptions:
|
239
|
-
Description: Don't suppress exception.
|
240
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
|
241
|
-
Enabled: false
|
242
|
-
Lint/LiteralAsCondition:
|
243
|
-
Description: Checks of literals used in conditions.
|
244
|
-
Enabled: false
|
245
|
-
Lint/LiteralInInterpolation:
|
246
|
-
Description: Checks for literals used in interpolation.
|
247
|
-
Enabled: false
|
248
|
-
|
249
|
-
##################### Rails ##################################
|
250
|
-
|
251
|
-
Rails/ActionFilter:
|
252
|
-
Description: 'Enforces consistent use of action filter methods.'
|
253
|
-
Enabled: true
|
254
|
-
Rails/Date:
|
255
|
-
Description: >-
|
256
|
-
Checks the correct usage of date aware methods,
|
257
|
-
such as Date.today, Date.current etc.
|
258
|
-
Enabled: true
|
259
|
-
Rails/Delegate:
|
260
|
-
Description: 'Prefer delegate method for delegations.'
|
261
|
-
Enabled: true
|
262
|
-
Rails/Exit:
|
263
|
-
Description: >-
|
264
|
-
Favor `fail`, `break`, `return`, etc. over `exit` in
|
265
|
-
application or library code outside of Rake files to avoid
|
266
|
-
exits during unit testing or running in production.
|
267
|
-
Enabled: true
|
268
|
-
Rails/FindBy:
|
269
|
-
Description: 'Prefer find_by over where.first.'
|
270
|
-
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find_by'
|
271
|
-
Enabled: true
|
272
|
-
Rails/FindEach:
|
273
|
-
Description: 'Prefer all.find_each over all.find.'
|
274
|
-
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#find-each'
|
275
|
-
Enabled: true
|
276
|
-
Rails/HasAndBelongsToMany:
|
277
|
-
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
|
278
|
-
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has-many-through'
|
279
|
-
Enabled: true
|
280
|
-
Rails/HttpPositionalArguments:
|
281
|
-
Description: 'Rails 5 only, disabled to keep Hound quiet'
|
282
|
-
Enabled: false
|
283
|
-
Rails/NotNullColumn:
|
284
|
-
Description: 'Do not add a NOT NULL column without a default value'
|
285
|
-
Enabled: false
|
286
|
-
Rails/Output:
|
287
|
-
Description: 'Checks for calls to puts, print, etc.'
|
288
|
-
Enabled: true
|
289
|
-
Rails/OutputSafety:
|
290
|
-
Description: 'The use of `html_safe` or `raw` may be a security risk.'
|
291
|
-
Enabled: true
|
292
|
-
Rails/PluralizationGrammar:
|
293
|
-
Description: 'Checks for incorrect grammar when using methods like `3.day.ago`.'
|
294
|
-
Enabled: true
|
295
|
-
Rails/ReadWriteAttribute:
|
296
|
-
Description: >-
|
297
|
-
Checks for read_attribute(:attr) and
|
298
|
-
write_attribute(:attr, val).
|
299
|
-
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#read-attribute'
|
300
|
-
Enabled: true
|
301
|
-
Rails/RequestReferer:
|
302
|
-
Description: 'Use consistent syntax for request.referer.'
|
303
|
-
Enabled: true
|
304
|
-
Rails/SafeNavigation:
|
305
|
-
Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`"
|
306
|
-
Enabled: true
|
307
|
-
Rails/ScopeArgs:
|
308
|
-
Description: 'Checks the arguments of ActiveRecord scopes.'
|
309
|
-
Enabled: true
|
310
|
-
Rails/TimeZone:
|
311
|
-
Description: 'Checks the correct usage of time zone aware methods.'
|
312
|
-
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
|
313
|
-
Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
|
314
|
-
Enabled: true
|
315
|
-
Rails/UniqBeforePluck:
|
316
|
-
Description: 'Prefer the use of uniq or distinct before pluck.'
|
317
|
-
Enabled: true
|
318
|
-
Rails/Validation:
|
319
|
-
Description: 'Use validates :attribute, hash of validations.'
|
320
|
-
Enabled: true
|
321
|
-
Security/JSONLoad:
|
322
|
-
Description : 'Prefer usage of JSON.parse'
|
323
|
-
Enabled: true
|