Discussion:
[clazy] [Bug 391824] New: False positive check "qstring-allocations" for function translate
(too old to reply)
Roman
2018-03-13 15:27:19 UTC
Permalink
Raw Message
https://bugs.kde.org/show_bug.cgi?id=391824

Bug ID: 391824
Summary: False positive check "qstring-allocations" for
function translate
Product: clazy
Version: unspecified
Platform: Other
OS: Linux
Status: UNCONFIRMED
Severity: normal
Priority: NOR
Component: general
Assignee: unassigned-***@kde.org
Reporter: ***@gmail.com
CC: ***@kde.org
Target Milestone: ---

In my code i use little hack. If wrap string to a function translate, it will
be marked for translation. No matter what namespace contains this function. So,
i have

#define translate(context, source, disambiguation)
QmuTranslation::translate((context), (source), (disambiguation))

And use it like this:

translate("QmuParserErrorMsg", "Unexpected token \"$TOK$\" found at position
$POS$.", "Math parser error messages. Left untouched \"$TOK$\" and $POS$")

When lupdate will parse a source code it will mark a string for translation.
But clazy doesn't recognize this case and warn about "qstring-allocations".
Where for canonical translate functions it doesn't.

--
You are receiving this mail because:
You are watching all bug changes.
Sergio Martins
2018-03-13 15:32:51 UTC
Permalink
Raw Message
https://bugs.kde.org/show_bug.cgi?id=391824

--- Comment #1 from Sergio Martins <***@kde.org> ---
Can you show a compilable-testcase.
Must be minimal, as I'll shove the code directly into clazy's unit-tests

thanks

--
You are receiving this mail because:
You are watching all bug changes.
Roman
2018-03-13 17:16:47 UTC
Permalink
Raw Message
https://bugs.kde.org/show_bug.cgi?id=391824

--- Comment #2 from Roman <***@gmail.com> ---
Created attachment 111374
--> https://bugs.kde.org/attachment.cgi?id=111374&action=edit
compilable-testcase

Minimal project that shows false positive warning. Uncomment strings to test
canonical way.

--
You are receiving this mail because:
You are watching all bug changes.
Sergio Martins
2018-03-14 19:58:26 UTC
Permalink
Raw Message
https://bugs.kde.org/show_bug.cgi?id=391824

--- Comment #3 from Sergio Martins <***@kde.org> ---
tr() doesn't take QString as argument, so there's no allocation

You can either use const char* in your translate function, or:
translate(QStringLiteral("context"), QStringLiteral("string"),
QStringLiteral("disambiguation"));

I don't see a way clazy could distinguish this case

--
You are receiving this mail because:
You are watching all bug changes.
Roman
2018-03-15 06:37:51 UTC
Permalink
Raw Message
https://bugs.kde.org/show_bug.cgi?id=391824

Roman <***@gmail.com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED

--- Comment #4 from Roman <***@gmail.com> ---
Yes, you are right. This ticket should be closed.

--
You are receiving this mail because:
You are watching all bug changes.
Loading...