Skip to content

Commit

Permalink
Cut 1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
bbatsov committed Mar 1, 2021
1 parent e3287dc commit 3741eeb
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ output by `rubocop -V`, include them as well. Here's an example:

```
$ [bundle exec] rubocop -V
1.10.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
1.11.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
- rubocop-performance 1.9.1
- rubocop-rspec 2.0.0
```
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## master (unreleased)

## 1.11.0 (2021-03-01)

### New features

* [#5388](https://github.com/rubocop/rubocop/issues/5388): Add new `Style/UnlessLogicalOperators` cop. ([@caalberts][])
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ do so.

```
$ rubocop -V
1.10.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
1.11.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
- rubocop-performance 1.9.1
- rubocop-rspec 2.0.0
```
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
in your `Gemfile`:

```rb
gem 'rubocop', '~> 1.10', require: false
gem 'rubocop', '~> 1.11', require: false
```

See [versioning](https://docs.rubocop.org/rubocop/1.0/versioning.html) for further details.
Expand Down
4 changes: 2 additions & 2 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3446,7 +3446,7 @@ Style/HashConversion:
Description: 'Avoid Hash[] in favor of ary.to_h or literal hashes.'
Enabled: pending
VersionAdded: '1.10'
VersionChanged: <<next>>
VersionChanged: '1.11'
AllowSplatArgument: true

Style/HashEachMethods:
Expand Down Expand Up @@ -4745,7 +4745,7 @@ Style/UnlessLogicalOperators:
Description: >-
Checks for use of logical operators in an unless condition.
Enabled: false
VersionAdded: '<<next>>'
VersionAdded: '1.11'
EnforcedStyle: forbid_mixed_logical_operators
SupportedStyles:
- forbid_mixed_logical_operators
Expand Down
2 changes: 1 addition & 1 deletion docs/antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ name: rubocop
title: RuboCop
# We always provide version without patch here (e.g. 1.1),
# as patch versions should not appear in the docs.
version: 'master'
version: '1.11'
nav:
- modules/ROOT/nav.adoc
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/cops.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ In the following section you find all available cops:
* xref:cops_style.adoc#styletrailingunderscorevariable[Style/TrailingUnderscoreVariable]
* xref:cops_style.adoc#styletrivialaccessors[Style/TrivialAccessors]
* xref:cops_style.adoc#styleunlesselse[Style/UnlessElse]
* xref:cops_style.adoc#styleunlesslogicaloperators[Style/UnlessLogicalOperators]
* xref:cops_style.adoc#styleunpackfirst[Style/UnpackFirst]
* xref:cops_style.adoc#stylevariableinterpolation[Style/VariableInterpolation]
* xref:cops_style.adoc#stylewhenthen[Style/WhenThen]
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/cops_layout.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ end

| Categories
| `{"module_inclusion"=>["include", "prepend", "extend"]}`
|
|

| ExpectedOrder
| `module_inclusion`, `constants`, `public_class_methods`, `initializer`, `public_methods`, `protected_methods`, `private_methods`
Expand Down
134 changes: 133 additions & 1 deletion docs/modules/ROOT/pages/cops_style.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4246,12 +4246,16 @@ EnforcedStyle.
| Yes
| Yes
| 1.10
| -
| 1.11
|===

This cop checks the usage of pre-2.1 `Hash[args]` method of converting enumerables and
sequences of values to hashes.

Correction code from splat argument (`Hash[*ary]`) is not simply determined. For example,
`Hash[*ary]` can be replaced with `ary.each_slice(2).to_h` but it will be complicated.
So, `AllowSplatArgument` option is true by default to allow splat argument for simple code.

=== Examples

[source,ruby]
Expand All @@ -4269,6 +4273,32 @@ Hash[key1, value1, key2, value2]
{key1 => value1, key2 => value2}
----

==== AllowSplatArgument: true (default)

[source,ruby]
----
# good
Hash[*ary]
----

==== AllowSplatArgument: false

[source,ruby]
----
# bad
Hash[*ary]
----

=== Configurable attributes

|===
| Name | Default value | Configurable values

| AllowSplatArgument
| `true`
| Boolean
|===

== Style/HashEachMethods

|===
Expand Down Expand Up @@ -10781,6 +10811,9 @@ This cop checks symbol literal syntax.

Use symbols as procs when possible.

If you prefer a style that allows block for method with arguments,
please set `true` to `AllowMethodsWithArguments`.

=== Examples

[source,ruby]
Expand All @@ -10793,11 +10826,34 @@ something.map { _1.upcase }
something.map(&:upcase)
----

==== AllowMethodsWithArguments: false (default)

[source,ruby]
----
# bad
something.do_something(foo) { |o| o.bar }
# good
something.do_something(foo, &:bar)
----

==== AllowMethodsWithArguments: true

[source,ruby]
----
# good
something.do_something(foo) { |o| o.bar }
----

=== Configurable attributes

|===
| Name | Default value | Configurable values

| AllowMethodsWithArguments
| `false`
| Boolean

| IgnoredMethods
| `respond_to`, `define_method`
| Array
Expand Down Expand Up @@ -11618,6 +11674,82 @@ end

* https://rubystyle.guide#no-else-with-unless

== Style/UnlessLogicalOperators

|===
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged

| Disabled
| Yes
| No
| 1.11
| -
|===

This cop checks for the use of logical operators in an `unless` condition.
It discourages such code, as the condition becomes more difficult
to read and understand.

This cop supports two styles:
- `forbid_mixed_logical_operators` (default)
- `forbid_logical_operators`

`forbid_mixed_logical_operators` style forbids the use of more than one type
of logical operators. This makes the `unless` condition easier to read
because either all conditions need to be met or any condition need to be met
in order for the expression to be truthy or falsey.

`forbid_logical_operators` style forbids any use of logical operator.
This makes it even more easy to read the `unless` condition as
there is only one condition in the expression.

=== Examples

==== EnforcedStyle: forbid_mixed_logical_operators (default)

[source,ruby]
----
# bad
return unless a || b && c
return unless a && b || c
return unless a && b and c
return unless a || b or c
return unless a && b or c
return unless a || b and c
# good
return unless a && b && c
return unless a || b || c
return unless a and b and c
return unless a or b or c
return unless a?
----

==== EnforcedStyle: forbid_logical_operators

[source,ruby]
----
# bad
return unless a || b
return unless a && b
return unless a or b
return unless a and b
# good
return unless a
return unless a?
----

=== Configurable attributes

|===
| Name | Default value | Configurable values

| EnforcedStyle
| `forbid_mixed_logical_operators`
| `forbid_mixed_logical_operators`, `forbid_logical_operators`
|===

== Style/UnpackFirst

|===
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/installation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ in your `Gemfile`:

[source,rb]
----
gem 'rubocop', '~> 1.10', require: false
gem 'rubocop', '~> 1.11', require: false
----

NOTE: You can check out our progress on the road to version 1.0 https://github.com/rubocop/rubocop/milestone/4[here].
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module RuboCop
# This module holds the RuboCop version information.
module Version
STRING = '1.10.0'
STRING = '1.11.0'

MSG = '%<version>s (using Parser %<parser_version>s, '\
'rubocop-ast %<rubocop_ast_version>s, ' \
Expand Down
25 changes: 25 additions & 0 deletions relnotes/v1.11.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
### New features

* [#5388](https://github.com/rubocop/rubocop/issues/5388): Add new `Style/UnlessLogicalOperators` cop. ([@caalberts][])
* [#9525](https://github.com/rubocop/rubocop/issues/9525): Add `AllowMethodsWithArguments` option to `Style/SymbolProc`. ([@koic][])

### Bug fixes

* [#9520](https://github.com/rubocop/rubocop/issues/9520): Fix an incorrect auto-correct for `Style/MultipleComparison` when comparing a variable with multiple items in `if` and `elsif` conditions. ([@koic][])
* [#9548](https://github.com/rubocop/rubocop/pull/9548): Fix a false positive for `Style/TrailingBodyOnMethodDefinition` when endless method definition body is after newline in opening parenthesis. ([@koic][])
* [#9541](https://github.com/rubocop/rubocop/issues/9541): Fix `Style/HashConversion` when the correction needs to be wrapped in parens. ([@dvandersluis][])
* [#9533](https://github.com/rubocop/rubocop/issues/9533): Make metrics length cops aware of multi-line kwargs. ([@koic][])
* [#9523](https://github.com/rubocop/rubocop/issues/9523): Fix an error for `Style/TrailingMethodEndStatement` when endless method definition signature and body are on different lines. ([@koic][])
* [#9482](https://github.com/rubocop/rubocop/issues/9482): Return minimal known ruby version from gemspecs `required_ruby_version`. ([@HeroProtagonist][])
* [#9539](https://github.com/rubocop/rubocop/issues/9539): Fix an error for `Style/RedundantBegin` when using body of `begin` is empty. ([@koic][])
* [#9542](https://github.com/rubocop/rubocop/pull/9542): Fix `Layout/FirstArgumentIndentation` for operator methods not called as operators. ([@dvandersluis][], [@TSMMark][])

### Changes

* [#9526](https://github.com/rubocop/rubocop/issues/9526): Add `AllowSplatArgument` option to `Style/HashConversion` and the option is true by default. ([@koic][])

[@caalberts]: https://github.com/caalberts
[@koic]: https://github.com/koic
[@dvandersluis]: https://github.com/dvandersluis
[@HeroProtagonist]: https://github.com/HeroProtagonist
[@TSMMark]: https://github.com/TSMMark

0 comments on commit 3741eeb

Please sign in to comment.