Skip to content
CAI
Software that uses CAICheck a score

heartcombo/has_scope

63.4

Adequate · 19 September 2026

215

lines of production code

Ruby

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This system is a Ruby gem that provides a \has\_scope\ helper for Rails applications, enabling the declaration and application of query scopes based on request parameters. It supports modern Ruby and Rails versions, offering features like type validation, flexible parameter passing, and deprecation warnings to ensure safe and maintainable controller logic.

Behavioural changes

Dropped support for older Ruby and Rails versions

The library now requires Ruby 2.7 or higher and Rails 7 or higher. Support for Ruby versions below 2.7 and Rails versions below 7 has been removed, aligning the gem with current supported versions of the Ruby and Rails ecosystems.

(repo-wide) · high confidence

Introduces Rails deprecation warnings via Railtie

The library now registers a dedicated deprecator with the Rails application through a new Railtie. This ensures that any deprecated features used within has\_scope will trigger standard Rails deprecation warnings, helping users identify and update legacy usage patterns.

_lib/has\scope · high confidence

Refactored scope configuration and added type validation options

The library now uses \class\_attribute\ instead of \class\_inheritable\_accessor\ for scope configuration, ensuring correct inheritance behavior in modern Ruby/Rails versions. A new \:type\ option allows explicit validation of parameter types (array, hash, boolean, default), replacing the previous \:boolean\ flag and preventing accidental hash/array injection. New \:using\ and \:in\ options enable passing multiple parameters to a scope from a single hash, while \:allow\_blank\ controls whether blank values trigger the scope. The \apply\_scopes\ method now accepts an optional hash argument for flexibility, and default values can be procs that optionally receive the controller instance.

lib · high confidence

Test coverage

Expanded test coverage for new scope options and modernized test suite

The test suite has been significantly expanded to cover new \has\_scope\ capabilities, including the \:using\, \:in\, and \:allow\_blank\ options, as well as custom type parsing (e.g., \:date\). Tests now verify that boolean scopes with \allow\_blank\ correctly handle true, false, and missing parameter states, and that scopes using \:in\ respect default values and blank checks. The test infrastructure has also been modernized to use \minitest\ and \mocha\ with updated syntax, and a deprecation silencer was added to the test helper to suppress warnings for deprecated string-based \if\/\unless\ options while still testing their behavior.

test · high confidence

Dependencies

Expanded Rails version compatibility for testing

The gemfiles directory now includes dedicated configuration files for testing against Rails 7.0, 7.1, 7.2, and 8.0, as well as the Rails main branch. This allows the library to be validated against a broader range of Rails versions, ensuring compatibility with both recent stable releases and the latest development version.

gemfiles · high confidence

Update Rails dependencies to 8.1 and raise minimum Ruby version

The gem now requires Ruby 2.7 or higher and explicitly depends on Action Pack and Active Support 8.1.0 in the development environment, while maintaining runtime compatibility with Rails 7.0 and above. This update aligns the project with the latest Rails 8.1 release cycle for testing and development purposes.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 63.

Lenses

  • Code Health 99
  • Architecture 69
  • Maturity 49
  • Readiness 77
  • Security 88

Changes since last survey

  • 248 commits — 233 feature/other, 15 fixes

By area

  • (root) — 161 commits
  • (repo) — 34 commits
  • lib/has_scope.rb — 25 commits
  • test/has_scope_test.rb — 10 commits
  • .github/workflows — 6 commits
  • test/test_helper.rb — 6 commits
  • .github/code-scanning.yml — 1 commit
  • gemfiles/Gemfile-rails-7-0 — 1 commit
  • gemfiles/Gemfile-rails-main — 1 commit
  • gemfiles/Gemfile-rails.3.2.x — 1 commit
  • gemfiles/rails_4.1.gemfile — 1 commit
  • lib/has_scope — 1 commit

Notable commits

  • fix: Fix Gemfile, Rakefile and gemspec.
  • fix: Fix README
  • fix: Fix badges in readme [ci skip]
  • fix: Fix has_scope behavior using class_attribute (fix suggested by @josevalim)
  • fix: Fix the Gemfile
  • fix: Fix the gemfile name
  • fix: Fixes a little mistake in the README
  • fix: Merge branch 'master' into ca-using-in-fixes
  • fix: Merge pull request #118 from heartcombo/ca-using-in-fixes
  • fix: Revert change of email address in gemspec
  • fix: Update changelog with in default/allow_blank fixes [ci skip]
  • fix: Upgrade mocha to latest, fix method sequence usage and deprecations
  • fix: Use the latest rubygems to fix build issue with old version and psych 4
  • fix: Who put tabs on my textmate? (aka fix identation)
  • fix: fix, add explicit requires to ensure constants are available.
  • change: :scissors:
  • change: Add Gemfile, cleanup test helper. Tests green on Rails 3
  • change: Add Gemfile.lock
  • change: Add HasScope to ActionController::Base instead of ApplicationController.
  • change: Add Ruby 1.8.7 to build matrix.
  • …and 228 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

heartcombo/has_scope was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit ad5141db29f992be3ef833aeafdfeaf9c704b397 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.