-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow for "budgets" as a deprecation handler #64
Comments
@fivetanley Just to clarify, does For example, adding a new test which exercises existing deprecated code won't cause you to blow your budget? |
@patocallaghan the total number of times the deprecation warning is called no matter where it's called from. trying to track where something gets triggered from sounds expensive/ hard to know, but if there's a good way to track that / figure it out that might be a more useful thing |
I think this is an excellent idea, but I'd like to suggest that an alternative property name be used, as I'd suggest something like: Additionally, it seems like it might also be useful to make this configurable so that you can set a budget and then choose whether additional deprecations window.deprecationWorkflow.config = {
workflow: [
{ matchId: 'ember-string-utils.fmt',
// Will log after the 10th occurrence
handler: 'budget', options: { count: 10, behavior: 'log' }
},
]
}; |
Oh I think I like @bantic's last suggestion at API there, especially since it moves |
Context
Currently, ember-cli-deprecation-workflow supports 3 handlers for deprecations:
While these work for their intended purposes really well, they don't necessarily help cases where you might not be able to address a deprecation right away, but a team wants to prevent the deprecation count from growing from things like copy-pasting code that will cause new deprecations to pile up.
Proposal
Users of this addon will be able to specify a
budget
option to thehandler
option for each deprecation. If the deprecation is triggered more than the allowedbudget
in certain scenarios (e.g. a test suite run where conditions are more controlled), then the handler will throw. This would allow a team to keep existing code that causes deprecations but fail builds in CI for any new code that increases deprecation use.For example, take the following
config/deprecation-workflow.js
:if a new pull request was opened with the following code:
Ember.String.format('some string %s', 'hi')
This would increase the number of deprecations invoked to
11
, violating the budget, causingember-cli-deprecation-workflow
to throw, failing the build.We would likely also need some facility to make copy/pasting the existing deprecation count (to set the initial budget) to
config/deprecation-workflow.js
from the browser easier as well.I'd be happy to PR this, just wanted to get thoughts on the idea before going through the effort of writing code.
The text was updated successfully, but these errors were encountered: