Details
-
Suggestion
-
Resolution: Fixed
-
Not Evaluated
-
Qt Creator 4.14.0-rc1
-
None
Description
The patch for QTCREATORBUG-9617 already allows to extract a constant as function parameter, which (almost) works great.
I'm now requesting the same, but to extract the value as const local variable and/or as enum.
The reason is, that in unit tests you often have to use magic numbers on several positions.
For example, the code:
void test_get() { RingBuffer buf; buf.add(42); QCOMPARE(buf.get(), 42)); }
could be refactored to:
void test_get()
{
enum { value = 42 };
RingBuffer buf;
buf.add(value);
QCOMPARE(buf.get(), value));
}
by using the quickfix "Extract constant as enum" by using Alt+Enter on the number 42.
Attachments
Issue Links
- relates to
-
QTCREATORBUG-9617 Refactoring: Extract constant in function body to function parameter and adapt function uses
-
- Closed
-
-
QTCREATORBUG-25104 "Extract constant as parameter" quickfix should allow immediate renaming
-
- Closed
-