Skip to content

Commit 1c543c8

Browse files
committed
Cut 1.79
1 parent 966ece8 commit 1c543c8

File tree

14 files changed

+268
-35
lines changed

14 files changed

+268
-35
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ output by `rubocop -V`, include them as well. Here's an example:
3939

4040
```
4141
$ [bundle exec] rubocop -V
42-
1.78.0 (using Parser 3.3.5.0, rubocop-ast 1.32.3, analyzing as Ruby 3.3, running on ruby 3.3.5) [x86_64-linux]
42+
1.79.0 (using Parser 3.3.5.0, rubocop-ast 1.32.3, analyzing as Ruby 3.3, running on ruby 3.3.5) [x86_64-linux]
4343
- rubocop-performance 1.22.1
4444
- rubocop-rspec 3.1.0
4545
```

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
## master (unreleased)
1313

14+
## 1.79.0 (2025-07-24)
15+
1416
### New features
1517

1618
* [#14348](https://github.com/rubocop/rubocop/pull/14348): Add new cop `Layout/EmptyLinesAfterModuleInclusion`. ([@lovro-bikic][])

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ do so.
1717

1818
```console
1919
$ rubocop -V
20-
1.78.0 (using Parser 3.3.5.0, rubocop-ast 1.32.3, analyzing as Ruby 3.3, running on ruby 3.3.5) [x86_64-linux]
20+
1.79.0 (using Parser 3.3.5.0, rubocop-ast 1.32.3, analyzing as Ruby 3.3, running on ruby 3.3.5) [x86_64-linux]
2121
- rubocop-performance 1.22.1
2222
- rubocop-rspec 3.1.0
2323
```

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
5353
in your `Gemfile`:
5454

5555
```rb
56-
gem 'rubocop', '~> 1.78', require: false
56+
gem 'rubocop', '~> 1.79', require: false
5757
```
5858

5959
See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.

config/default.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ Layout/EmptyLinesAfterModuleInclusion:
642642
Description: 'Keeps track of empty lines after module inclusion methods.'
643643
StyleGuide: '#empty-lines-after-module-inclusion'
644644
Enabled: pending
645-
VersionAdded: '<<next>>'
645+
VersionAdded: '1.79'
646646

647647
Layout/EmptyLinesAroundAccessModifier:
648648
Description: "Keep blank lines around access modifiers."
@@ -2284,7 +2284,7 @@ Lint/RedundantSafeNavigation:
22842284
Description: 'Checks for redundant safe navigation calls.'
22852285
Enabled: true
22862286
VersionAdded: '0.93'
2287-
VersionChanged: '<<next>>'
2287+
VersionChanged: '1.79'
22882288
AllowedMethods:
22892289
- instance_of?
22902290
- kind_of?

docs/antora.yml

Lines changed: 1 addition & 1 deletion
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: ~
5+
version: '1.79'
66
nav:
77
- modules/ROOT/nav.adoc

docs/modules/ROOT/pages/cops.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ In the following section you find all available cops:
121121
* xref:cops_layout.adoc#layoutemptylineaftermultilinecondition[Layout/EmptyLineAfterMultilineCondition]
122122
* xref:cops_layout.adoc#layoutemptylinebetweendefs[Layout/EmptyLineBetweenDefs]
123123
* xref:cops_layout.adoc#layoutemptylines[Layout/EmptyLines]
124+
* xref:cops_layout.adoc#layoutemptylinesaftermoduleinclusion[Layout/EmptyLinesAfterModuleInclusion]
124125
* xref:cops_layout.adoc#layoutemptylinesaroundaccessmodifier[Layout/EmptyLinesAroundAccessModifier]
125126
* xref:cops_layout.adoc#layoutemptylinesaroundarguments[Layout/EmptyLinesAroundArguments]
126127
* xref:cops_layout.adoc#layoutemptylinesaroundattributeaccessor[Layout/EmptyLinesAroundAttributeAccessor]

docs/modules/ROOT/pages/cops_layout.adoc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,6 +1816,53 @@ some_method
18161816
18171817
* https://rubystyle.guide#two-or-more-empty-lines
18181818
1819+
[#layoutemptylinesaftermoduleinclusion]
1820+
== Layout/EmptyLinesAfterModuleInclusion
1821+
1822+
|===
1823+
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed
1824+
1825+
| Pending
1826+
| Yes
1827+
| Always
1828+
| 1.79
1829+
| -
1830+
|===
1831+
1832+
Checks for an empty line after a module inclusion method (`extend`,
1833+
`include` and `prepend`), or a group of them.
1834+
1835+
[#examples-layoutemptylinesaftermoduleinclusion]
1836+
=== Examples
1837+
1838+
[source,ruby]
1839+
----
1840+
# bad
1841+
class Foo
1842+
include Bar
1843+
attr_reader :baz
1844+
end
1845+
1846+
# good
1847+
class Foo
1848+
include Bar
1849+
1850+
attr_reader :baz
1851+
end
1852+
1853+
# also good - multiple module inclusions grouped together
1854+
class Foo
1855+
extend Bar
1856+
include Baz
1857+
prepend Qux
1858+
end
1859+
----
1860+
1861+
[#references-layoutemptylinesaftermoduleinclusion]
1862+
=== References
1863+
1864+
* https://rubystyle.guide#empty-lines-after-module-inclusion
1865+
18191866
[#layoutemptylinesaroundaccessmodifier]
18201867
== Layout/EmptyLinesAroundAccessModifier
18211868
@@ -6744,6 +6791,8 @@ end
67446791
67456792
something = 123if test
67466793
6794+
return(foo + bar)
6795+
67476796
# good
67486797
something 'test' do |x|
67496798
end
@@ -6752,6 +6801,8 @@ while (something)
67526801
end
67536802
67546803
something = 123 if test
6804+
6805+
return (foo + bar)
67556806
----
67566807
67576808
[#layoutspacearoundmethodcalloperator]

docs/modules/ROOT/pages/cops_lint.adoc

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5301,7 +5301,7 @@ require 'unloaded_feature'
53015301
| No
53025302
| Always (Unsafe)
53035303
| 0.93
5304-
| -
5304+
| 1.79
53055305
|===
53065306
53075307
Checks for redundant safe navigation calls.
@@ -5321,6 +5321,15 @@ for which to suppress (allow) this cop's check.
53215321
In the example below, the safe navigation operator (`&.`) is unnecessary
53225322
because `NilClass` has methods like `respond_to?` and `is_a?`.
53235323
5324+
The `InferNonNilReceiver` option specifies whether to look into previous code
5325+
paths to infer if the receiver can't be nil. This check is unsafe because the receiver
5326+
can be redefined between the safe navigation call and previous regular method call.
5327+
It does the inference only in the current scope, e.g. within the same method definition etc.
5328+
5329+
The `AdditionalNilMethods` option specifies additional custom methods which are
5330+
defined on `NilClass`. When `InferNonNilReceiver` is set, they are used to determine
5331+
whether the receiver can be nil.
5332+
53245333
[#safety-lintredundantsafenavigation]
53255334
=== Safety
53265335
@@ -5339,6 +5348,20 @@ CamelCaseConst&.do_something
53395348
# good
53405349
CamelCaseConst.do_something
53415350
5351+
# bad
5352+
foo.to_s&.strip
5353+
foo.to_i&.zero?
5354+
foo.to_f&.zero?
5355+
foo.to_a&.size
5356+
foo.to_h&.size
5357+
5358+
# good
5359+
foo.to_s.strip
5360+
foo.to_i.zero?
5361+
foo.to_f.zero?
5362+
foo.to_a.size
5363+
foo.to_h.size
5364+
53425365
# bad
53435366
do_something if attrs&.respond_to?(:[])
53445367
@@ -5394,6 +5417,59 @@ do_something if attrs.nil_safe_method(:[])
53945417
do_something if attrs&.not_nil_safe_method(:[])
53955418
----
53965419
5420+
[#infernonnilreceiver_-false-_default_-lintredundantsafenavigation]
5421+
==== InferNonNilReceiver: false (default)
5422+
5423+
[source,ruby]
5424+
----
5425+
# good
5426+
foo.bar
5427+
foo&.baz
5428+
----
5429+
5430+
[#infernonnilreceiver_-true-lintredundantsafenavigation]
5431+
==== InferNonNilReceiver: true
5432+
5433+
[source,ruby]
5434+
----
5435+
# bad
5436+
foo.bar
5437+
foo&.baz # would raise on previous line if `foo` is nil
5438+
5439+
# good
5440+
foo.bar
5441+
foo.baz
5442+
5443+
# bad
5444+
if foo.condition?
5445+
foo&.bar
5446+
end
5447+
5448+
# good
5449+
if foo.condition?
5450+
foo.bar
5451+
end
5452+
5453+
# good (different scopes)
5454+
def method1
5455+
foo.bar
5456+
end
5457+
5458+
def method2
5459+
foo&.bar
5460+
end
5461+
----
5462+
5463+
[#additionalnilmethods_-_present__-lintredundantsafenavigation]
5464+
==== AdditionalNilMethods: [present?]
5465+
5466+
[source,ruby]
5467+
----
5468+
# good
5469+
foo.present?
5470+
foo&.bar
5471+
----
5472+
53975473
[#configurable-attributes-lintredundantsafenavigation]
53985474
=== Configurable attributes
53995475
@@ -5403,6 +5479,14 @@ do_something if attrs&.not_nil_safe_method(:[])
54035479
| AllowedMethods
54045480
| `instance_of?`, `kind_of?`, `is_a?`, `eql?`, `respond_to?`, `equal?`
54055481
| Array
5482+
5483+
| InferNonNilReceiver
5484+
| `false`
5485+
| Boolean
5486+
5487+
| AdditionalNilMethods
5488+
| `present?`, `blank?`, `try`, `try!`
5489+
| Array
54065490
|===
54075491
54085492
[#lintredundantsplatexpansion]
@@ -5974,7 +6058,7 @@ end
59746058
| -
59756059
|===
59766060
5977-
Check for arguments to `rescue` that will result in a `TypeError`
6061+
Checks for arguments to `rescue` that will result in a `TypeError`
59786062
if an exception is raised.
59796063
59806064
[#examples-lintrescuetype]

0 commit comments

Comments
 (0)