Summary: | Validate regular expressions passed to QRegExp and QRegularExpression | ||
---|---|---|---|
Product: | [Developer tools] clazy | Reporter: | Thomas Fischer <fischer> |
Component: | general | Assignee: | Sergio Martins <smartins> |
Status: | CONFIRMED --- | ||
Severity: | wishlist | CC: | smartins |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Thomas Fischer
2017-10-10 07:33:33 UTC
we could use a regular expression to validate regular expressions :) One option is to link to pcre or Qt and validate the string. Additionally, I think it should warn if you're not using C++11 raw-string-literals, which makes code much less error prone. (In reply to Sergio Martins from comment #2) > One option is to link to pcre or Qt and validate the string. Using pcre would have the advantage of being a 'lighter' dependency than Qt and maybe more generally already installed. Using Qt would have the advantage to be more 'realistic'. > Additionally, I think it should warn if you're not using C++11 > raw-string-literals, which makes code much less error prone. If it would be technically possible, make the dependency on pcre or Qt compile-time optional, i.e. a configuration/build flag. Coded in clazy could be some basic checks that would be applied before any pcre/Qt tests and be available even if pcre/Qt support would be disabled. Those basic checks could be: - Correct usage of raw-string literals as you mention, e.g. \b vs \\b - Correct matching of parenthesises: (..[..]{..}..) with some support for special cases such as \( or [^{] ... in general some quick and dirty checks for common mistakes and always cheaper than parsing the regexp in pcre or Qt. For more inspiration check StackExchange for common problems programmers have with regexps ... ;-) |