Comments (10)
Ack, playing with some nice regexp for this.
from faillint.
Happy to take this.
Our main use case is that we need this to block prometheus.New...
and promethues.MustRegister
to force the use of new amazing promauto.With(..).New...
addition that ensures that we never forget about registering metric again! However https://godoc.org/github.com/prometheus/client_golang/prometheus package has much more than just constructors, so we cannot block the whole package. (:
from faillint.
Some additional work would be to make it less painful to configure multiple functions like
faillint -paths "github.com/foo/bar,github.com/foo/bar/foo.{A,B,D,G,Z}
But let's maybe attack this later on - also it would work weirdly with suggestions.
from faillint.
This would be super easy to implement, but might be not very clear for users (:
faillint -paths "github.com/foo/bar,github.com/foo/bar/foo.A.B.D.G.Z
from faillint.
Nice edge case:
faillint --paths "errors,gopkg.in/yaml.v2"
Should we block v2
function of yaml or just gopkg.in/yaml.v2
import? ;p I guess since you cannot in theory use unexported v2
function, it's the former (:
from faillint.
Also package.ABC
is invalid as package name but a valid repository name.. 🤦♂️
No way really to figure it out, so I guess we either assume no such package will be provided.. or we might need something different than .
for function name separator.
from faillint.
{}
might do...
faillint -paths "github.com/foo/bar,github.com/foo/bar/foo.{A}
from faillint.
{} might do...
Looks a feasible solution to me.
from faillint.
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 --paths
flag and try to improve the syntax there OR we split certain things into separate flags.
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:
faillint --paths "github.com/golang.org/x/net/**"
Or for this issues it could be
faillint --pahts "errors,fmt.(Errorf|Foo)"
But regex
is the last thing I want to use anywhere in this tool. faillint should be easy to use without any surprises. regex
is the opposite. Also I don't want to use a config file, because storing and managing a file is a chore and burden.
Assuming we use this format (no regex):
faillint -paths "errors,fmt.{Errorf}"
How should we define the suggestion in this case? Currently it's like this:
faillint -paths "errors=github.com/pkg/errors"
So we need to come up with a solution to provide suggestion for methods as well. One idea:
faillint -paths "errors=github.com/pkg/errors,fmt.{Errorf}=github.com/pkg/errors.{Errorf}"
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.
from faillint.
Suggestions for the function is not really a problem. It's bit tricky to add suggestions for grouped functions with {A,B,C}
which I proposed here: #8 (:
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
from faillint.
Related Issues (18)
- Ignore vendor dir HOT 1
- Ignore Tests HOT 3
- Comment imports to tolerate exceptions HOT 10
- Skip generated files. HOT 3
- Add support to path prefixes HOT 3
- Parse paths from a configuration file
- Dot imports
- Possibility to detect function from a struct
- [Feature Request] Autofix support HOT 1
- Analyse go files with buildtags HOT 3
- Error "could not import C" when using CGO HOT 3
- Error `constant overflow` for `-math.MaxFloat64` HOT 2
- [Feature Request] Support excluding packages HOT 4
- Add ability to lint only test/benchmark/fuzz functions HOT 1
- package imported without types errors when using with Go 1.18 HOT 4
- Example of README: As an example, you could enforce the usage of github.com/pkg/errors instead of the errors package. HOT 1
- Panic while parsing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from faillint.