-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Linter for print statements #57216
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
Comments
I'm considering taking a stab at this, but I have a couple questions.
|
This would be useful, but I wouldn't want it on by default (if there is such a thing). For example, I think it's fine to |
I don't care if it is on by default or not, but I would like to have this very much. Currently it's still common that debugging doesn't work and then I start adding print statements and it would be cool if the lint check would complain about them. |
Paging @bwilkerson ! :) As for a grouping, we definitely need more categories. Totally open for ideas as to where this one should land! Actually @bwilkerson, I'm curious, did you do anything similar in |
Assuming you have a resolved AST, then ask the MethodInvocation node for the staticElement it resolved to. That will get you a MethodElement, and you can ask it for the LibraryElement that it's part of. In this case it's easy because you can then ask the library element if it is in the SDK. Yes, we had a similar rule in CodePro that looked for uses of |
Thanks! I started to add just this but given that there are likely to be so few entries in this category, I wonder if we could lump this under something more general. What about under a |
A new |
In my experience, it becomes much too easy for people to just not think about the category very much and use a catch-all group for everything. But I think it's really useful to users to have meaningful categories to help them find what they're looking for. I'd strongly recommend not creating a catch-all group, but the decision is yours. |
Bumping this issue. It would be nice to have print statements listed as hints (if the linter rule is active). |
Hey I'm sorry to do the annoying thing where I'm basically just commenting to +1 an issue, but here we are 😳 This would be a really useful lint rule for my team. We frequently review PRs where team members accidentally left a Thanks! |
No worries @maxlapides . Any feedback is greatly appreciated and helps a lot! |
Thanks so much @pq! Looking forward to enabling this rule soon :) |
Good deal. Thanks for the nudge! |
Published code should use logging rather than
print()
statements, so consumers can decide how debugging should be handled.The text was updated successfully, but these errors were encountered: