Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-31768

Add "fix available" for unused parameter warning

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • None
    • C/C++/Obj-C++ Support
    • None
    • Not really relevant

    • All

    Description

      QtCreator has some cool interactive lightbulbs that allow one-click "fix". Some of them are quite clever, for example, it offers to include the correct header file when it encounters an undeclared identifier that is declared in a header in Qt or in the project itself:

      However some simple warnings do not have such nice fixes available. This suggestion is about such a fix:

      In my code, I have defined a method with a named parameter (returnActivity in this example). There are really 4 ways to handle this from a developer's perspective:

      1. Use the variable (sometimes we can't or won't do that)
      2. Disable compiler warning (not really advised)
      3. un-name the variable by removing it from the signature. This may be a contentious issue, but I think that keeping it named serves a purpose of giving other developer context, even if the parameter is not actually used. But you could argue it is a clean-code practice to just remove the name. Also, often when implementing a large interface we defer the implementation mentally during development, and thus we have to endure the mental agony of looking at irrelevant warnings that distract us from the real work.
      4. Add a Q_UNUSED() macro at the top of the file (or void cast) to pretend it is used to silence the warning. This is usually what I end up doing.

      I would love to see the fix "un-name this variable" and "Wrap in Q_UNUSED()" as proposed fixes inside the little helpful light bulb. I would hit that at least 10 times per day.

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kandeler Christian Kandeler
            lennartrolland@gmail.com Lennart Rolland
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes