-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
new rule - enforce that strings passed to exceptions have a variable in them #11979
Comments
I can give this a go as it seems quite similar to the other PR (#11981) I just worked on, and I personally like long and detailed Exceptions! I am proposing to only deal with Built-in Exceptions - as User defined exceptions can have particular contextual meaning already, and a variable is not necessarily required. There are also 4 notable exceptions:
I'll set this up to check against the remaining 52 types. |
…eption messages without contextual information.
…eption messages without contextual information.
…eption messages without contextual information.
…eption messages without contextual information.
…eption messages without contextual information.
there have been countless times where i've encountered unhelpful error messages in software that don't provide enough information to the user. i think this is something that can be addressed with a lint rule. for example:
error messages like this are extremely common and are very frustrating when exposed to a user. what file was it looking for?
in this case, the fix would be to include the
path
variable in the message:obviously there will be cases where this is intentional, so here are a couple ideas to help reduce the number of false positives:
Exception
,FileNotFoundError
). ideally this would be user-configurable.raise FooException()
would not report the error butraise FooException("something failed")
wouldThe text was updated successfully, but these errors were encountered: