Title: false positive for Lint/UselessAssignment with until loop · Issue #14402 · rubocop/rubocop · GitHub
Open Graph Title: false positive for Lint/UselessAssignment with until loop · Issue #14402 · rubocop/rubocop
X Title: false positive for Lint/UselessAssignment with until loop · Issue #14402 · rubocop/rubocop
Description: I have some text parsing code that passed all lints with rubocop 1.77.0 but has a Lint/UselessAssignment offense as of 1.79.0 I managed to simplify the code to this example: # frozen_string_literal: true list = '3234(234)23'.chars in_par...
Open Graph Description: I have some text parsing code that passed all lints with rubocop 1.77.0 but has a Lint/UselessAssignment offense as of 1.79.0 I managed to simplify the code to this example: # frozen_string_literal...
X Description: I have some text parsing code that passed all lints with rubocop 1.77.0 but has a Lint/UselessAssignment offense as of 1.79.0 I managed to simplify the code to this example: # frozen_string_literal...
Opengraph URL: https://github.com/rubocop/rubocop/issues/14402
X: @github
Domain: redirect.github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"false positive for Lint/UselessAssignment with until loop","articleBody":"I have some text parsing code that passed all lints with rubocop 1.77.0 but has a Lint/UselessAssignment offense as of 1.79.0\n\nI managed to simplify the code to this example:\n\n```ruby\n# frozen_string_literal: true\n\nlist = '3234(234)23'.chars\nin_parens = false\nuntil list.empty?\n c = list.shift\n if in_parens\n if c == ')'\n in_parens = false\n else\n $stdout.puts c\n end\n elsif c == '('\n in_parens = true\n end\nend\n```\n\n--------\n\n## Expected behavior\n\nNo offenses\n\n## Actual behavior\n```\n$ rubocop --debug test.rb\nFor /app: configuration from /app/.rubocop.yml\nDefault configuration from /home/docker-user/bundle/ruby/3.3.0/gems/rubocop-1.79.0/config/default.yml\nPlugin configuration from /home/docker-user/bundle/ruby/3.3.0/gems/rubocop-rails-2.32.0/config/default.yml\nUse parallel by default.\nSkipping parallel inspection: only a single file needs inspection\nInspecting 1 file\nScanning /app/test.rb\nW\n\nOffenses:\n\ntest.rb:9:7: W: [Correctable] Lint/UselessAssignment: Useless assignment to variable - in_parens.\n in_parens = false\n ^^^^^^^^^\n\n1 file inspected, 1 offense detected, 1 offense autocorrectable\nFinished in 0.26479940899298526 seconds\n```\n\n## Steps to reproduce the problem\n\nSee sample code above\n\n## RuboCop version\n\n```\n1.79.0 (using Parser 3.3.9.0, rubocop-ast 1.46.0, analyzing as Ruby 2.7, running on ruby 3.3.7) [x86_64-linux]\n - rubocop-rails 2.32.0\n```\n","author":{"url":"https://github.com/seandilda","@type":"Person","name":"seandilda"},"datePublished":"2025-07-29T13:06:42.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/14402/rubocop/issues/14402"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2426585e-0875-dac1-b804-5a195dc2d509 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DAD4:308D8D:EFCE8A:14043DA:6994F912 |
| html-safe-nonce | cf6d85e6cd7e14afdb59a2e2d6efef71dce141b9497b1767f30e19c716ad68d0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQUQ0OjMwOEQ4RDpFRkNFOEE6MTQwNDNEQTo2OTk0RjkxMiIsInZpc2l0b3JfaWQiOiI4MjU4MzQxOTE3MzI0MDY1NDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 504bea9496312cf7802c4d13baa69230df7d5282bffda46f01d41637401405a1 |
| hovercard-subject-tag | issue:3273586356 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/rubocop/rubocop/14402/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fe7af9d71e66a8ea809838287499b5769f11b802f0b73fff9c5becaf846e740c/rubocop/rubocop/issues/14402 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fe7af9d71e66a8ea809838287499b5769f11b802f0b73fff9c5becaf846e740c/rubocop/rubocop/issues/14402 |
| og:image:alt | I have some text parsing code that passed all lints with rubocop 1.77.0 but has a Lint/UselessAssignment offense as of 1.79.0 I managed to simplify the code to this example: # frozen_string_literal... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | seandilda |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4bd759bc5f83244e2a0de29b937365905c0fefd238b6f077c24a49830375b4df |
| turbo-cache-control | no-preview |
| go-import | github.com/rubocop/rubocop git https://github.com/rubocop/rubocop.git |
| octolytics-dimension-user_id | 10871348 |
| octolytics-dimension-user_login | rubocop |
| octolytics-dimension-repository_id | 4095287 |
| octolytics-dimension-repository_nwo | rubocop/rubocop |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 4095287 |
| octolytics-dimension-repository_network_root_nwo | rubocop/rubocop |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 48c364f96c0b8ac95ea493e8f02d59e2a5af92a3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width