Details
-
Suggestion
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
None
-
None
-
Not really relevant
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:
- Use the variable (sometimes we can't or won't do that)
- Disable compiler warning (not really advised)
- 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.
- 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.