Commit Graph

87 Commits

Author SHA1 Message Date
Olivier De Cannière 319dea7924 QQmlJSLogger: Also print out hints of fixSuggestions
It otherwise went unused.

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I255a53247d0cfce29d958425d1f8f2895eb093e7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-08-20 16:32:36 +02:00
Fabian Kosmale 0b9a554ede QQmlJSLogger: Don't trigger assert in QColorOutput
As a comment already points out, having an empty replacement message is
possible. In that case, we shouldn't attempt to print it.

Add a dedicated test-setup for QQmlJSLogger, to make it easier to expand
tests there.

Pick-to: 6.10 6.9 6.8
Fixes: QTBUG-138871
Change-Id: I55c5de140fe8175e9deaca519bb734654dc366f4
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2025-08-05 17:06:31 +02:00
Fabian Kosmale 3ab60f40d5 qmllint: Avoid spurious warnings when file selectors are used
When file selectors are used, we loose too much information currently,
as we completely discard everything we know about the type.

[ChangeLog][qmllint] qmllint and the LSP now no longer print warnings
about ambiguous types if file selectors are used, and instead use the
"plain" version. The QML script compiler will still conservatively
reject such QML files. If warnings about such cases are desired,
the new "importFileSelector" warning category can be enabled.

Task-number: QTBUG-137075
Pick-to: 6.10
Change-Id: Ia87d5ab62003fe8d7d2ab9569fac2942fb1c7c14
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
2025-07-18 11:59:42 +02:00
Olivier De Cannière 2a6e8582fc qmllint: Warn about using enums as type annotations in functions
Until we support a proper representation of enums in the type system,
all we can do is warn the user that enums can't be used as types.

After the improved runtime warning added in a recent commit, this patch
adds a qmllint warning to warn about the same issue but at
'compile time'.

Fixes: QTBUG-135255
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I02266f21266e59eb6d4a4dbe0e4335b845c62133
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2025-06-10 13:25:50 +02:00
Sami Shalayel 64bc8887f2 qmllint: implement MaybeWarnEqualityTypeCoercion
Warn in qmllint when encountering "==" or "!=" about possible type
coercions between JS objects, numbers, strings and booleans.

Task-number: QTBUG-129307
Change-Id: Ib9b8057c1b4eca760c4f40825f4053aa35f1680b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-05-31 07:02:15 +02:00
Olivier De Cannière 2e00bc40cc qmllint: Warn about unintentional empty blocks
If a property binding is a js block without any statements, it could
mean that the user intended to create an object literal instead of an
empty block that returns undefined.

Task-number: QTBUG-129307
Change-Id: If242ddac140cce6479062194b785096ba1f6c0a6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-05-30 22:25:39 +02:00
Olivier De Cannière 005848a0c8 qmllint: Suggest specific types instead of var
A test was slightly adapted as a result.

Task-number: QTBUG-129307
Change-Id: I07ac61b183d9d7d237e9cf51ce3a0c6c280daa45
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2025-05-30 18:29:44 +02:00
Olivier De Cannière 7c97e932e1 qmllint: Warn about Components that don't have exactly one QML child
Two other tests needed to be updated as a result.

Task-number: QTBUG-129307
Change-Id: I1470a5ae93cc20ef90ffd63471bd36408b61af57
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2025-05-30 18:29:31 +02:00
Sami Shalayel b739545a12 qmllint: implement WarnConfusingExpressionStatement
Warn about ExpressionStatements that has no obvious effect in qmllint,
for example "x * 3;" is an expression statement that is either useless
or that potentially triggers user code with potential side-effects
during the custom coercion of "x". Warn that the expression statement
has no obvious effect.

Don't warn about expression statements inside of bindings: "y: x * 3" is
completely fine, for example.

