[clazy] [Bug 450744] New: QString::toLower()/toUpper().endsWith()/.startsWith()

martonmiklos bugzilla_noreply at kde.org
Wed Feb 23 10:11:22 GMT 2022


https://bugs.kde.org/show_bug.cgi?id=450744

            Bug ID: 450744
           Summary: QString::toLower()/toUpper().endsWith()/.startsWith()
           Product: clazy
           Version: unspecified
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: unassigned-bugs at kde.org
          Reporter: martonmiklosqdev at gmail.com
                CC: smartins at kde.org
  Target Milestone: ---

I recently came across a code which used the following method to check file
extension:

if (fileName.toLower().endsWith(".xml"))

Clearly the author was not aware that the endsWith/startsWith has a second
argument for the case sensitivity.

I think it would be beneficial to add a clazy warning to highlight this. 

To summarize:
Throw a warning like "use the cs argument of the endsWith/startsWith" in the
case if:
There is a chained call of toLower()/toUpper().endsWith()/.startsWith()
And the endsWith() startsWith() has a single constant argument which does not
contain any upper/lower case characters.

I do not know if it is achievable by the clazy (having access to the arguments,
types, etc.)
If the idea has positive feedback I could look into implementing it.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Unassigned-bugs mailing list