Skip to content

Fix mismatched indentation in Ransack::Nodes::Node - #1804

Merged
scarroll32 merged 1 commit into
activerecord-hackery:mainfrom
viktorianer:fix-node-mismatched-indentation
Nov 16, 2026
Merged

scarroll32 merged 1 commit into
activerecord-hackery:mainfrom
viktorianer:fix-node-mismatched-indentation

Conversation

@viktorianer

Copy link
Copy Markdown
Contributor

Consider supporting us via Open Collective


What this changes

Loading Ransack 6.1.0 (and main) with warnings enabled prints:

lib/ransack/nodes/node.rb:55: warning: mismatched indentations at 'end' with 'def' at 50

The private indifferent_params and scalar_param methods added in #1763 lost their indentation: their bodies, their closing ends and the comment above scalar_param sit at column zero inside Ransack::Nodes::Node. This indents them to the class body. The change is whitespace only: git diff -w is empty.

Verified on Ruby 4.0.7:

  • bundle exec ruby -w -Ilib -e 'require "ransack"' prints the warning above before the change and nothing after it.
  • ruby -wc lib/ransack/nodes/node.rb warns before and prints only Syntax OK after.
  • bundle exec rake spec (SQLite): 1169 examples, 0 failures.
  • bundle exec rubocop: no offenses.

Checklist

  • Specs cover the change, and fail without it (whitespace only, no behavior change)
  • bundle exec rake spec passes
  • Docs under docs/ are updated for any user-visible change (none needed)
  • Anything that breaks backward compatibility is called out above (nothing does)

See the Contributing Guide.

🤖 Generated with Claude Code

The private indifferent_params and scalar_param methods sat at column zero, so Ruby warned on load under -w:

  lib/ransack/nodes/node.rb:55: warning: mismatched indentations at 'end' with 'def' at 50

Indent them to the class body. Whitespace only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@viktorianer
viktorianer marked this pull request as ready for review November 16, 2026 11:27
@scarroll32

Copy link
Copy Markdown
Member

LGTM, thank you @viktorianer viktorianer

@scarroll32
scarroll32 merged commit 61bd6ef into activerecord-hackery:main Nov 16, 2026
10 checks passed
scarroll32 added a commit that referenced this pull request Nov 16, 2026
…1805)

* Accept strong parameters in the grouping, condition and sort builders

`Search#initialize` unwraps `ActionController::Parameters`, but the nodes
built afterwards went through `Node#indifferent_params`, which only took
objects responding to `with_indifferent_access`. `build_grouping` and
`build_sort` given strong parameters raised `InvalidSearchError`. They are
now unwrapped there too. Whether the search counts as permitted is still
decided only by the params it was created from.

The callers now pass the article, as `scalar_param`'s do, so the message
reads "supplied for an attribute" rather than "a attribute". Also drops the
blank line left before the end of the class.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* Enable Layout/DefEndAlignment

RuboCop runs with every cop disabled by default and none of the enabled
ones checked that `end` lines up with its `def`, which is how the
misindented methods in Ransack::Nodes::Node got through.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* Remove the ransack/invalid_search_error shim

The error classes live in ransack/errors, which `require 'ransack'` loads.
Code that requires `ransack/invalid_search_error` directly needs to require
`ransack` or `ransack/errors` instead.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
@scarroll32 scarroll32 mentioned this pull request Nov 20, 2026
2 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants