{"id":16738871,"url":"https://github.com/domcleal/as_deprecation_tracker","last_synced_at":"2025-10-06T09:31:25.781Z","repository":{"id":59150737,"uuid":"69569273","full_name":"domcleal/as_deprecation_tracker","owner":"domcleal","description":"Track known ActiveSupport deprecation warnings","archived":false,"fork":false,"pushed_at":"2022-07-24T15:28:32.000Z","size":64,"stargazers_count":6,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-20T22:05:43.196Z","etag":null,"topics":["activesupport","deprecation-tracker","deprecations","rails","ruby-on-rails","testing"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/domcleal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-29T13:18:30.000Z","updated_at":"2022-07-24T15:19:56.000Z","dependencies_parsed_at":"2022-09-13T11:00:43.585Z","dependency_job_id":null,"html_url":"https://github.com/domcleal/as_deprecation_tracker","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domcleal%2Fas_deprecation_tracker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domcleal%2Fas_deprecation_tracker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domcleal%2Fas_deprecation_tracker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domcleal%2Fas_deprecation_tracker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/domcleal","download_url":"https://codeload.github.com/domcleal/as_deprecation_tracker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235516762,"owners_count":19002685,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activesupport","deprecation-tracker","deprecations","rails","ruby-on-rails","testing"],"created_at":"2024-10-13T00:32:52.277Z","updated_at":"2025-10-06T09:31:20.443Z","avatar_url":"https://github.com/domcleal.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# as_deprecation_tracker\n\nTracks known ActiveSupport (Rails) deprecation warnings and catches new issues\nwhen an unknown warning is seen.\n\nThis allows for easier upgrades of Rails and other AS-based apps because as\neach deprecation warning is fixed, it's removed from the whitelist and any\nattempt to reintroduce the deprecated call will fail. It's also useful when the\napp runs on multiple versions of Rails and newer deprecation warnings can't be\nfixed yet without breaking the older version.\n\nThe library maintains the whitelist in a configuration file that's usually\ninitially written by running the app test suite with an environment variable\nset. When the tests are run normally, deprecation warnings triggered that\naren't in the config file will raise an exception. The call can then be fixed\nor added to the whitelist with the provided instructions.\n\nIf you'd prefer just to fix all deprecation warnings at once then this gem is\nunnecessary! Just use:\n\n```ruby\nActiveSupport::Deprecation.behavior = :raise\n```\n\nin your test environment config.\n\n## Installation\n\n    $ gem install as_deprecation_tracker\n\nor in your Gemfile:\n\n    gem 'as_deprecation_tracker', '~\u003e 1.0', group: 'test'\n\nThis gem and its API is versioned according to semver.\n\nIt's recommended to only add the gem to the test Bundler group as raising\nerrors in production and development isn't desirable.\n\n## Usage\n\n### Automatic whitelisting\n\nTo set up an initial whitelist, run:\n\n    AS_DEPRECATION_RECORD=yes bin/rake test\n\nThis will generate `config/as_deprecation_whitelist.yaml` with a list of\nspecific instances of deprecated calls which can be committed. Subsequent `rake\ntest` runs will then automatically raise errors for new occurrences.\n\nRe-run tests with `AS_DEPRECATION_RECORD=yes` to append new instances to the\nexisting whitelist file, if you wish to permit rather than fix them.\n\nUse `AS_DEPRECATION_WHITELIST=~/rails_engine` to set a different root directory\nor whitelist file to update, e.g. for a Rails engine.\n\n### Whitelist configuration\n\nThe whitelist may be broad, permitting any call causing a particular\ndeprecation message or be precise, only permitting known calls identified by\ntheir backtrace. With broad whitelists, more instances of the same deprecated\ncall may be added, but precise whitelists require more maintenance if code is\nmoved and the backtrace changes.\n\nThe whitelist is stored in the Rails root at\n`config/as_deprecation_whitelist.yaml` and is a YAML file containing a single\narray of hashes:\n\n```yaml\n---\n- message: \"Deprecated call to X, use Y instead\"\n- message: \"Deprecated call to Z\"\n  callstack: \"app/models/foo.rb:23:in `example_method'\"\n```\n\nAccepted keys are:\n\n* `message`, matching the exact deprecation message\n* `callstack`, a string or an array forming the backtrace of the deprecation.\n  If an array is given for the callstack, all entries must match the caller.\n* `engine`, a Rails `engine_name` string, matching any call within the engine\n\nThe callstack will match on as much data as is provided - if only a file is\ngiven, any matching deprecation within the file will be whitelisted. The line\nnumber and method specification may be given for more specificity. The line\nnumber may vary by up to ten lines from the recorded number by default (see\n`line_tolerance` to tune). Usually the filename and method name are sufficient\nto match the caller without needing line numbers.\n\nThe message is an exact string match on the _start_ of the deprecation message,\nso not all of the original deprecation message needs to be specified.\n\nAdditional whitelist files may be placed below the root of each Rails engine\nand will be loaded at startup in addition to the main Rails root config file.\n\nEntries can be added programmatically by calling\n`ASDeprecationTracker.whitelist.add(message: ...)` with any of the supported\nkeys above supplied as keyword arguments.\n\n### Configuration\n\nUse an initializer to change ASDT's behaviour at startup:\n\n```ruby\nASDeprecationTracker.config.envs = %w(test development)\n```\n\nSupported options:\n\n* `envs` is an array of string Rails environment names that ASDT will monitor\n  and raise errors for unpermitted deprecation warnings (defaults to\n  `['test']`)\n* `line_tolerance` is the number of lines that callstack line numbers may\n  differ from the deprecated call (defaults to 10)\n* `register_behavior` controls whether to change the AS::Deprecation behavior\n  to ASDeprecationTracker::Receiver at startup, may be disabled to use multiple\n  behaviors (defaults to true)\n* `whitelist_file` to customise the location of the whitelist YAML file\n  (defaults to `config/as_deprecation_whitelist.yaml`)\n\n### Environment variables\n\nBoth `AS_DEPRECATION_` or the shorter `ASDT_` prefixes work with all\nenvironment variables listed below.\n\n* `AS_DEPRECATION_DISABLE` - set to any value will prevent ASDT from monitoring\n  deprecations and throwing exceptions. Rails will use default deprecation\n  behaviour.\n* `AS_DEPRECATION_RECORD` - set to any value will prevent ASDT from throwing\n  exceptions and will append entries to the `whitelist_file` for every\n  deprecation seen.\n* `AS_DEPRECATION_WHITELIST` - set to the root or full path of a whitelist\n  configuration file, overrides `whitelist_file`.\n\n### Pause/resume\n\nThe processing of deprecation warnings can be suspended and resumed via the\n`ASDeprecationTracker.pause!` and `ASDeprecationTracker.resume!` methods.\n\nThis is useful when programmatically building whitelist entries during Rails\ninitialisation, as deprecation processing can be disabled until the whitelist\nis fully formed. ASDT will queue events while paused and processes them when\n`resume!` is called.\n\n## Alternatives\n\nShopify have open-sourced a gem that works very similarly to ASDT and is worth\na look. It supports more configuration options when seeing a new or removed\ndeprecation warning, and also supports `Kernel#warn`.\n\n* [Shopify: Introducing the deprecation toolkit](https://engineering.shopify.com/blogs/engineering/introducing-the-deprecation-toolkit)\n* [deprecation_toolkit (GitHub)](https://github.com/shopify/deprecation_toolkit)\n\n## License\n\nCopyright (c) 2016-2022 Dominic Cleal.  Distributed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdomcleal%2Fas_deprecation_tracker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdomcleal%2Fas_deprecation_tracker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdomcleal%2Fas_deprecation_tracker/lists"}