Task-number: QTBUG-129307
Change-Id: I065ddce7394276296062545c1516ab9b4ad9f24d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-05-22 17:27:54 +02:00
Sami Shalayel 4d31fd5799 QQmlJSLinter: add crude context properties warnings
Warn in QQmlJSTypePropagator::generate_LoadQmlContextPropertyLookup()
about usages of context properties that were found. Also treat context
properties as var.
Add the (C++) location of the "setContextProperty()" call to the
warning, and also hint that a property is assumed to be a context
property when inside a top-level component (capital C Component, inline
component or implicitly wrapped as component) because it is not
declared as required property.

Still print the accompanying unqualified warnings next to the new
context property warning.

Add a test.

Later patches will add the support to qmlls and qmllint by passing
the workspace folders to the new functionality.

Task-number: QTBUG-128232
Change-Id: I26e39e0bce8c6e9f203962a091209c7acd15d445
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
2025-05-22 09:19:51 +02:00
Olivier De Cannière 65804aaa92 qmllint: Warn about unterminated non-empty case blocks
Task-number: QTBUG-129307
Change-Id: I95f633299ca94cb27c545a97a465bb5e24b5e3e8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-05-19 20:41:03 +02:00
Olivier De Cannière f7a60386df qmllint: Warn about enums declared in non-root elements
Fixes: QTBUG-119781
Task-number: QTBUG-119890
Change-Id: I392819ad0a47e0457c4b888894893ac37a77fa11
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-05-19 20:41:03 +02:00
Olivier De Cannière ae3754df95 qmllint: Warn about enum entries matching the name of the enum itself
Fixes: QTBUG-117300
Task-number: QTBUG-119890
Change-Id: If503b3dbfe9c8ad916afa3b570861f62c33e1fbd
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-05-19 20:41:03 +02:00
Olivier De Cannière b44e844f4a qmllint: Move enum warnings to linting visitor and add warning category
The warnings should be part of the linting visitor.

Introduce a new warning category for the exising warning about
duplicate enum entries.

Amends bbce9ea73f

This also (re)moves the test for warnings about enums in inline
components from qmltc. These warnings should be generated by qmllint.
Some files that had enum inside of inline components may no longer fail
to compile because of the warning. This is fine as the enum is not
accessible anyways.

Amends f368be4320

Task-number: QTBUG-119890
Change-Id: I90f280e2e443504ab336b4c2ad85bf7e53e4544f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-05-19 20:41:03 +02:00
Olivier De Cannière bcbd2173dc qmllint: Warn about duplicate imports
Fixes: QTBUG-127325
Task-number: QTBUG-119890
Change-Id: I20b497da025dec8050ea94fc604db33a3ebdde77
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-05-16 17:00:10 +02:00
Sami Shalayel 131cc998f7 qmllint: implement WarnConfusingPluses and Minuses
Implement the confusing pluses and minuses warnings. Those are triggered
for weird combinations of unary pluses and pre increments inside of
additions. (same for unary minuses and pre decrements).

Task-number: QTBUG-129307
Change-Id: I45c202efa58a588090d872f0bf8f43523c24a957
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-05-16 17:00:04 +02:00
Sami Shalayel 6d86e944f0 qmllint: implement WarnVoid
Warn about usages of the void keyword. This warning is off by default,
mirroring the behavior of eslint.

Task-number: QTBUG-129307
Change-Id: Iba1cc09e028d5053ef1aa28f01f1694efa5c250f
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
2025-05-16 17:00:01 +02:00
Sami Shalayel 1950f29b88 qmllint: implement WarnXConstructor
Implement the WarnXConstructor and complain about a specific set of
constructors.

Task-number: QTBUG-129307
Change-Id: I27e0cfcb1f061bb2efff1721da4a2bbdb01fcf2f
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
2025-05-16 16:59:57 +02:00
Sami Shalayel 76a29eee52 qmllint: implement WarnComma
Warn when comma expressions are used outside of for-loops.

