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
valid_regexps should warn about string literal #1049
Comments
Seems to be a valid regex according to the comments in the linked issue. |
If I'm understanding, I think the issue is not that it's an invalid regular expression but rather that it does not match what you think it should (e.g., in this case just a literal string match). I think I know what you mean though. Maybe something along the lines of a warning when you are using a regexp when a string match mould do? In that case, maybe another lint for Thanks for opening this issue! |
I interpreted it that it should warn about the missing |
Oh! (It's early here; need more ☕️.) That's easier but likely to flag a bunch of false positives? For example, I count ~12 regexps in the linter package that are valid but not defined w/ raw strings... |
Sorry if my request is not clear :-) |
No worries @alescdb. This is a great conversation. Thanks for kicking it off!
Interesting idea. My gut says that should be another lint. (These are not technically invalid and may, in odd cases, actually be what you have in mind? 🤔 ) The trick is in writing the write prescription. We're not checking for validity exactly. Maybe we just want something that flags Want to take a stab at writing a sentence or two description? 😄 |
If escaping parenthesis |
Ah, OK. I honestly have to look up the grammar for regexps every time I use them for exactly the reason you describe. 🙄 Definitely annoying and if analysis can help, all the better. Flagging this one as "help wanted" since I'm lacking the required fluency and updating the title too. Thanks! /cc @bwilkerson |
For the curious, Dart regular expressions have the same syntax and semantics as JavaScript regular expressions. Here's the relevant bit of grammar: |
The regular expression
new RegExp('\(([^\)]*)\)');
is not valid in dart, and (I think) we should be warned about it by lint.ref : dart-lang/sdk#33669
The text was updated successfully, but these errors were encountered: