Skip to content
CAI
Software that uses CAICheck a score

daddyz/phonelib

57.3

Adequate · 6 November 2026

2.5k

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

Added Ruby development and testing shell scripts

New executable scripts have been added to the bin directory to facilitate local development and testing. The bin/console script initializes a Ruby environment with the Phonelib and Pry gems, providing an interactive console for experimentation. The bin/rspec script serves as a Bundler-generated binstub to run the RSpec test suite, ensuring consistent execution context for tests.

bin · high confidence

New phone number validation capability with structured error reporting

The lib/validators directory now includes a new PhoneValidator class that validates phone numbers using the Phonelib library. This validator supports multiple configuration options including enforcing specific phone types (mobile, fixed), restricting valid countries, controlling whether extensions are allowed, requiring explicit international prefixes, and enforcing E.164 format. A key behavioral addition is the support for detailed/structured error reporting via the 'detailed\_errors' option, which provides granular validation failure reasons rather than a single generic error message.

lib/validators · high confidence

Phonelib gem initial release with structured validation and extended data

Phonelib is introduced as a new gem for parsing, validating, and formatting international phone numbers. It provides structured validation diagnostics via a new \validation\ method and \Errors\ collection, replacing simple boolean checks with detailed error reasons (e.g., \:too\_short\, \:invalid\_country\_code\). The library includes an importer to generate phone data from the official libphonenumber repository, supporting extended data for geocoding, timezones, and carriers. Key features include support for vanity number conversion, extension parsing, and configurable parsing behaviors like strict checking and special type parsing.

lib/phonelib · high confidence

Removals

Removed phone\_data.yml

The static phone data file (phone\_data.yml) has been deleted from the repository. This removes the embedded YAML-based phone number metadata and formatting rules from the data directory, likely as part of a migration to a different data source or format.

data · high confidence

Behavioural changes

Drops support for Ruby versions older than 2.0 and migrates test suite to RSpec

The library now requires Ruby 2.0 or later, as indicated by the new .ruby-version file and changelog entry for version 0.6.55. Additionally, the project has migrated its test infrastructure from Rake/Ruby's built-in test unit to RSpec, evidenced by the new .rspec configuration, the switch from Rake::TestTask to RSpec::Core::RakeTask in the Rakefile, and the relocation of test fixtures from the test/ directory to spec/. Documentation generation has also been updated to use YARD instead of RDoc.

(repo-wide) · high confidence

Refactored library structure and added structured validation support

The library has been reorganized into modular components (core, analyzer, formatter, validation) to improve maintainability and support eager loading in Rails applications. A new structured validation system has been introduced, providing detailed error diagnostics via ValidationError and ValidationResult classes, allowing users to access specific validation failure reasons rather than simple boolean results. Additionally, the library now automatically loads I18n locale files if the I18n gem is present and conditionally loads the Rails Railtie only when Rails is detected, ensuring better compatibility and reduced overhead in non-Rails environments.

lib · high confidence

Simplified phone data import task

The \phonelib:import\_data\ rake task has been refactored to delegate the import logic to the \Phonelib::DataImporter\ class, replacing the previous inline implementation that manually parsed XML and wrote YAML. This change removes direct dependencies on \net/http\, \yaml\, and \nokogiri\ within the task file, streamlining the data import process and improving code maintainability.

lib/tasks · high confidence

Structured phone validation errors

Phonelib now returns structured, immutable validation diagnostics instead of simple boolean or string results. The new ValidationError class provides specific error codes (such as invalid\_country\_code, too\_short, or type\_not\_allowed) with associated details, allowing users to programmatically identify exactly why a phone number failed validation. These errors support internationalization via i18n keys and are wrapped in a ValidationResult object that exposes validity status and individual error instances, enabling more precise error handling in applications.

phonelib · high confidence

Test coverage

Added test assets and migrated test suite to RSpec; Added test coverage for Phone model validations; Added test suite and benchmarking infrastructure; Added test suite for Phone resource views and helpers; Added test suite for phone validation in the dummy Rails application; Removed legacy test infrastructure files.