Task-number: QTBUG-129307
Change-Id: Ic86bf3af7f122f73b70e18c728c72f64c355f982
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-05-16 16:59:53 +02:00
Olivier De Cannière fb61c6bb84 qmllint: Warn about duplicate inline components
Fixes: QTBUG-126715
Task-number: QTBUG-129307
Change-Id: I739587bf6d44131d9a0bdcec4df60ab3f53e1a12
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2025-05-08 12:31:35 +02:00
Olivier De Cannière 41f8e39567 Logger: Sort logging categories
Merge conflicts are slowing us down quite a bit when working on
qmllint. Sorting the logging categories will reduce their number.

As a drive-by: fix macro

Change-Id: Ibee997c79b29128c209018a2aa010a35e7d13991
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2025-05-08 12:31:34 +02:00
Olivier De Cannière 1215e4dc60 qmllint: Fix typo in warning description
Amends 959836a5b3

Change-Id: I64a04f20beed34cb853e69a356734bcb6f7f0349
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2025-05-08 12:31:34 +02:00
Olivier De Cannière 959836a5b3 qmllint: Warn about reads of non-constant and non-notifiable properties
The binding might not update if their value changes.

Fixes: QTBUG-112508
Change-Id: I27801d662117a89c0fdddc2aaa2f1dde21b238df
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2025-04-29 09:46:49 +02:00
Sami Shalayel f8e3ad0b09 qmllint: warn about unreachable code
The compiler is very polite and does not tell the user about its useless
code. Codegen::statementList(StatementList *ast) silently discards
unreachable statements during byte code generation.

Warn the user that their code is unreachable. Don't warn about
function definitions because these ones are "hoisted" up,
which means that their definition is supposed to be pushed up, so that
they can be used even if they are behind a "return" or "throw"
statement.

Don't use the qqmljsbasicblock analysis for that, it reports too many
"false positives" where the compiler generates dead code that can't be
fixed by the user.

Task-number: QTBUG-129307
Change-Id: Ia26e8af1adf4e63b26dcaa7fb10be73b7eb084d7
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
2025-04-25 14:32:03 +02:00
Sami Shalayel 9b2cff650a qmllint: Implement WarnFunctionUsedBeforeDeclaration
Warn about functions used before their declaration. Its not technically
an error like the "var used before declaration" because functions are
"hoisted up" and therefore available even before their declaration, so
create a new warning category for it instead of reusing the "var used
before declaration" category. Disable the warning by default: Qt Creator
used to have it as default, while other tools like eslint don't.

For the same reason, don't warn about functions used before declaration
during codegen, and add a method to warn about it in
CodeGenWarningInterface. The code for "var used before declaration"
can be reused by function declarations by adding a sourcelocation for
function declarations in the "addLocalVar"-call, so make sure to
differentiate between functions and vars by adding an extra member to
Context::ResolvedName.

Task-number: QTBUG-129307
Change-Id: I83a4f8cd00c120db23a0cec3365a00ed44de2836
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
2025-04-24 14:45:48 +02:00
Sami Shalayel 6dcd494cad qmllint: suppress secondary messages with main message
Allow warnings to be emitted in multiple parts, as a preparation step to
have two warnings for "var-used-before-declaration": one of the usage
and one for the declaration.

Added an extra parameter to log that overrides the line number used to
determine whether the current warning is ignored or not. This assumes
that both main and secondary messages both use the same warning
category.

Task-number: QTBUG-129307
Change-Id: I82ed01d417070b13e3c91ea82218e0d858e10d24
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-04-10 13:35:01 +02:00
Olivier De Cannière 3cb8e9b605 qmllint: Warn about redundant optional chaining
Using an optional lookup '?.' on a base type that cannot be null or
undefined or when looking up an enum value is pointless. We generate a
normal lookup for this in the compiler, but the bytecode keeps these
redundant instructions in.

Task-number: QTBUG-135649
Change-Id: I95d8b4ed22afa1bdc46a3f8b3d60a499d43931ac
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-04-10 13:35:00 +02:00
Sami Shalayel bf6b29fbe8 qmllint: implement WarnEval
Complain about usages of Eval in qmllint, and make the
qqmljstypepropagator analyze eval calls.

Task-number: QTBUG-129307
Change-Id: I577612220383c624e960db60ed755e0f2dbc59aa
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-04-04 14:51:21 +02:00
Olivier De Cannière 7d02c86531 Compiler: Ensure uniqueness of logging categories
Added some macros to static_assert that the logging categories are
unique in name, settings name and description. This excludes empty
strings.

A duplicate description was already found and fixed thanks to this.

Change-Id: I9fd689065f5bb3a567143ed78211800f88543408
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2025-03-25 22:54:42 +01:00
Sami Shalayel ce69cc78c0 qmllint: implement WarnAssignmentInCondition
Warn for assignments inside of if-statement conditions.

Task-number: QTBUG-129307
Change-Id: If1e4d85b6cdbf4f076d91dcf8d7600988f51d6a1
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-03-25 22:54:42 +01:00
Sami Shalayel 1c440fb896 qmllint: fix a typo in top-level-component description
Fix a typo in the top-level-component description.

Pick-to: 6.8 6.9
Task-number: QTBUG-135020
Change-Id: I22b0e83567fa71346486d206e21e182fabde2718
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
2025-03-25 22:54:42 +01:00
Sami Shalayel 9cf3285062 qmllint: clean up recursion-depth-errors category
The category is default, it has no setting name and also no commandline
parameter. Remove the bogus ones and use empty strings instead.

Task-number: QTBUG-135020
Change-Id: Ie8847a379c86f705cb7883615bb71b76e08ec4ce
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
2025-03-25 22:54:42 +01:00
Sami Shalayel ca0348fad2 qmllint: fix setting for alias cycle and unresolved alias
Make sure both have their own setting key, but still support the
previous "buggy" setting key. Print a deprecated warning when finding
the buggy setting key in a setting file.

Task-number: QTBUG-135020
Change-Id: I364e7e41380de43a0883bcf4d3f6cefcf11b6c90
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-03-25 22:54:41 +01:00
Sami Shalayel 2b720dbe79 qmllint: register missing-enum-entry category
Amends d876ce343d and add a description
and a settingname to the missing-enum-entry category, so that it can get
registered into qmllint.

Also fix the test to expect a warning instead of an info message. Info
messages are selected by default for unregistered categories.

Task-number: QTBUG-135020
Change-Id: I1fe3684bb12c198633bb86e1cb96a390f352739b
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
2025-03-25 22:54:41 +01:00
Sami Shalayel 276a5a8755 qmllint: put all warning categories in one central location
Before this commit, adding one warning category required changing three
different code locations. This makes adding new categories complicated
and error-prone. We will need to potentially add a lot of new categories
for QTBUG-129307, and d876ce343d is an
example where a warning category was introduced but not registered into
qmllint (it can't be controlled with commandline parameters, nor
settings, nor is it listed by qmllints --help method...).

With this commit, new warning categories only need to be added in two places:
the QMLLINT_DEFAULT_CATEGORIES macro and the public header
qqmljsloggingcategories.h.

Task-number: QTBUG-135020
Task-number: QTBUG-129307
Change-Id: I915ae8da7fe0a01b7518ed8c113be5bb640de75b
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
2025-03-25 22:54:41 +01:00
Sami Shalayel 6d4a14f047 qmllint: avoid wasteful didYouMean calls
Add a new disabled mode to qqmljslogger that is used when warnings
emitted by qqmljsimportvisitor are actually not shown to the user. Add a
comment explaining the difference to a silenced logger (that still
processes warnings and can be used to generate a JSON representation of
the warnings) and a disabled logger (that does not contain any warning).

