-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add failing for certain methods in a given package (i.e: fmt.Errorf) #7
Comments
Happy to take this. Our main use case is that we need this to block |
Some additional work would be to make it less painful to configure multiple functions like
But let's maybe attack this later on - also it would work weirdly with suggestions. |
This would be super easy to implement, but might be not very clear for users (:
|
Nice edge case:
Should we block |
|
Looks a feasible solution to me. |
Ack, playing with some nice regexp for this. |
Thanks for the comments. There are a lot of edge cases and it's great we capture them here. So after looking at #2 and reading the comments here, I think we need a proper and scalable syntax for the config. Either we try to put everything inside the If we go route 1, I think using a Regex style syntax would solve a lot of stuff. For example #2 would benefit from it:
Or for this issues it could be
But Assuming we use this format (no regex):
How should we define the suggestion in this case? Currently it's like this:
So we need to come up with a solution to provide suggestion for methods as well. One idea:
I'm still tinkering about this so if you have more ideas about the syntax or if you think it would make sense to introduce new flags let me know. |
Fixes fatih#7 Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
Fixes fatih#7 Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
Suggestions for the function is not really a problem. It's bit tricky to add suggestions for grouped functions with I went for a simple solution, so just a single suggestion for a single group, so it's up to the user to make it work. The suggestion is kind of import-like arbitrary string you can put. I think that's easy enough for users. Anyway, all should be fixed here: #8 |
Fixes fatih#7 Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
Fixes fatih#7 Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
Currently
faillint
only fails on package level (based on the import path). We should also make it possible to fail for a sub-set of exported functions, types or variables (i.e: ast.TypeSpec and ast.ValueSpec should be enough).Why is this useful? Let's look at this example:
If a user opted to use
github.com/pkg/errors
not only want they prevent the usage oferrors
package, they probably also want to avoid usingfmt.Errorf
and start usingerrors.Errorf
method from thegit.luolix.top/pkg/errors
package. There are many reasons for that. For example thegit.luolix.top/pkg/errors
package includes stack information in each error value. Hence they want to make sure all errors are created with thegit.luolix.top/pkg/errors
package.We could still use the
paths
flags and could define the sub-set with a dot identifier. For example the following command could fail for all usages oferrors
and the usage offmt.Errorf
:If anyone wants to work on this, please comment on the PR before starting on it. I'll work on that at some point otherwise.
The text was updated successfully, but these errors were encountered: