Skip to content

Commit 27231a6

Browse files
committed
Cut 1.5.0
1 parent ee17be5 commit 27231a6

14 files changed

+238
-26
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ output by `rubocop -V`, include them as well. Here's an example:
3838

3939
```
4040
$ [bundle exec] rubocop -V
41-
1.4.2 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
41+
1.5.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
4242
- rubocop-performance 1.9.1
4343
- rubocop-rspec 2.0.0
4444
```

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## master (unreleased)
44

5+
## 1.5.0 (2020-12-01)
6+
57
### New features
68

79
* [#9112](https://github.com/rubocop-hq/rubocop/pull/9112): Add new cop `Lint/UnexpectedBlockArity`. ([@dvandersluis][])

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ do so.
1717

1818
```
1919
$ rubocop -V
20-
1.4.2 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
20+
1.5.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
2121
- rubocop-performance 1.9.1
2222
- rubocop-rspec 2.0.0
2323
```

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
5151
in your `Gemfile`:
5252

5353
```rb
54-
gem 'rubocop', '~> 1.4', require: false
54+
gem 'rubocop', '~> 1.5', require: false
5555
```
5656

5757
See [versioning](https://docs.rubocop.org/rubocop/1.0/versioning.html) for further details.

config/default.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -2012,7 +2012,7 @@ Lint/UnexpectedBlockArity:
20122012
Description: 'Looks for blocks that have fewer arguments that the calling method expects.'
20132013
Enabled: pending
20142014
Safe: false
2015-
VersionAdded: <<next>>
2015+
VersionAdded: '1.5'
20162016
Methods:
20172017
chunk_while: 2
20182018
each_with_index: 2
@@ -2034,7 +2034,7 @@ Lint/UnmodifiedReduceAccumulator:
20342034
Description: Checks for `reduce` or `inject` blocks that do not update the accumulator each iteration.
20352035
Enabled: pending
20362036
VersionAdded: '1.1'
2037-
VersionChanged: <<next>>
2037+
VersionChanged: '1.5'
20382038

20392039
Lint/UnreachableCode:
20402040
Description: 'Unreachable code.'
@@ -2138,7 +2138,7 @@ Metrics/AbcSize:
21382138
- https://en.wikipedia.org/wiki/ABC_Software_Metric
21392139
Enabled: true
21402140
VersionAdded: '0.27'
2141-
VersionChanged: '<<next>>'
2141+
VersionChanged: '1.5'
21422142
# The ABC size is a calculated magnitude, so this number can be an Integer or
21432143
# a Float.
21442144
IgnoredMethods: []
@@ -2149,7 +2149,7 @@ Metrics/BlockLength:
21492149
Description: 'Avoid long blocks with many lines.'
21502150
Enabled: true
21512151
VersionAdded: '0.44'
2152-
VersionChanged: <<next>>
2152+
VersionChanged: '1.5'
21532153
CountComments: false # count full line comments?
21542154
Max: 25
21552155
CountAsOne: []
@@ -2195,7 +2195,7 @@ Metrics/MethodLength:
21952195
StyleGuide: '#short-methods'
21962196
Enabled: true
21972197
VersionAdded: '0.25'
2198-
VersionChanged: <<next>>
2198+
VersionChanged: '1.5'
21992199
CountComments: false # count full line comments?
22002200
Max: 10
22012201
CountAsOne: []
@@ -2216,7 +2216,7 @@ Metrics/ParameterLists:
22162216
StyleGuide: '#too-many-params'
22172217
Enabled: true
22182218
VersionAdded: '0.25'
2219-
VersionChanged: '<<next>>'
2219+
VersionChanged: '1.5'
22202220
Max: 5
22212221
CountKeywordArgs: true
22222222
MaxOptionalParameters: 3
@@ -4301,7 +4301,7 @@ Style/SoleNestedConditional:
43014301
which can be merged into outer conditional node.
43024302
Enabled: true
43034303
VersionAdded: '0.89'
4304-
VersionChanged: '<<next>>'
4304+
VersionChanged: '1.5'
43054305
AllowModifier: false
43064306

43074307
Style/SpecialGlobalVars:
@@ -4434,7 +4434,7 @@ Style/SymbolProc:
44344434
Enabled: true
44354435
Safe: false
44364436
VersionAdded: '0.26'
4437-
VersionChanged: <<next>>
4437+
VersionChanged: '1.5'
44384438
# A list of method names to be ignored by the check.
44394439
# The names should be fairly unique, otherwise you'll end up ignoring lots of code.
44404440
IgnoredMethods:

docs/antora.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ name: rubocop
22
title: RuboCop
33
# We always provide version without patch here (e.g. 1.1),
44
# as patch versions should not appear in the docs.
5-
version: 'master'
5+
version: '1.5'
66
nav:
77
- modules/ROOT/nav.adoc

docs/modules/ROOT/pages/cops.adoc

+1
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ In the following section you find all available cops:
278278
* xref:cops_lint.adoc#linttoplevelreturnwithargument[Lint/TopLevelReturnWithArgument]
279279
* xref:cops_lint.adoc#linttrailingcommainattributedeclaration[Lint/TrailingCommaInAttributeDeclaration]
280280
* xref:cops_lint.adoc#lintunderscoreprefixedvariablename[Lint/UnderscorePrefixedVariableName]
281+
* xref:cops_lint.adoc#lintunexpectedblockarity[Lint/UnexpectedBlockArity]
281282
* xref:cops_lint.adoc#lintunifiedinteger[Lint/UnifiedInteger]
282283
* xref:cops_lint.adoc#lintunmodifiedreduceaccumulator[Lint/UnmodifiedReduceAccumulator]
283284
* xref:cops_lint.adoc#lintunreachablecode[Lint/UnreachableCode]

docs/modules/ROOT/pages/cops_lint.adoc

+58-3
Original file line numberDiff line numberDiff line change
@@ -4605,6 +4605,62 @@ end
46054605
| Boolean
46064606
|===
46074607

4608+
== Lint/UnexpectedBlockArity
4609+
4610+
|===
4611+
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
4612+
4613+
| Pending
4614+
| No
4615+
| No
4616+
| 1.5
4617+
| -
4618+
|===
4619+
4620+
This cop checks for a block that is known to need more positional
4621+
block arguments than are given (by default this is configured for
4622+
`Enumerable` methods needing 2 arguments). Optional arguments are allowed,
4623+
although they don't generally make sense as the default value will
4624+
be used. Blocks that have no receiver, or take splatted arguments
4625+
(ie. `*args`) are always accepted.
4626+
4627+
Keyword arguments (including `**kwargs`) do not get counted towards
4628+
this, as they are not used by the methods in question.
4629+
4630+
NOTE: This cop matches for method names only and hence cannot tell apart
4631+
methods with same name in different classes.
4632+
4633+
Method names and their expected arity can be configured like this:
4634+
4635+
Methods:
4636+
inject: 2
4637+
reduce: 2
4638+
4639+
=== Examples
4640+
4641+
[source,ruby]
4642+
----
4643+
# bad
4644+
values.reduce {}
4645+
values.min { |a| a }
4646+
values.sort { |a; b| a + b }
4647+
4648+
# good
4649+
values.reduce { |memo, obj| memo << obj }
4650+
values.min { |a, b| a <=> b }
4651+
values.sort { |*x| x[0] <=> x[1] }
4652+
----
4653+
4654+
=== Configurable attributes
4655+
4656+
|===
4657+
| Name | Default value | Configurable values
4658+
4659+
| Methods
4660+
| `{"chunk_while"=>2, "each_with_index"=>2, "each_with_object"=>2, "inject"=>2, "max"=>2, "min"=>2, "minmax"=>2, "reduce"=>2, "slice_when"=>2, "sort"=>2}`
4661+
|
4662+
|===
4663+
46084664
== Lint/UnifiedInteger
46094665

46104666
|===
@@ -4645,7 +4701,7 @@ This cop checks for using Fixnum or Bignum constant.
46454701
| Yes
46464702
| No
46474703
| 1.1
4648-
| -
4704+
| 1.5
46494705
|===
46504706

46514707
Looks for `reduce` or `inject` blocks where the value returned (implicitly or
@@ -4657,8 +4713,7 @@ block will just return a transformation of the last element value, and
46574713
could be rewritten as such without a loop.
46584714

46594715
Also catches instances where an index of the accumulator is returned, as
4660-
this may change the type of object being retained. As well, detects when
4661-
fewer than 2 block arguments are specified.
4716+
this may change the type of object being retained.
46624717

46634718
NOTE: For the purpose of reducing false positives, this cop only flags
46644719
returns in `reduce` blocks where the element is the only variable in

0 commit comments

Comments
 (0)