Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore docs for Lint/UselessElseWithoutRescue #10724

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/cops.adoc
Expand Up @@ -313,6 +313,7 @@ In the following section you find all available cops:
* xref:cops_lint.adoc#linturiregexp[Lint/UriRegexp]
* xref:cops_lint.adoc#lintuselessaccessmodifier[Lint/UselessAccessModifier]
* xref:cops_lint.adoc#lintuselessassignment[Lint/UselessAssignment]
* xref:cops_lint.adoc#lintuselesselsewithoutrescue[Lint/UselessElseWithoutRescue]
* xref:cops_lint.adoc#lintuselessmethoddefinition[Lint/UselessMethodDefinition]
* xref:cops_lint.adoc#lintuselessruby2keywords[Lint/UselessRuby2Keywords]
* xref:cops_lint.adoc#lintuselesssettercall[Lint/UselessSetterCall]
Expand Down
42 changes: 42 additions & 0 deletions docs/modules/ROOT/pages/cops_lint.adoc
Expand Up @@ -6446,6 +6446,48 @@ end

* https://rubystyle.guide#underscore-unused-vars

== Lint/UselessElseWithoutRescue

|===
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed

| Enabled
| Yes
| No
| 0.17
| <<next>>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR restoring this cop was one day late for 1.30.1.

|===

Checks for useless `else` in `begin..end` without `rescue`.

NOTE: This syntax is no longer valid on Ruby 2.6 or higher.

=== Examples

[source,ruby]
----
# bad

begin
do_something
else
do_something_else # This will never be run.
end
----

[source,ruby]
----
# good

begin
do_something
rescue
handle_errors
else
do_something_else
end
----

== Lint/UselessMethodDefinition

|===
Expand Down