Skip to content
CAI
Software that uses CAICheck a score

egonSchiele/contracts.ruby

65.9

Adequate · 6 November 2026

2.1k

lines of production code

Ruby

primary language

4

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

Features

Add RuboCop configuration and RSpec defaults

The project now includes a \.rubocop.yml\ configuration file to enforce code style, targeting Ruby 3.0 and excluding specific directories like benchmarks and specs from certain checks. Additionally, an \.rspec\ file has been added to set default test runner options, specifically enabling color output and requiring the \spec\_helper\ for all test runs.

(repo-wide) · high confidence

Added benchmark suite for performance analysis

A new set of benchmark scripts has been added to the \benchmarks\ directory to help users evaluate the performance impact of using Contracts. These scripts compare execution times and profiling data for basic arithmetic, hash-based arguments, object invariants, and real-world I/O operations (web downloads) with and without contract validation, allowing users to assess overhead in their specific use cases.

benchmarks · high confidence

Added documentation release scripts and a Ruby version-gated Rubocop runner

This change introduces two new shell scripts, \script/docs-release\ and \script/docs-staging\, which automate pushing documentation to the relishapp platform for the production and staging contract libraries respectively. Additionally, a new \script/rubocop.rb\ script is added to execute Rubocop, but it is strictly gated to run only on Ruby 2.1, ensuring the linter is invoked conditionally based on the runtime version.

script · high confidence

Documented method overloading via pattern matching contracts

Added a feature specification for method overloading using contracts, demonstrating how to define multiple methods with the same name but different argument patterns (positional and keyword arguments). The documentation includes examples for factorial calculation and string formatting, as well as a scenario illustrating the consequences of incorrect contract ordering, which results in a stack overflow error.

features/advanced · high confidence

Behavioural changes

Contracts library restructured into modular components with new attribute helpers

The contracts library has been refactored from a single monolithic file into a modular structure under the \lib/contracts\ directory, introducing dedicated modules for core functionality (\Core\), method decoration (\MethodDecorators\, \MethodHandler\), validation strategies (\Validators\), and error handling (\Errors\). This change introduces a new \Contracts::Attrs\ module that provides \attr\_reader\_with\_contract\, \attr\_writer\_with\_contract\, and \attr\_accessor\_with\_contract\ methods, allowing users to define attributes with contract validation directly. The \Builtin\ module now contains all built-in contract classes (e.g., \Num\, \Int\, \Nat\, \Or\, \And\, \Xor\), and the engine logic is centralized in \Engine\ and \CallWith\. The version is bumped to 0.17.3.

lib/contracts · high confidence

Documented builtin contract features and fixed keyword argument validation

This update adds comprehensive documentation and feature tests for several builtin contracts, including And, Any, Args, Bool, Int, KeywordArgs (with optional positional arguments), Maybe, Nat, NatPos, Neg, None, Num, Or, Pos, RespondTo, Send, and Xor. Additionally, it fixes a bug where keyword arguments contracts failed when used alongside optional positional arguments, ensuring that methods with mixed argument types are validated correctly.

_features/builtin\contracts · high confidence

Initialize Aruba Cucumber support for CLI testing

Added a new support file (features/support/env.rb) that integrates the Aruba gem for Cucumber, enabling command-line interface testing. The setup configures a default timeout of 5 seconds for standard Ruby runs and 30 seconds for JRuby environments to accommodate potential performance differences.

features/support · high confidence

Refactored contract validation and error reporting architecture

The library's core validation logic has been restructured to improve readability and maintainability. The \Contract\ class now explicitly manages argument, keyword, and return value validators, separating the parsing of complex method signatures from the validation execution. Error reporting has been enhanced with a dedicated \failure\_msg\ method that provides structured, pretty-printed details including expected vs. actual values, argument positions, and method context. Additionally, the \failure\_callback\ mechanism now supports pattern matching logic, allowing for more granular control over how contract violations are handled during execution.

lib · high confidence

Refactored contracts engine into modular components

The contracts engine implementation has been split from a single file into three distinct modules: \Engine::Base\ for core class decoration logic, \Engine::Eigenclass\ to handle class-level method decorators, and \Engine::Target\ to manage the activation and retrieval of engines for specific classes. This structural change improves code organization and clarifies the separation between instance and class method contract handling, while maintaining the same external API for enabling and applying contracts.

lib/contracts/engine · high confidence

Test coverage

Add documentation and tests for functype and contract violation scenarios; Added Ruby version-specific contract tests; Added comprehensive test suite for contract validation features; Added fixture definitions for contract testing.

Dependencies

Initial gem release with Ruby 3.0+ support and modern test dependencies

This change introduces the core gem specification and development environment for the 'contracts' library. The gemspec now requires Ruby version 3.0 or higher (but less than 5), aligning with the project's shift to modern Ruby versions. The Gemfile establishes the dependency structure, pinning test dependencies to Cucumber \>= 9.2.1 and RuboCop \>= 1.0.0 to ensure compatibility with current Ruby versions and CI standards, while including development tools like RSpec, Aruba, and Method Profiler.

(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.1)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.

Lenses

  • Code Health 74 → 74 (+0.0)
  • Architecture 100 → 100 (+0.0)
  • Maturity 50 → 51 (+0.3)
  • Readiness 76 → 76 (+0.0)
  • Security 97 → 95 (-2.1)
  • Performance 85 → 85 (+0.0)

Resolved (6)

  • Confusing callback management API. failure_callback takes arguments, override_failure_callback sets a block, and fetch_failure_callback retrieves it. This mixes invocation, configuration, and retrieval in a non-standard way. Typically, you set a callback once and invoke it, or use a standard observer pattern.
  • Duplicate intent for invoking a contract. call and [] (square bracket access) appear to perform the same operation (invoking the contract logic), which is confusing for API users who must choose between two names for the same action.
  • Inconsistent hook naming and presence. Contracts and Invariants both define included and extended, but Core defines included, extended, AND common. The presence of common in Core but not in the other modules suggests a potential inconsistency in how module inclusion hooks are exposed or if common is a duplicate intent of included/extended in a different context.
  • Inconsistent naming for formatter methods. hash_contract and array_contract are methods on Expected that likely format specific types. The naming is inconsistent with standard Ruby conventions (e.g., format_hash, format_array) and unclear if they are meant to be called directly or are internal helpers.
  • Inconsistent validation method signatures. Contract.valid? takes two arguments (arg, contract), while all Builtin contracts (Num, Pos, Int, etc.) take only one (val). This forces users to use different code paths depending on whether they are using a generic Contract object or a specific Builtin type.
  • Off-boarding risk: anonymized user #1

New (2)

  • Off-boarding risk: anonymized user #1
  • Orphaned file (lib/contracts/formatters.rb)

Changes since last survey

  • 4 commits — 3 feature/other, 1 fixes

By area

  • (repo) — 1 commit
  • .github/workflows — 1 commit
  • features/basics — 1 commit
  • features/builtin_contracts — 1 commit

Notable commits

  • fix: ! Fix cucumber issue
  • change: $ Escape not really cucumber Scenarios
  • change: Bump ruby/setup-ruby from 1.327.0 to 1.336.0
  • change: Merge pull request #318 from egonSchiele/dependabot/github_actions/ruby/setup-ruby-1.335.0

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

Survey your own repository

egonSchiele/contracts.ruby 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 b36158ae22879c401d1021d4973e2f296897c99a — 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.