Skip to content

Commit

Permalink
Cut 1.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bbatsov committed Jan 28, 2021
1 parent bd20cc7 commit c95412e
Show file tree
Hide file tree
Showing 13 changed files with 326 additions and 26 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.8.1 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
1.9.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.9.0 (2021-01-28)

### New features

* [#9396](https://github.com/rubocop-hq/rubocop/pull/9396): Add new `Style/IfWithBooleanLiteralBranches` cop. ([@koic][])
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.8.1 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
1.9.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.8', require: false
gem 'rubocop', '~> 1.9', require: false
```

See [versioning](https://docs.rubocop.org/rubocop/1.0/versioning.html) for further details.
Expand Down
14 changes: 7 additions & 7 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1809,13 +1809,13 @@ Lint/NumberConversion:
Lint/NumberedParameterAssignment:
Description: 'Checks for uses of numbered parameter assignment.'
Enabled: pending
VersionAdded: '<<next>>'
VersionAdded: '1.9'

Lint/OrAssignmentToConstant:
Description: 'Checks unintended or-assignment to constant.'
Enabled: pending
Safe: false
VersionAdded: '<<next>>'
VersionAdded: '1.9'

Lint/OrderedMagicComments:
Description: 'Checks the proper ordering of magic comments and whether a magic comment is not placed before a shebang.'
Expand Down Expand Up @@ -2046,7 +2046,7 @@ Lint/SuppressedException:
Lint/SymbolConversion:
Description: 'Checks for unnecessary symbol conversions.'
Enabled: pending
VersionAdded: <<next>>
VersionAdded: '1.9'

Lint/Syntax:
Description: 'Checks for syntax errors.'
Expand Down Expand Up @@ -2076,7 +2076,7 @@ Lint/TrailingCommaInAttributeDeclaration:
Lint/TripleQuotes:
Description: 'Checks for useless triple quote constructs.'
Enabled: pending
VersionAdded: <<next>>
VersionAdded: '1.9'

Lint/UnderscorePrefixedVariableName:
Description: 'Do not use prefix `_` for a variable that is used.'
Expand Down Expand Up @@ -3141,7 +3141,7 @@ Style/DisableCopsWithinSourceCodeDirective:
Forbids disabling/enabling cops within source code.
Enabled: false
VersionAdded: '0.82'
VersionChanged: <<next>>
VersionChanged: '1.9'
AllowedCops: []

Style/DocumentDynamicEvalDefinition:
Expand Down Expand Up @@ -3314,7 +3314,7 @@ Style/FloatDivision:
Reference: 'https://blog.rubystyle.guide/ruby/2019/06/21/float-division.html'
Enabled: true
VersionAdded: '0.72'
VersionChanged: <<next>>
VersionChanged: '1.9'
Safe: false
EnforcedStyle: single_coerce
SupportedStyles:
Expand Down Expand Up @@ -3520,7 +3520,7 @@ Style/IfUnlessModifierOfIfUnless:
Style/IfWithBooleanLiteralBranches:
Description: 'Checks for redundant `if` with boolean literal branches.'
Enabled: pending
VersionAdded: '<<next>>'
VersionAdded: '1.9'

Style/IfWithSemicolon:
Description: 'Do not use if x; .... Use the ternary operator instead.'
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.9'
nav:
- modules/ROOT/nav.adoc
5 changes: 5 additions & 0 deletions docs/modules/ROOT/pages/cops.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ In the following section you find all available cops:
* xref:cops_lint.adoc#lintnondeterministicrequireorder[Lint/NonDeterministicRequireOrder]
* xref:cops_lint.adoc#lintnonlocalexitfromiterator[Lint/NonLocalExitFromIterator]
* xref:cops_lint.adoc#lintnumberconversion[Lint/NumberConversion]
* xref:cops_lint.adoc#lintnumberedparameterassignment[Lint/NumberedParameterAssignment]
* xref:cops_lint.adoc#lintorassignmenttoconstant[Lint/OrAssignmentToConstant]
* xref:cops_lint.adoc#lintorderedmagiccomments[Lint/OrderedMagicComments]
* xref:cops_lint.adoc#lintoutofrangeregexpref[Lint/OutOfRangeRegexpRef]
* xref:cops_lint.adoc#lintparenthesesasgroupedexpression[Lint/ParenthesesAsGroupedExpression]
Expand Down Expand Up @@ -277,11 +279,13 @@ In the following section you find all available cops:
* xref:cops_lint.adoc#lintshadowingouterlocalvariable[Lint/ShadowingOuterLocalVariable]
* xref:cops_lint.adoc#lintstructnewoverride[Lint/StructNewOverride]
* xref:cops_lint.adoc#lintsuppressedexception[Lint/SuppressedException]
* xref:cops_lint.adoc#lintsymbolconversion[Lint/SymbolConversion]
* xref:cops_lint.adoc#lintsyntax[Lint/Syntax]
* xref:cops_lint.adoc#linttoenumarguments[Lint/ToEnumArguments]
* xref:cops_lint.adoc#linttojson[Lint/ToJSON]
* xref:cops_lint.adoc#linttoplevelreturnwithargument[Lint/TopLevelReturnWithArgument]
* xref:cops_lint.adoc#linttrailingcommainattributedeclaration[Lint/TrailingCommaInAttributeDeclaration]
* xref:cops_lint.adoc#linttriplequotes[Lint/TripleQuotes]
* xref:cops_lint.adoc#lintunderscoreprefixedvariablename[Lint/UnderscorePrefixedVariableName]
* xref:cops_lint.adoc#lintunexpectedblockarity[Lint/UnexpectedBlockArity]
* xref:cops_lint.adoc#lintunifiedinteger[Lint/UnifiedInteger]
Expand Down Expand Up @@ -424,6 +428,7 @@ In the following section you find all available cops:
* xref:cops_style.adoc#styleifinsideelse[Style/IfInsideElse]
* xref:cops_style.adoc#styleifunlessmodifier[Style/IfUnlessModifier]
* xref:cops_style.adoc#styleifunlessmodifierofifunless[Style/IfUnlessModifierOfIfUnless]
* xref:cops_style.adoc#styleifwithbooleanliteralbranches[Style/IfWithBooleanLiteralBranches]
* xref:cops_style.adoc#styleifwithsemicolon[Style/IfWithSemicolon]
* xref:cops_style.adoc#styleimplicitruntimeerror[Style/ImplicitRuntimeError]
* xref:cops_style.adoc#styleinfiniteloop[Style/InfiniteLoop]
Expand Down
164 changes: 164 additions & 0 deletions docs/modules/ROOT/pages/cops_lint.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3138,12 +3138,18 @@ with `Integer()` and can be ignored with `IgnoredMethods`.
'10'.to_i
'10.2'.to_f
'10'.to_c
['1', '2', '3'].map(&:to_i)
foo.try(:to_f)
bar.send(:to_c)
# good
Integer('10', 10)
Float('10.2')
Complex('10')
['1', '2', '3'].map { |i| Integer(i, 10) }
foo.try { |i| Float(i) }
bar.send { |i| Complex(i) }
----

==== IgnoredMethods: [minutes]
Expand Down Expand Up @@ -3176,6 +3182,77 @@ Time.now.to_datetime.to_i
| Array
|===

== Lint/NumberedParameterAssignment

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

| Pending
| Yes
| No
| 1.9
| -
|===

This cop checks for uses of numbered parameter assignment.
It emulates the following warning in Ruby 2.7:

% ruby -ve '_1 = :value'
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
-e:1: warning: `_1' is reserved for numbered parameter; consider another name

Assiging to numbered parameter (from `_1` to `_9`) cause an error in Ruby 3.0.

% ruby -ve '_1 = :value'
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
-e:1: _1 is reserved for numbered parameter

NOTE: The parametered parameters are from `_1` to `_9`. This cop checks `_0`, and over `_10`
as well to prevent confusion.

=== Examples

[source,ruby]
----
# bad
_1 = :value
# good
non_numbered_parameter_name = :value
----

== Lint/OrAssignmentToConstant

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

| Pending
| No
| Yes (Unsafe)
| 1.9
| -
|===

This cop checks for unintended or-assignment to a constant.

Constants should always be assigned in the same location. And its value
should always be the same. If constants are assigned in multiple
locations, the result may vary depending on the order of `require`.

Also, if you already have such an implementation, auto-correction may
change the result.

=== Examples

[source,ruby]
----
# bad
CONST ||= 1
# good
CONST = 1
----

== Lint/OrderedMagicComments

|===
Expand Down Expand Up @@ -4638,6 +4715,40 @@ end

* https://rubystyle.guide#dont-hide-exceptions

== Lint/SymbolConversion

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

| Pending
| Yes
| Yes
| 1.9
| -
|===

This cop checks for uses of literal strings converted to
a symbol where a literal symbol could be used instead.

=== Examples

[source,ruby]
----
# bad
'string'.to_sym
:symbol.to_sym
'underscored_string'.to_sym
:'underscored_symbol'
'hyphenated-string'.to_sym
# good
:string
:symbol
:underscored_string
:underscored_symbol
:'hyphenated-string'
----

== Lint/Syntax

|===
Expand Down Expand Up @@ -4788,6 +4899,59 @@ class Foo
end
----

== Lint/TripleQuotes

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

| Pending
| Yes
| Yes
| 1.9
| -
|===

This cop checks for "triple quotes" (strings delimted by any odd number
of quotes greater than 1).

Ruby allows multiple strings to be implicitly concatenated by just
being adjacent in a statement (ie. `"foo""bar" == "foobar"`). This sometimes
gives the impression that there is something special about triple quotes, but
in fact it is just extra unnecessary quotes and produces the same string. Each
pair of quotes produces an additional concatenated empty string, so the result
is still only the "actual" string within the delimiters.

NOTE: Although this cop is called triple quotes, the same behavior is present
for strings delimited by 5, 7, etc. quotation marks.

=== Examples

[source,ruby]
----
# bad
"""
A string
"""
# bad
'''
A string
'''
# good
"
A string
"
# good
<<STRING
A string
STRING
# good (but not the same spacing as the bad case)
'A string'
----

== Lint/UnderscorePrefixedVariableName

|===
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/cops_naming.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ def some_method_1; end
:some_sym_1
----

==== AllowedIdentifier: [capture3]
==== AllowedIdentifiers: [capture3]

[source,ruby]
----
Expand Down
Loading

0 comments on commit c95412e

Please sign in to comment.