Dependencies

Added CI gemfiles for Rails 3.1–7.0 and Ruby 1.9–2.0

The project now includes dedicated gemfiles for continuous integration testing across a wide range of supported environments. New files have been added for Rails versions 3.1.x through 7.0.x, as well as Ruby 1.9.x and 2.0.x. These gemfiles pin specific versions of dependencies such as rspec-rails, sqlite3, and nokogiri to ensure compatibility and stable test execution across these different framework and language versions.

gemfiles · high confidence

Phonelib gem initialization and dependency setup

The Phonelib gem is initialized with its core specification, including author details, MIT license, and a summary describing it as a phone number validation gem based on Google's libphonenumber. The project sets up its development and runtime dependencies, pinning \json\ to version 2.3.1 and \rack-cache\ to 1.2, while conditionally selecting \nokogiri\ versions based on the Ruby version (e.g., \~\> 1.15 for Ruby \> 2.7). It also includes development tools like \pry\, \rspec\ (pinned to 2.14.1 in the main Gemfile), \simplecov\, and benchmarking libraries (\benchmark-ips\, \benchmark-memory\).

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

Lenses

  • Code Health 75 → 75 (+0.1)
  • Architecture 94 → 94 (+0.0)
  • Maturity 65 → 65 (+0.0)
  • Readiness 72 → 72 (+0.0)
  • Security 59 → 41 (-18.7)
  • Performance 90 → 90 (+0.0)

Resolved (6)

  • Ambiguous naming for data accessors. phone_data, data_by_country_codes, and phone_ext_data all appear to expose internal data structures. The naming convention is inconsistent (phone_data vs data_by_... vs phone_ext_...). It is unclear if these are meant for public consumption or internal use. If public, they should follow a consistent naming pattern (e.g., get_phone_data, get_country_data).
  • Documentation: no architecture or design documentation
  • Duplicate validation logic across Core and Phone types. Core provides class-level validation methods that accept a phone string, while Phone provides instance-level methods. While technically distinct (class vs instance), the naming valid?/invalid? is identical, which can confuse users about whether they are calling a static utility or an instance method. More critically, Phonelib.Core.valid_for_country? and Phonelib.Phone.valid_for_country? create a parallel API surface where the user must choose between the 'Core' entry point and the 'Phone' object entry point for the same logical operation.
  • PhoneAnalyzer.detect_and_parse (cognitive 17) (lib/phonelib/phone_analyzer.rb)
  • Repeated repair: lib/validators/phone_validator.rb (lib/validators/phone_validator.rb)
  • Semantic overlap between Core.parse and PhoneAnalyzer.analyze. Both accept a phone string and an optional country and likely return similar structured data or a Phone object. The distinction between 'parsing' (converting string to object) and 'analyzing' (determining properties) is blurred here. If Core.parse returns a Phone object, PhoneAnalyzer.analyze seems redundant unless it returns a different, more detailed structure. If it returns the same structure, it is a duplicate operation with a confusingly different name.

New (1)

  • Critical vulnerability: [GHSA redacted] (Gemfile.lock)

Changes since last survey

  • 9 commits — 6 feature/other, 3 fixes

By area

  • (repo) — 4 commits
  • lib/phonelib — 3 commits
  • (root) — 1 commit
  • data/extended_data.dat — 1 commit

Notable commits

  • fix: Merge pull request #370 from dajiaohuang/fix/origin-idd-context-20261015
  • fix: Merge pull request #371 from dajiaohuang/fix/detailed-input-constraints-20261015
  • fix: Merge pull request #372 from dajiaohuang/fix/preserve-i18n-translations-20261016
  • change: Merge pull request #374 from czj/perf/regexp-and-allocations
  • change: Reduce allocations and regexp work when parsing numbers
  • change: bumped version
  • change: fixing issue #373
  • change: performance improvement for issue #375
  • change: updated data

Architecture

  • Unchanged — 0 containers · 1 contexts · 0 edges

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

Survey your own repository

daddyz/phonelib 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 c73d1c1f0658ab807d983d02544caa6eae49b7d6 — 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.