danger-semantic-commit 0.2.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8b62c7bb0d1b25fbf4caf4f62cb6a5e6e48b7ce0
4
+ data.tar.gz: d8b190a0bad9676f681db950b5dcefd79e883f53
5
+ SHA512:
6
+ metadata.gz: f8da83b84905a68909b2d67eef51b0cad4ad56590db7994126189580e155d002ba0f2e45e52e6104b53b1523bf212d799a2a9325fd828c962de270496a81a2f2
7
+ data.tar.gz: c9604574dc8e53b1075d8499f5e9813e5ab7265a12f72c8ffd2a9c2fa6b4448c216909be79ce603f71ab0982d51319b387b2fb6dcd01db1ab1d40b769513909b
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ /spec/examples.txt
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,637 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+ Exclude:
4
+ - db/schema.rb
5
+
6
+ Style/AccessorMethodName:
7
+ Description: Check the naming of accessor methods for get_/set_.
8
+ Enabled: false
9
+
10
+ Style/Alias:
11
+ Description: 'Use alias_method instead of alias.'
12
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method'
13
+ Enabled: false
14
+
15
+ Style/ArrayJoin:
16
+ Description: 'Use Array#join instead of Array#*.'
17
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#array-join'
18
+ Enabled: false
19
+
20
+ Style/AsciiComments:
21
+ Description: 'Use only ascii symbols in comments.'
22
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-comments'
23
+ Enabled: false
24
+
25
+ Style/AsciiIdentifiers:
26
+ Description: 'Use only ascii symbols in identifiers.'
27
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-identifiers'
28
+ Enabled: false
29
+
30
+ Style/Attr:
31
+ Description: 'Checks for uses of Module#attr.'
32
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr'
33
+ Enabled: false
34
+
35
+ Metrics/BlockNesting:
36
+ Description: 'Avoid excessive block nesting'
37
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count'
38
+ Enabled: false
39
+
40
+ Style/CaseEquality:
41
+ Description: 'Avoid explicit use of the case equality operator(===).'
42
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-case-equality'
43
+ Enabled: false
44
+
45
+ Style/CharacterLiteral:
46
+ Description: 'Checks for uses of character literals.'
47
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-character-literals'
48
+ Enabled: false
49
+
50
+ Style/ClassAndModuleChildren:
51
+ Description: 'Checks style of children classes and modules.'
52
+ Enabled: true
53
+ EnforcedStyle: compact
54
+
55
+ Metrics/ClassLength:
56
+ Description: 'Avoid classes longer than 100 lines of code.'
57
+ Enabled: false
58
+
59
+ Metrics/ModuleLength:
60
+ Description: 'Avoid modules longer than 100 lines of code.'
61
+ Enabled: false
62
+
63
+ Style/ClassVars:
64
+ Description: 'Avoid the use of class variables.'
65
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-class-vars'
66
+ Enabled: false
67
+
68
+ Style/CollectionMethods:
69
+ Enabled: true
70
+ PreferredMethods:
71
+ find: detect
72
+ inject: reduce
73
+ collect: map
74
+ find_all: select
75
+
76
+ Style/ColonMethodCall:
77
+ Description: 'Do not use :: for method call.'
78
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#double-colons'
79
+ Enabled: false
80
+
81
+ Style/CommentAnnotation:
82
+ Description: >-
83
+ Checks formatting of special comments
84
+ (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
85
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#annotate-keywords'
86
+ Enabled: false
87
+
88
+ Metrics/AbcSize:
89
+ Description: >-
90
+ A calculated magnitude based on number of assignments,
91
+ branches, and conditions.
92
+ Enabled: false
93
+
94
+ Metrics/CyclomaticComplexity:
95
+ Description: >-
96
+ A complexity metric that is strongly correlated to the number
97
+ of test cases needed to validate a method.
98
+ Enabled: false
99
+
100
+ Rails/Delegate:
101
+ Description: 'Prefer delegate method for delegations.'
102
+ Enabled: false
103
+
104
+ Style/PreferredHashMethods:
105
+ Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
106
+ StyleGuide: '#hash-key'
107
+ Enabled: false
108
+
109
+ Style/Documentation:
110
+ Description: 'Document classes and non-namespace modules.'
111
+ Enabled: false
112
+
113
+ Style/DotPosition:
114
+ Description: 'Checks the position of the dot in multi-line method calls.'
115
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
116
+ EnforcedStyle: leading
117
+
118
+ Style/DoubleNegation:
119
+ Description: 'Checks for uses of double negation (!!).'
120
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-bang-bang'
121
+ Enabled: false
122
+
123
+ Style/EachWithObject:
124
+ Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
125
+ Enabled: false
126
+
127
+ Style/EmptyLiteral:
128
+ Description: 'Prefer literals to Array.new/Hash.new/String.new.'
129
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#literal-array-hash'
130
+ Enabled: false
131
+
132
+ # Checks whether the source file has a utf-8 encoding comment or not
133
+ # AutoCorrectEncodingComment must match the regex
134
+ # /#.*coding\s?[:=]\s?(?:UTF|utf)-8/
135
+ Style/Encoding:
136
+ Enabled: false
137
+
138
+ Style/EvenOdd:
139
+ Description: 'Favor the use of Fixnum#even? && Fixnum#odd?'
140
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
141
+ Enabled: false
142
+
143
+ Style/ExtraSpacing:
144
+ Description: 'Do not use unnecessary spacing.'
145
+ Enabled: true
146
+
147
+ Style/FileName:
148
+ Description: 'Use snake_case for source file names.'
149
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
150
+ Enabled: false
151
+
152
+ Style/FrozenStringLiteralComment:
153
+ Description: >-
154
+ Add the frozen_string_literal comment to the top of files
155
+ to help transition from Ruby 2.3.0 to Ruby 3.0.
156
+ Enabled: false
157
+
158
+ Style/FlipFlop:
159
+ Description: 'Checks for flip flops'
160
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-flip-flops'
161
+ Enabled: false
162
+
163
+ Style/FormatString:
164
+ Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
165
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#sprintf'
166
+ Enabled: false
167
+
168
+ Style/GlobalVars:
169
+ Description: 'Do not introduce global variables.'
170
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#instance-vars'
171
+ Reference: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html'
172
+ Enabled: false
173
+
174
+ Style/GuardClause:
175
+ Description: 'Check for conditionals that can be replaced with guard clauses'
176
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
177
+ Enabled: false
178
+
179
+ Style/IfUnlessModifier:
180
+ Description: >-
181
+ Favor modifier if/unless usage when you have a
182
+ single-line body.
183
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
184
+ Enabled: false
185
+
186
+ Style/IfWithSemicolon:
187
+ Description: 'Do not use if x; .... Use the ternary operator instead.'
188
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-semicolon-ifs'
189
+ Enabled: false
190
+
191
+ Style/InlineComment:
192
+ Description: 'Avoid inline comments.'
193
+ Enabled: false
194
+
195
+ Style/Lambda:
196
+ Description: 'Use the new lambda literal syntax for single-line blocks.'
197
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#lambda-multi-line'
198
+ Enabled: false
199
+
200
+ Style/LambdaCall:
201
+ Description: 'Use lambda.call(...) instead of lambda.(...).'
202
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc-call'
203
+ Enabled: false
204
+
205
+ Style/LineEndConcatenation:
206
+ Description: >-
207
+ Use \ instead of + or << to concatenate two string literals at
208
+ line end.
209
+ Enabled: false
210
+
211
+ Metrics/LineLength:
212
+ Description: 'Limit lines to 150 characters.'
213
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
214
+ Max: 150
215
+
216
+ Metrics/MethodLength:
217
+ Description: 'Avoid methods longer than 10 lines of code.'
218
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
219
+ Enabled: false
220
+
221
+ Style/ModuleFunction:
222
+ Description: 'Checks for usage of `extend self` in modules.'
223
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#module-function'
224
+ Enabled: false
225
+
226
+ Style/MultilineOperationIndentation:
227
+ Description: >-
228
+ Checks indentation of binary operations that span more than
229
+ one line.
230
+ Enabled: true
231
+ EnforcedStyle: indented
232
+
233
+ Style/MultilineBlockChain:
234
+ Description: 'Avoid multi-line chains of blocks.'
235
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
236
+ Enabled: false
237
+
238
+ Style/MultilineMethodCallIndentation:
239
+ Description: >-
240
+ Checks indentation of method calls with the dot operator
241
+ that span more than one line.
242
+ Enabled: true
243
+ EnforcedStyle: indented
244
+
245
+ Style/NegatedIf:
246
+ Description: >-
247
+ Favor unless over if for negative conditions
248
+ (or control flow or).
249
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#unless-for-negatives'
250
+ Enabled: false
251
+
252
+ Style/NegatedWhile:
253
+ Description: 'Favor until over while for negative conditions.'
254
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#until-for-negatives'
255
+ Enabled: false
256
+
257
+ Style/Next:
258
+ Description: 'Use `next` to skip iteration instead of a condition at the end.'
259
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
260
+ Enabled: false
261
+
262
+ Style/NilComparison:
263
+ Description: 'Prefer x.nil? to x == nil.'
264
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
265
+ Enabled: false
266
+
267
+ Style/Not:
268
+ Description: 'Use ! instead of not.'
269
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bang-not-not'
270
+ Enabled: false
271
+
272
+ Style/NumericLiterals:
273
+ Description: >-
274
+ Add underscores to large numeric literals to improve their
275
+ readability.
276
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscores-in-numerics'
277
+ Enabled: false
278
+
279
+ Style/OneLineConditional:
280
+ Description: >-
281
+ Favor the ternary operator(?:) over
282
+ if/then/else/end constructs.
283
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#ternary-operator'
284
+ Enabled: false
285
+
286
+ Style/OpMethod:
287
+ Description: 'When defining binary operators, name the argument other.'
288
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#other-arg'
289
+ Enabled: false
290
+
291
+ Metrics/ParameterLists:
292
+ Description: 'Avoid parameter lists longer than three or four parameters.'
293
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#too-many-params'
294
+ Enabled: false
295
+
296
+ Style/PercentLiteralDelimiters:
297
+ Description: 'Use `%`-literal delimiters consistently'
298
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-literal-braces'
299
+ Enabled: false
300
+
301
+ Style/PerlBackrefs:
302
+ Description: 'Avoid Perl-style regex back references.'
303
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
304
+ Enabled: false
305
+
306
+ Style/PredicateName:
307
+ Description: 'Check the names of predicate methods.'
308
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark'
309
+ NamePrefixBlacklist:
310
+ - is_
311
+ Exclude:
312
+ - spec/**/*
313
+
314
+ Style/Proc:
315
+ Description: 'Use proc instead of Proc.new.'
316
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc'
317
+ Enabled: false
318
+
319
+ Style/RaiseArgs:
320
+ Description: 'Checks the arguments passed to raise/fail.'
321
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#exception-class-messages'
322
+ Enabled: false
323
+
324
+ Style/RegexpLiteral:
325
+ Description: 'Use / or %r around regular expressions.'
326
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-r'
327
+ Enabled: false
328
+
329
+ Style/SelfAssignment:
330
+ Description: >-
331
+ Checks for places where self-assignment shorthand should have
332
+ been used.
333
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment'
334
+ Enabled: false
335
+
336
+ Style/SingleLineBlockParams:
337
+ Description: 'Enforces the names of some block params.'
338
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#reduce-blocks'
339
+ Enabled: false
340
+
341
+ Style/SingleLineMethods:
342
+ Description: 'Avoid single-line methods.'
343
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods'
344
+ Enabled: true
345
+
346
+ Style/SignalException:
347
+ Description: 'Checks for proper usage of fail and raise.'
348
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method'
349
+ Enabled: false
350
+
351
+ Style/SpecialGlobalVars:
352
+ Description: 'Avoid Perl-style global variables.'
353
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms'
354
+ Enabled: false
355
+
356
+ Style/StringLiterals:
357
+ Description: 'Checks if uses of quotes match the configured preference.'
358
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-string-literals'
359
+ EnforcedStyle: double_quotes
360
+ Enabled: true
361
+
362
+ Style/TrailingCommaInArguments:
363
+ Description: 'Checks for trailing comma in argument lists.'
364
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
365
+ EnforcedStyleForMultiline: comma
366
+ SupportedStyles:
367
+ - comma
368
+ - consistent_comma
369
+ - no_comma
370
+ Enabled: true
371
+
372
+ Style/TrailingCommaInLiteral:
373
+ Description: 'Checks for trailing comma in array and hash literals.'
374
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
375
+ EnforcedStyleForMultiline: comma
376
+ SupportedStyles:
377
+ - comma
378
+ - consistent_comma
379
+ - no_comma
380
+ Enabled: true
381
+
382
+ Style/TrivialAccessors:
383
+ Description: 'Prefer attr_* methods to trivial readers/writers.'
384
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr_family'
385
+ Enabled: false
386
+
387
+ Style/VariableInterpolation:
388
+ Description: >-
389
+ Don't interpolate global, instance and class variables
390
+ directly in strings.
391
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#curlies-interpolate'
392
+ Enabled: false
393
+
394
+ Style/WhenThen:
395
+ Description: 'Use when x then ... for one-line cases.'
396
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#one-line-cases'
397
+ Enabled: false
398
+
399
+ Style/WhileUntilModifier:
400
+ Description: >-
401
+ Favor modifier while/until usage when you have a
402
+ single-line body.
403
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#while-as-a-modifier'
404
+ Enabled: false
405
+
406
+ Style/WordArray:
407
+ Description: 'Use %w or %W for arrays of words.'
408
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-w'
409
+ Enabled: false
410
+
411
+ Style/AlignParameters:
412
+ EnforcedStyle: with_fixed_indentation
413
+ Enabled: true
414
+
415
+ # Lint
416
+
417
+ Lint/AmbiguousOperator:
418
+ Description: >-
419
+ Checks for ambiguous operators in the first argument of a
420
+ method invocation without parentheses.
421
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-as-args'
422
+ Enabled: false
423
+
424
+ Lint/AmbiguousRegexpLiteral:
425
+ Description: >-
426
+ Checks for ambiguous regexp literals in the first argument of
427
+ a method invocation without parenthesis.
428
+ Enabled: false
429
+
430
+ Lint/AssignmentInCondition:
431
+ Description: "Don't use assignment in conditions."
432
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition'
433
+ Enabled: false
434
+
435
+ Lint/CircularArgumentReference:
436
+ Description: "Don't refer to the keyword argument in the default value."
437
+ Enabled: false
438
+
439
+ Lint/ConditionPosition:
440
+ Description: >-
441
+ Checks for condition placed in a confusing position relative to
442
+ the keyword.
443
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition'
444
+ Enabled: false
445
+
446
+ Lint/DeprecatedClassMethods:
447
+ Description: 'Check for deprecated class method calls.'
448
+ Enabled: false
449
+
450
+ Lint/DuplicatedKey:
451
+ Description: 'Check for duplicate keys in hash literals.'
452
+ Enabled: false
453
+
454
+ Lint/EachWithObjectArgument:
455
+ Description: 'Check for immutable argument given to each_with_object.'
456
+ Enabled: false
457
+
458
+ Lint/ElseLayout:
459
+ Description: 'Check for odd code arrangement in an else block.'
460
+ Enabled: false
461
+
462
+ Lint/FormatParameterMismatch:
463
+ Description: 'The number of parameters to format/sprint must match the fields.'
464
+ Enabled: false
465
+
466
+ Lint/HandleExceptions:
467
+ Description: "Don't suppress exception."
468
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions'
469
+ Enabled: false
470
+
471
+ Lint/InvalidCharacterLiteral:
472
+ Description: >-
473
+ Checks for invalid character literals with a non-escaped
474
+ whitespace character.
475
+ Enabled: false
476
+
477
+ Style/InitialIndentation:
478
+ Description: >-
479
+ Checks the indentation of the first non-blank non-comment line in a file.
480
+ Enabled: false
481
+
482
+ Lint/LiteralInCondition:
483
+ Description: 'Checks of literals used in conditions.'
484
+ Enabled: false
485
+
486
+ Lint/LiteralInInterpolation:
487
+ Description: 'Checks for literals used in interpolation.'
488
+ Enabled: false
489
+
490
+ Lint/Loop:
491
+ Description: >-
492
+ Use Kernel#loop with break rather than begin/end/until or
493
+ begin/end/while for post-loop tests.
494
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#loop-with-break'
495
+ Enabled: false
496
+
497
+ Lint/NestedMethodDefinition:
498
+ Description: 'Do not use nested method definitions.'
499
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-methods'
500
+ Enabled: false
501
+
502
+ Lint/NonLocalExitFromIterator:
503
+ Description: 'Do not use return in iterator to cause non-local exit.'
504
+ Enabled: false
505
+
506
+ Lint/ParenthesesAsGroupedExpression:
507
+ Description: >-
508
+ Checks for method calls with a space before the opening
509
+ parenthesis.
510
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
511
+ Enabled: false
512
+
513
+ Lint/RequireParentheses:
514
+ Description: >-
515
+ Use parentheses in the method call to avoid confusion
516
+ about precedence.
517
+ Enabled: false
518
+
519
+ Lint/UnderscorePrefixedVariableName:
520
+ Description: 'Do not use prefix `_` for a variable that is used.'
521
+ Enabled: false
522
+
523
+ Lint/UnneededDisable:
524
+ Description: >-
525
+ Checks for rubocop:disable comments that can be removed.
526
+ Note: this cop is not disabled when disabling all cops.
527
+ It must be explicitly disabled.
528
+ Enabled: false
529
+
530
+ Lint/Void:
531
+ Description: 'Possible use of operator/literal/variable in void context.'
532
+ Enabled: false
533
+
534
+ # Performance
535
+
536
+ Performance/CaseWhenSplat:
537
+ Description: >-
538
+ Place `when` conditions that use splat at the end
539
+ of the list of `when` branches.
540
+ Enabled: false
541
+
542
+ Performance/Count:
543
+ Description: >-
544
+ Use `count` instead of `select...size`, `reject...size`,
545
+ `select...count`, `reject...count`, `select...length`,
546
+ and `reject...length`.
547
+ Enabled: false
548
+
549
+ Performance/Detect:
550
+ Description: >-
551
+ Use `detect` instead of `select.first`, `find_all.first`,
552
+ `select.last`, and `find_all.last`.
553
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code'
554
+ Enabled: false
555
+
556
+ Performance/FlatMap:
557
+ Description: >-
558
+ Use `Enumerable#flat_map`
559
+ instead of `Enumerable#map...Array#flatten(1)`
560
+ or `Enumberable#collect..Array#flatten(1)`
561
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code'
562
+ Enabled: false
563
+
564
+ Performance/ReverseEach:
565
+ Description: 'Use `reverse_each` instead of `reverse.each`.'
566
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
567
+ Enabled: false
568
+
569
+ Performance/Sample:
570
+ Description: >-
571
+ Use `sample` instead of `shuffle.first`,
572
+ `shuffle.last`, and `shuffle[Fixnum]`.
573
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
574
+ Enabled: false
575
+
576
+ Performance/Size:
577
+ Description: >-
578
+ Use `size` instead of `count` for counting
579
+ the number of elements in `Array` and `Hash`.
580
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraycount-vs-arraysize-code'
581
+ Enabled: false
582
+
583
+ Performance/StringReplacement:
584
+ Description: >-
585
+ Use `tr` instead of `gsub` when you are replacing the same
586
+ number of characters. Use `delete` instead of `gsub` when
587
+ you are deleting characters.
588
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code'
589
+ Enabled: false
590
+
591
+ # Rails
592
+
593
+ Rails/ActionFilter:
594
+ Description: 'Enforces consistent use of action filter methods.'
595
+ Enabled: false
596
+
597
+ Rails/Date:
598
+ Description: >-
599
+ Checks the correct usage of date aware methods,
600
+ such as Date.today, Date.current etc.
601
+ Enabled: false
602
+
603
+ Rails/FindBy:
604
+ Description: 'Prefer find_by over where.first.'
605
+ Enabled: false
606
+
607
+ Rails/FindEach:
608
+ Description: 'Prefer all.find_each over all.find.'
609
+ Enabled: false
610
+
611
+ Rails/HasAndBelongsToMany:
612
+ Description: 'Prefer has_many :through to has_and_belongs_to_many.'
613
+ Enabled: false
614
+
615
+ Rails/Output:
616
+ Description: 'Checks for calls to puts, print, etc.'
617
+ Enabled: false
618
+
619
+ Rails/ReadWriteAttribute:
620
+ Description: >-
621
+ Checks for read_attribute(:attr) and
622
+ write_attribute(:attr, val).
623
+ Enabled: false
624
+
625
+ Rails/ScopeArgs:
626
+ Description: 'Checks the arguments of ActiveRecord scopes.'
627
+ Enabled: false
628
+
629
+ Rails/TimeZone:
630
+ Description: 'Checks the correct usage of time zone aware methods.'
631
+ StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
632
+ Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
633
+ Enabled: false
634
+
635
+ Rails/Validation:
636
+ Description: 'Use validates :attribute, hash of validations.'
637
+ Enabled: false
@@ -0,0 +1,12 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.1
5
+ - 2.2
6
+ - 2.3.3
7
+ - 2.4.1
8
+
9
+ before_install: gem install bundler -v 1.14.6
10
+
11
+ script:
12
+ - bundle exec danger --verbose
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at mikeastock@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
@@ -0,0 +1 @@
1
+ semantic_commit.validate
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in danger-semantic_commit.gemspec
4
+ gemspec
@@ -0,0 +1,45 @@
1
+ # Danger::SemanticCommit
2
+
3
+ [![Build Status](https://travis-ci.org/mikeastock/danger-semantic-commit.svg?branch=master)](https://travis-ci.org/mikeastock/danger-semantic-commit)
4
+
5
+ A Danger plugin that validates your commits to be semantic. Semantic commits
6
+ idea comes from the Karma Runner project. More information can be found
7
+ [here](http://karma-runner.github.io/1.0/dev/git-commit-msg.html)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem "danger-semantic-commit"
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ ## Usage
22
+
23
+ To use the default config simply add this line to your `Dangerfile`
24
+
25
+ ```
26
+ semantic_config.validate
27
+ ```
28
+
29
+ By default the plugin will fail any commits that don't pass the checks. To change
30
+ this you can pass a config like so:
31
+
32
+ ```
33
+ semantic_commit.validate warn: :all
34
+ ```
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+
40
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mikeastock/danger-semantic-commit. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
45
+
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task default: :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "danger/semantic_commit"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rake' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rake", "rake")
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rspec' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rspec-core", "rspec")
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'semantic_commit/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "danger-semantic-commit"
8
+ spec.version = Danger::SemanticCommit::VERSION
9
+ spec.authors = ["Michael Stock"]
10
+ spec.email = ["mikeastock@gmail.com"]
11
+
12
+ spec.summary = "A Danger plugin for linting semantic commits"
13
+ spec.description = "A Danger plugin for linting semantic commits"
14
+ spec.homepage = "https://github.com/mikeastock/danger-semantic-commit"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "danger"
24
+
25
+ spec.add_development_dependency "bundler"
26
+ spec.add_development_dependency "danger-rubocop"
27
+ spec.add_development_dependency "minitest"
28
+ spec.add_development_dependency "minitest-reporters"
29
+ spec.add_development_dependency "pry"
30
+ spec.add_development_dependency "rake"
31
+ spec.add_development_dependency "yard"
32
+ end
@@ -0,0 +1 @@
1
+ require "semantic_commit"
@@ -0,0 +1,4 @@
1
+ require "semantic_commit/length_validator"
2
+ require "semantic_commit/plugin"
3
+ require "semantic_commit/type_validator"
4
+ require "semantic_commit/version"
@@ -0,0 +1,25 @@
1
+ module Danger
2
+ module SemanticCommit
3
+ class LengthValidator
4
+ def initialize(length)
5
+ @length = length || default_length
6
+ end
7
+
8
+ def valid?(commit)
9
+ commit.fetch(:subject).length < length
10
+ end
11
+
12
+ def message(_commit)
13
+ "Commit subject is too long"
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :length
19
+
20
+ def default_length
21
+ 70
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,101 @@
1
+ require "danger"
2
+
3
+ module Danger
4
+ # Run each commit in the PR through a message linting.
5
+ #
6
+ # Semantic commit lint will validate each commit in the PR to ensure the
7
+ # following is true:
8
+ #
9
+ # * Commit subject begins with a type
10
+ # * Commit subject is no longer than 70 characters (`length`)
11
+ #
12
+ # By default, Semantic Commit Lint fails, but you can configure this behavior.
13
+ #
14
+ #
15
+ # @example Lint all commits using defaults
16
+ #
17
+ # semantic_commit.validate
18
+ #
19
+ # @example Warn instead of fail
20
+ #
21
+ # semantic_commit.validate warn: :all
22
+ #
23
+ # @example Disable a particular validator
24
+ #
25
+ # semantic_commit.validate disable: [:length]
26
+ #
27
+ # @example Configure semantic types
28
+ #
29
+ # semantic_commit.validate types: ["feat", "fix", "docs"]
30
+ #
31
+ # @example Configure length
32
+ #
33
+ # semantic_commit.validate length: 100
34
+ #
35
+ # @see danger/danger
36
+ # @tags commit linting
37
+ #
38
+ class DangerSemanticCommit < Plugin
39
+ # Validates the commits with whatever config the user passes.
40
+ #
41
+ # Passing in a hash which contain the following keys:
42
+ #
43
+ # * `disable` - array of checks to skip
44
+ # * `fail` - array of checks to fail on
45
+ # * `warn` - array of checks to warn on
46
+ #
47
+ # The current check types are:
48
+ #
49
+ # * `length`
50
+ #
51
+ # Note: you can pass :all instead of an array to target all checks.
52
+ #
53
+ # @param [Hash] config
54
+ #
55
+ # @return [void]
56
+ #
57
+ def validate(config = {})
58
+ self.config = config
59
+
60
+ commits.each do |commit|
61
+ enabled_validators.each do |validator|
62
+ if !validator.valid?(commit)
63
+ message = validator.message(commit)
64
+ messaging.fail([message, commit.fetch(:sha)].join("\n"))
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ private
71
+
72
+ attr_accessor :config
73
+
74
+ def commits
75
+ git.commits.map do |commit|
76
+ subject, _ = commit.message.split("\n")
77
+ {
78
+ sha: commit.sha,
79
+ subject: subject,
80
+ }
81
+ end
82
+ end
83
+
84
+ def enabled_validators
85
+ validators.reject do |validator|
86
+ config.fetch(:disabled, []).include?(validator)
87
+ end
88
+ end
89
+
90
+ def validators
91
+ @validators ||= build_validators
92
+ end
93
+
94
+ def build_validators
95
+ [
96
+ Danger::SemanticCommit::LengthValidator.new(config[:length]),
97
+ Danger::SemanticCommit::TypeValidator.new(config[:types]),
98
+ ]
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,41 @@
1
+ module Danger
2
+ module SemanticCommit
3
+ class TypeValidator
4
+ def initialize(types)
5
+ @types = types || default_types
6
+ end
7
+
8
+ def valid?(commit)
9
+ subject = commit.fetch(:subject)
10
+
11
+ type_from(subject) && types.include?(type_from(subject))
12
+ end
13
+
14
+ def message(_commit)
15
+ "Commit is missing a type"
16
+ end
17
+
18
+ private
19
+
20
+ attr_reader :types
21
+
22
+ def type_from(subject)
23
+ if matches = subject.match(/^(?<type>\w+)(\(|:)/)
24
+ matches[:type]
25
+ end
26
+ end
27
+
28
+ def default_types
29
+ [
30
+ "chore",
31
+ "docs",
32
+ "feat",
33
+ "fix",
34
+ "refactor",
35
+ "style",
36
+ "test",
37
+ ]
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,5 @@
1
+ module Danger
2
+ module SemanticCommit
3
+ VERSION = "0.2.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-semantic-commit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Stock
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-06-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: danger
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: danger-rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest-reporters
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: yard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: A Danger plugin for linting semantic commits
126
+ email:
127
+ - mikeastock@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".rspec"
134
+ - ".rubocop.yml"
135
+ - ".travis.yml"
136
+ - CODE_OF_CONDUCT.md
137
+ - Dangerfile
138
+ - Gemfile
139
+ - README.md
140
+ - Rakefile
141
+ - bin/console
142
+ - bin/rake
143
+ - bin/rspec
144
+ - bin/setup
145
+ - danger-semantic-commit.gemspec
146
+ - lib/danger_plugin.rb
147
+ - lib/semantic_commit.rb
148
+ - lib/semantic_commit/length_validator.rb
149
+ - lib/semantic_commit/plugin.rb
150
+ - lib/semantic_commit/type_validator.rb
151
+ - lib/semantic_commit/version.rb
152
+ homepage: https://github.com/mikeastock/danger-semantic-commit
153
+ licenses: []
154
+ metadata: {}
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 2.6.11
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: A Danger plugin for linting semantic commits
175
+ test_files: []