Unbounded query in a controller index action
Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 8 points from that category, once per scan, no matter how many places it turns up.
What it detects
A controller index action loads Model.all with no limit, page/per, paginate, or find_each anywhere in the method body. Once the table grows past a few thousand rows, this loads the entire table into memory on every request. Heuristic: it cannot see how large the table actually is.
Why it matters
An index action that loads Model.all with no limit returns every row in the table on every request. On a small table this is invisible; once the table reaches production scale it means slow responses, high memory use per request, and a table that keeps growing can eventually turn a routine page load into a timeout or an out-of-memory worker restart.
How to fix it
Add pagination (Kaminari or Pagy's .page(params[:page]).per(n), or will_paginate) to the query, or a fixed reasonable limit if a simple cap is enough for this endpoint. If the action is really meant to process the whole table for a background or export use case rather than render a page, use find_each to stream it in batches instead of loading it all at once.
The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing
Does your repo trip this check?
Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.
Scan your repo