Disable the logger in QQmlJSTypeReader that is only used for the (lazy
file creation.

This avoids expensive didYouMean() calls that slow down the linter and
only create warnings that are ignored by the linter.

Also add some ifs to qqmljslogger to avoid any useless computations when
the logger is disabled anyway.

This commit makes the runtime of tst_qmllint_benchmark:onlyQdsLintPlugin
on qtdesign-studio/examples/DesignEffectsDemo/content/Gallery.ui.qml go
from 500ms to 135ms (mean over 3 iterations) when the QtDesign studio
modules import paths are unavailable.

Task-number: QTBUG-133349
Change-Id: I5abaa5e6776e39f2dee7f1a92577a240dd5c61c1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-02-18 20:02:03 +01:00
Ulf Hermann 13cb5754b2 QmlCompiler: Clean up error handling
We should only have one way to handle diagnostic messages: The
QQmlJSLogger. In addition each compile pass may result in an error that
prevents the running of further passes. But that error should not rely
on the selection of messages posted earlier.

For this to work we need to introduce a further state transition into
the logger. The logger now "archives" messages after compiling each
function, so that only the current function's compile errors are taken
into account as result of the current function's compilation.

Task-number: QTBUG-124913
Change-Id: I4b6d9910b80527cefb1aba02598114d1fe5ba172
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
2025-02-02 13:59:44 +01:00
Ulf Hermann d3492ff7c1 QmlCompiler: Introduce transactions for the logger
Certain compile passes may be run multiple times and only the last run
counts. We need to be able to roll back the logger to the state before
the pass in that case.

Amends commit d70abd83dc

Pick-to: 6.9
Task-number: QTBUG-124913
Change-Id: Ie6174fc3d6ce60ca3f0a3fa27484a58e6febcc17
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-01-21 16:56:47 +01:00
Sami Shalayel 8b61addfa4 qmllint: warn about mixing translation functions
It seems that mixing different translation functions (id-based with
non-id based translations) is not supported in the same qml file.
Therefore, emit a warning when mixing up id and non-id translation
methods.

Currently, it is not possible to have warnings for mixing usages of
QT_TRANSLATE_NOOP(), QT_QSTR_NOOP(), QT_QSTRID_NOOP() but that
should not be too important for the actual feature, as calls to
QT_QSTR_NOOP and QT_TRANSLATE_NOOP only make sense when there is
a qsTr or qsTranslate around.

Add a QEXPECT_FAIL test for that.

Task-number: QTBUG-129308
Change-Id: I8b19ca997cd6b4b8619c53c079dd72b9510fb904
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-01-02 17:48:52 +01:00
Sami Shalayel 7188ee3513 qmlls: put import warnings on the correct line
In qmllint, the import warnings are printed right after the "warnings
occurred while importing" warning despite them having no sourcelocation.

This warning gets a default sourcelocation when used in qmlls which
points to the first line of the file, so the "Failed to import" warning
ends up an the first line of a file, and not on the same line as the
"warnings occurred while importing" warning. This is confusing for users.

Modify a test to expect that the "Failed to import" warning has a valid
sourcelocation, so that it is shown on the correct line in qmlls.

Fixes: QTBUG-131958
Pick-to: 6.8 6.9
Change-Id: Ia0c327b82e89cd0a003d05b4c3efe693fb3b3ed7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2024-12-11 14:26:05 +01:00
Olivier De Cannière ee5c015b3a Compiler: Make qqmljsscope::filePath hold the source location more often
Previously, it would hold the location of the copy in the build
directory or in the resource file system.

This should improve the accuracy of the information that we can report
back. For example, the file location of files reported in aotstats will
now be those in the source folder.

The changes necessary for this patch were found through trial and error
by asserting that the filePath respect a certain form and fixing what I
could. There remain cases where the filePath still contains a location
in the build directory. We would need some other change to report those
accurately as well.

Finally, sometimes the filePath is empty or does not contain a valid
path at all but instead what seems to be the location of an included
file. It can have the form "private/..._p.h" for example.

Pick-to: 6.8
Change-Id: I77a2596f6c4a179580d924a6e9324e43dbb86c0c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-10-31 11:49:54 +01:00
Olivier De Cannière 660fc8fb7d QmlCompiler: Rename QQmlJSLogger's fileName to filePath
This is done in prepartion for the following patch in the chain.

Pick-to: 6.8
Change-Id: If8ce75be8ba00e7e4cdd5a0f5e66319ab0d36755
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-10-31 11:49:54 +01:00
Ulf Hermann ae7419479a QmlCompiler: Log double colon if source location missing
This causes the lines logged to be shown in Qt Creator's issues pane.

Fixes: QTCREATORBUG-31526
Change-Id: I2c55d09a779cd4a51df5dda0e4ef894de235f974
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
2024-09-04 23:29:40 +02:00
Fabian Kosmale d77693a028 QQmlSA: Don't expose QQmlJS namespace
QQmlSA is meant as the public namespace, QQmlJS is (at least currently)
completely internal. However, LoggerWarningID currently only existed in
QQmlJS.
Move it into QQmlSA, add some minimal class documentation and add a
typedef in QQmlJS (inside a private header) to avoid the need to modify
all users.

Pick-to: 6.6.0 6.6
Change-Id: Icff860c92054ac810c6e15eb26090d38fbc2c965
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-09-21 00:07:22 +02:00
Thiago Macieira b881ca8f4e Re-workaround the maybe-uninitialized warning from GCC 11+
It's still happening with GCC 13.

My guess is that the includes changed so the disabling wasn't applying.

Amends 067d5a3334.

Pick-to: 6.5 6.6
Change-Id: I80612a7d275c41f1baf0fffd177a234b8fd398e1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-11 10:00:01 -07:00
Ulf Hermann c000ea178b QmlCompiler: Clean up some includes
Change-Id: Ib9ffe5e604ccbdb7e841b28111954e38b862b15a
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-06-06 12:56:37 +02:00
Olivier De Cannière cdd7fe05f6 QQmlSA: Create an abstraction layer for static analysis
This patch adds abstractions for QML Elements, Bindings, Methods and
Properties. This abstraction layer avoids exposing internal details and
should be more suited for static analysis tasks. It is now possible to
write qmllint plugins without including private headers.

As a drive-by, change tst_qmllint:verifyJsRoot to open files in text
mode instead of binary. This fixes an issue where line endings cause
issues on Windows.

Fixes: QTBUG-102276
Change-Id: I6b6e53f1e0078734a18f3aa51807fbe875b375f0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-30 13:42:35 +02:00
Olivier De Cannière d876ce343d QmlCompiler: Simplify isRescricted checks down to only enums
Most checks in isRestricted were redundant. Only those related to enums
seem to be useful. These are kept in the new checkForEnumProblems while
isRestricted is removed.

The error checking in checkForEnumProblems should also provide better
error messages for enum problems.

Pick-to: 6.5
Change-Id: Ic3f3589464ebe519bee8b4c580b2e80d310c937f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-03-22 13:57:24 +01:00
Ulf Hermann aa49d0f2d9 qmllint: Fix attached property re-use detection
Move the detection into the QtQuick lint plugin. It's mostly meant for
QQC, so let's auto-enable it for attached types derived from
QQuickAttachedPropertyPropagator.

To this end, two new categories are introduced: The Quick lint plugin
gets its own attached-property-reuse category which is synonymous to the
default category of the same name. Furthermore, we add a
controls-attached-property-reuse category for only checking controls.
That one is implied by either of the others.

Finally, fix the id vs. scope resolution to actually do something.
This way we can give appropriate hints when the outer type has an ID
already.

Pick-to: 6.5
Fixes: QTBUG-110834
Change-Id: Ib71a9e3bbc10bac77f36db6cc441af88df20fd33
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-02-14 13:32:13 +01:00
Ulf Hermann 403f4117e2 qmllint: Uncruftify FixSuggestion
In this form we can expose it in QQmlSA.

Pick-to: 6.5
Task-number: QTBUG-110834
Change-Id: Ieb0cf31b6e86379c0d80f89bc6c63b129f269798
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-02-08 21:14:39 +01:00