Skip to content
CAI
Software that uses CAICheck a score

jhawthorn/discard

65.8

Adequate · 6 November 2026

198

lines of production code

Ruby

primary language

4

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a Ruby gem that provides soft-delete functionality for ActiveRecord models, allowing records to be discarded and restored without permanent deletion. It supports both instance and bulk operations, custom discard columns, and transactional integrity to ensure data consistency during state changes. The library exposes scopes and query methods for filtering records based on their discard status and includes comprehensive test coverage using RSpec.

Behavioural changes

Discard gem v2.0.0: ActiveRecord 7.0+ requirement and transactional discard operations

The Discard gem has been updated to version 2.0.0, which raises the minimum supported version of ActiveRecord to 7.0, dropping support for Rails 6.x and earlier. Additionally, the \discard\ and \undiscard\ methods are now wrapped in a database transaction, ensuring that if a callback raises an exception, the database write is rolled back to maintain data consistency. The project has also migrated its test suite from Minitest to RSpec and updated its CI configuration to use GitHub Actions instead of Travis CI.

(repo-wide) · high confidence

Soft-delete functionality with undiscard support and custom columns

The library now provides a complete soft-delete implementation for ActiveRecord models. Users can discard and undiscard records using instance methods (discard, discard!, undiscard, undiscard!) as well as bulk class methods (discard\_all, discard\_all!, undiscard\_all, undiscard\_all!). The system supports custom discard columns via the :discard\_column option, includes callbacks for both discard and undiscard events, and introduces specific error classes (RecordNotDiscarded, RecordNotUndiscarded) for bang-method failures. Additionally, boolean query methods (discarded?, undiscarded?, kept?) and scopes (kept, undiscarded, discarded, with\_discarded) are available for filtering records.

lib/discard · high confidence

Test coverage

Added RSpec test configuration; Added test coverage for soft-delete model behavior; Removal of Minitest-based test suite.

Dependencies

Updated ActiveRecord support and development dependencies

The gem now requires ActiveRecord versions 7.0 through 8.x (specifically \>= 7.0, \< 9.0), dropping support for older Rails versions. Development dependencies have been updated to include RSpec (\~\> 3.13), database\_cleaner (\~\> 1.5), with\_model (\~\> 2.0), and sqlite3, while bundler and rake constraints have been loosened to support newer Ruby versions.

(dependencies) · high confidence

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

How this codebase got here

Score

  • CAI 66 → 66 (-0.0)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.

Lenses

  • Code Health 76 → 76 (+0.0)
  • Architecture 69 → 69 (+0.0)
  • Maturity 56 → 56 (+0.0)
  • Readiness 80 → 80 (+0.0)
  • Security 96 → 95 (-0.9)

Resolved (2)

  • Redundant bang (!) variants for bulk operations. The distinction between discard_all and discard_all! is unclear in the context of class methods. Typically, bang methods imply raising errors on failure or destructive behavior, but for bulk operations on a class, the behavior difference is ambiguous and inconsistent with standard Ruby conventions where bang often implies 'raise on error' vs 'return false'. If the non-bang version swallows errors and the bang raises, this is a valid distinction, but it creates API surface bloat. If the distinction is minor or non-existent, it is redundant.
  • Redundant bang (!) variants for instance methods. Similar to the class methods, the presence of both discard/discard! and undiscard/undiscard! suggests a distinction in error handling or return values. However, for simple state transitions, having both variants often confuses users about when to use which. If discard! raises an error and discard returns false, this is a common pattern, but it doubles the API surface for simple operations.

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

Survey your own repository

jhawthorn/discard 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 6 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit b4780e8ee95a9bce4b94dded4c3ed93f3067f95c — the exact code this score is about.
  • Scored under rubric-2026.11.2 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.2+preprod-5c4e66d9318b.