This repository has been archived by the owner on May 3, 2024. It is now read-only.
Adding a new protection #15
alexevanczuk
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Adding a new protection
This document contains some information on adding new protections. It's mostly focused on adding a custom one in your app, but it also applies to protections checked into this repo.
Making a new rubocop protection
.rubocop.yml
to make sure its working as expected.include PackageProtections::RubocopProtectionInterface
, run sorbet type check, and implement the required interface methods. See https://github.com/rubyatscale/package_protections/tree/main/lib/rubocop/cop/package_protections for examples.Backfill the protection to
fail_never
for all packagesBy default, all protections have a default value of
fail_on_new
. The idea is that if we think the protection is something everything should turn on, we want the default to be the path we want folks to take. In some cases this is not the case. The visibility protection default isfail_never
, because by default we don't want folks making packs only visible to some other packs (we want the default design principle to be that any pack can consume any other path, theoretically).For new protections, its important to backfill all old packages to turn this protection OFF so it can be gradually turned on. Say your protection is
prevent_foobar
. You can backfill this with this script:This just rewrites all packages with the new protection.
In some cases, this may produce undesirable diffs related to other things that are rewritten. I recommend committing those as part of a separate diff that can be generated with the simpler command:
Gusto today has a CI check that ensures
deprecated_references.yml
are up to date. We might consider adding something to ensurepackage.yml
changes do not contain incorrect formatting (basically linting forpackage.yml
files).Identifying candidates to opt into the package protection
It might be helpful to identify packages that are already overwhelmingly following the new protection and opt them in to establish some examples.
For a rubocop rule, you can do this by following these steps:
Say my new cop is
Style/MyNewCop
and it applies to files in the public directory..rubocop.yml
Writing tests for custom protections (rspec)
I'll fill this out with more detail later.
require 'package_protections/rspec/support'
package_protections_spec.rb
Beta Was this translation helpful? Give feedback.
All reactions