Ban redundant then keyword via RuboCop - #1791
Open
st0012 wants to merge 1 commit into
Open
Conversation
Enable Style/MultilineIfThen, Style/MultilineWhenThen and Style/MultilineInPatternThen, and remove the existing redundant `then` keywords across the codebase (autocorrected, plus two spots the cops don't reach: a multiline `when` condition list in the ri servlet and a code sample in a doc comment). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G11TTmQg9oQXAwJ79A5gsm
Collaborator
|
🚀 Preview deployment available at: https://259c1d9f.rdoc-6cd.pages.dev (commit: 88c8b73) |
Contributor
There was a problem hiding this comment.
Pull request overview
Bans redundant multiline then keywords through RuboCop and updates existing Ruby code accordingly without changing behavior.
Changes:
- Enables three multiline
thenstyle cops. - Removes existing violations across source and test files.
- Preserves required single-line
thenforms.
Reviewed changes
Copilot reviewed 50 out of 50 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
.rubocop.yml |
Enables multiline then cops. |
exe/rdoc |
Removes redundant then. |
lib/rdoc/code_object.rb |
Removes redundant then. |
lib/rdoc/code_object/any_method.rb |
Removes redundant then. |
lib/rdoc/code_object/attr.rb |
Removes redundant then. |
lib/rdoc/code_object/class_module.rb |
Removes redundant then. |
lib/rdoc/code_object/constant.rb |
Removes redundant then. |
lib/rdoc/code_object/context.rb |
Removes redundant then. |
lib/rdoc/code_object/method_attr.rb |
Removes redundant then. |
lib/rdoc/code_object/require.rb |
Removes redundant then. |
lib/rdoc/cross_reference.rb |
Removes redundant then. |
lib/rdoc/encoding.rb |
Removes redundant then. |
lib/rdoc/generator/darkfish.rb |
Removes redundant then. |
lib/rdoc/generator/markup.rb |
Removes redundant then. |
lib/rdoc/markup.rb |
Removes redundant then. |
lib/rdoc/markup/document.rb |
Removes redundant then. |
lib/rdoc/markup/formatter.rb |
Removes redundant then. |
lib/rdoc/markup/indented_paragraph.rb |
Removes redundant then. |
lib/rdoc/markup/paragraph.rb |
Removes redundant then. |
lib/rdoc/markup/parser.rb |
Removes redundant then. |
lib/rdoc/markup/pre_process.rb |
Removes redundant then. |
lib/rdoc/markup/to_ansi.rb |
Removes redundant then. |
lib/rdoc/markup/to_bs.rb |
Removes redundant then. |
lib/rdoc/markup/to_html.rb |
Removes redundant then. |
lib/rdoc/markup/to_html_crossref.rb |
Removes redundant then. |
lib/rdoc/markup/to_html_snippet.rb |
Removes redundant then. |
lib/rdoc/markup/to_markdown.rb |
Removes redundant then. |
lib/rdoc/markup/to_rdoc.rb |
Removes redundant then. |
lib/rdoc/markup/to_test.rb |
Removes redundant then. |
lib/rdoc/markup/to_tt_only.rb |
Removes redundant then. |
lib/rdoc/markup/verbatim.rb |
Removes redundant then. |
lib/rdoc/options.rb |
Removes redundant then. |
lib/rdoc/parser.rb |
Removes redundant then. |
lib/rdoc/parser/c.rb |
Removes redundant then. |
lib/rdoc/parser/changelog.rb |
Removes redundant then. |
lib/rdoc/parser/ruby.rb |
Removes redundant then. |
lib/rdoc/rd.rb |
Removes redundant then. |
lib/rdoc/rd/inline.rb |
Removes redundant then. |
lib/rdoc/rdoc.rb |
Removes redundant then. |
lib/rdoc/ri/driver.rb |
Removes redundant then. |
lib/rdoc/ri/paths.rb |
Removes redundant then. |
lib/rdoc/ri/servlet.rb |
Removes redundant then. |
lib/rdoc/rubygems_hook.rb |
Removes redundant then. |
lib/rdoc/stats.rb |
Removes redundant then. |
lib/rdoc/stats/normal.rb |
Removes redundant then. |
lib/rdoc/store.rb |
Removes redundant then. |
lib/rdoc/task.rb |
Removes redundant then. |
lib/rdoc/token_stream.rb |
Removes redundant then. |
lib/rdoc/tom_doc.rb |
Removes redundant then. |
test/rdoc/code_object/class_module_test.rb |
Updates test code to comply. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This has bothered me for quite a while. I was thinking about dropping them gradually, but with agents reading other code they constantly add
thentoo. So let's ban this.Cops enabled
.rubocop.ymlusesDisabledByDefault: true, so each cop is opted in explicitly:Style/MultilineIfThen—if cond thenwith the body on the next lineStyle/MultilineWhenThen— same forwhenStyle/MultilineInPatternThen— same forinpattern matchingThere is no single "redundant then" cop; these three are RuboCop's coverage for it.
They intentionally leave single-line forms alone, where
thenis required and not redundant: