+120
-10
lines changedFilter options
+120
-10
lines changed Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ output by `rubocop -V`, include them as well. Here's an example:
39
39
40
40
```
41
41
$ [bundle exec] rubocop -V
42
-
1.77.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.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]
43
43
- rubocop-performance 1.22.1
44
44
- rubocop-rspec 3.1.0
45
45
```
Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@
11
11
12
12
## master (unreleased)
13
13
14
+
## 1.78.0 (2025-07-08)
15
+
14
16
### New features
15
17
16
18
* [#14331](https://github.com/rubocop/rubocop/pull/14331): Enhance `Naming/MethodName` cop to detect offenses within `define_method` calls. ([@viralpraxis][])
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ do so.
17
17
18
18
```console
19
19
$ rubocop -V
20
-
1.77.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.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]
21
21
- rubocop-performance 1.22.1
22
22
- rubocop-rspec 3.1.0
23
23
```
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
53
53
in your `Gemfile`:
54
54
55
55
```rb
56
-
gem 'rubocop', '~> 1.77', require: false
56
+
gem 'rubocop', '~> 1.78', require: false
57
57
```
58
58
59
59
See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
Original file line number Diff line number Diff line change
@@ -3072,7 +3072,7 @@ Naming/PredicateMethod:
3072
3072
Description: 'Checks that predicate methods end with `?` and non-predicate methods do not.'
3073
3073
Enabled: pending
3074
3074
VersionAdded: '1.76'
3075
-
VersionChanged: '<<next>>'
3075
+
VersionChanged: '1.78'
3076
3076
# In `aggressive` mode, the cop will register an offense for predicate methods that
3077
3077
# may return a non-boolean value.
3078
3078
# In `conservative` mode, the cop will *not* register an offense for predicate methods
Original file line number Diff line number Diff line change
@@ -2,6 +2,6 @@ name: rubocop
2
2
title: RuboCop
3
3
# We always provide version without patch here (e.g. 1.1),
4
4
# as patch versions should not appear in the docs.
5
-
version: ~
5
+
version: '1.78'
6
6
nav:
7
7
- modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
@@ -1747,6 +1747,10 @@ end
1747
1747
Checks for duplicated instance (or singleton) method
1748
1748
definitions.
1749
1749
1750
+
NOTE: Aliasing a method to itself is allowed, as it indicates that
1751
+
the developer intends to suppress Ruby's method redefinition warnings.
1752
+
See https://bugs.ruby-lang.org/issues/13574.
1753
+
1750
1754
[#examples-lintduplicatemethods]
1751
1755
=== Examples
1752
1756
@@ -1783,6 +1787,18 @@ def foo
1783
1787
end
1784
1788
1785
1789
alias bar foo
1790
+
1791
+
# good
1792
+
alias foo foo
1793
+
def foo
1794
+
1
1795
+
end
1796
+
1797
+
# good
1798
+
alias_method :foo, :foo
1799
+
def foo
1800
+
1
1801
+
end
1786
1802
----
1787
1803
1788
1804
[#allcops_activesupportextensionsenabled_-false-_default_-lintduplicatemethods]
Original file line number Diff line number Diff line change
@@ -1052,6 +1052,20 @@ def fooBar; end
1052
1052
1053
1053
# good
1054
1054
def foo_bar; end
1055
+
1056
+
# bad
1057
+
define_method :fooBar do
1058
+
end
1059
+
1060
+
# good
1061
+
define_method :foo_bar do
1062
+
end
1063
+
1064
+
# bad
1065
+
Struct.new(:fooBar)
1066
+
1067
+
# good
1068
+
Struct.new(:foo_bar)
1055
1069
----
1056
1070
1057
1071
[#enforcedstyle_-camelcase-namingmethodname]
@@ -1064,6 +1078,20 @@ def foo_bar; end
1064
1078
1065
1079
# good
1066
1080
def fooBar; end
1081
+
1082
+
# bad
1083
+
define_method :foo_bar do
1084
+
end
1085
+
1086
+
# good
1087
+
define_method :fooBar do
1088
+
end
1089
+
1090
+
# bad
1091
+
Struct.new(:foo_bar)
1092
+
1093
+
# good
1094
+
Struct.new(:fooBar)
1067
1095
----
1068
1096
1069
1097
[#forbiddenidentifiers_-__def__-_super__-namingmethodname]
@@ -1206,7 +1234,7 @@ end
1206
1234
| Yes
1207
1235
| No
1208
1236
| 1.76
1209
-
| 1.76
1237
+
| 1.78
1210
1238
|===
1211
1239
1212
1240
Checks that predicate methods end with `?` and non-predicate methods do not.
@@ -1232,6 +1260,11 @@ registering an offense from a method name that does not confirm to the naming
1232
1260
guidelines. By default, `call` is allowed. The cop also has `AllowedPatterns`
1233
1261
configuration to allow method names by regular expression.
1234
1262
1263
+
Although returning a call to another predicate method is treated as a boolean value,
1264
+
certain method names can be known to not return a boolean, despite ending in a `?`
1265
+
(for example, `Numeric#nonzero?` returns `self` or `nil`). These methods can be
1266
+
configured using `NonBooleanPredicates`.
1267
+
1235
1268
The cop can furthermore be configured to allow all bang methods (method names
1236
1269
ending with `!`), with `AllowBangMethods: true` (default false).
1237
1270
@@ -1370,6 +1403,10 @@ end
1370
1403
| AllowBangMethods
1371
1404
| `false`
1372
1405
| Boolean
1406
+
1407
+
| WaywardPredicates
1408
+
| `nonzero?`
1409
+
| Array
1373
1410
|===
1374
1411
1375
1412
[#namingpredicateprefix]
Original file line number Diff line number Diff line change
@@ -74,6 +74,7 @@ Checks for the use of `Kernel#eval` and `Binding#eval`.
74
74
75
75
eval(something)
76
76
binding.eval(something)
77
+
Kernel.eval(something)
77
78
----
78
79
79
80
[#securityiomethods]
@@ -252,6 +253,7 @@ URI.parse(something).open
252
253
# good (literal strings)
253
254
open("foo.text")
254
255
URI.open("http://example.com")
256
+
URI.parse(url).open
255
257
----
256
258
257
259
[#securityyamlload]
Original file line number Diff line number Diff line change
@@ -9262,6 +9262,30 @@ class Foo
9262
9262
end
9263
9263
----
9264
9264
9265
+
[#allowedmethods_-__puts__-_print__-stylemethodcallwithargsparentheses]
9266
+
==== AllowedMethods: ["puts", "print"]
9267
+
9268
+
[source,ruby]
9269
+
----
9270
+
# good
9271
+
puts "Hello world"
9272
+
print "Hello world"
9273
+
# still enforces parentheses on other methods
9274
+
array.delete(e)
9275
+
----
9276
+
9277
+
[#allowedpatterns_-___assert__-stylemethodcallwithargsparentheses]
9278
+
==== AllowedPatterns: ["^assert"]
9279
+
9280
+
[source,ruby]
9281
+
----
9282
+
# good
9283
+
assert_equal 'test', x
9284
+
assert_match(/foo/, bar)
9285
+
# still enforces parentheses on other methods
9286
+
array.delete(e)
9287
+
----
9288
+
9265
9289
[#allowparenthesesinmultilinecall_-false-_default_-stylemethodcallwithargsparentheses]
9266
9290
==== AllowParenthesesInMultilineCall: false (default)
9267
9291
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4