Commit Graph

99 Commits

Author SHA1 Message Date
Sami Shalayel 2bc3f45e82 qmllint: don't search for heuristic context properties
Don't search for heuristic context properties in qmllint, to avoid
making qmllint more complicated from a user perspective. Instead,
qmlcontextpropertydump can be used via its CMake target.

Task-number: QTBUG-128232
Change-Id: Ie7553821e6b62c0a89179e8abee2ac7d15647265
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-08-25 16:10:21 +00:00
Olivier De Cannière 243883ed78 qmllint: Update JSON format to include hints into fix suggestions
Hints are no longer their own fix suggestion but instead are part of an
existing one. This breaks compatibility with the existing format but as
the output is not documented and is versioned this should be ok.

This change will enable having multiple fix suggestions per warning in a
future change.

Pick-to: 6.10
Change-Id: Iedf275507554a2d70399757396e278999874cd53
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-08-20 16:32:38 +02:00
Semih Yavuz e3891d7459 qmltoolings add --dry-run option for qmlformat and qmllint
Add reportConfigForFiles to generic tooling class. It will perform the
search for the given files. Use stdout to report. qmllint had already an
option --dry-run for printing the fixed codes, but we can still allow this to
use that option name.

For qmlls, report the path if verbose option is set.

Fixes: QTBUG-137874
Change-Id: I6bd43866073b3df832b6fd89d477bced869d74c0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-08-14 19:54:37 +02:00
Sami Shalayel 7ded306d74 qmllint: make contextproperties a real class and rename
Prepares for QTBUG-138061 where we need a way to load user-defined
context properties into QQmlJS::ContextProperties.

Rename QQmlJS::ContextProperties into HeuristicContextProperties to
avoid confusions with the UserContextProperties.

Make HeuristicContextProperties a real class so that we can add methods
to load and save context properties to and from disk.

Make the heuristics be saved in a list instead of a QHash, as the order
of the property matters as we write them out into a file and testing
becomes complicated when the order changes between different runs. Also
note that it might be confusing for qmlls users if their warnings change
orders during multiple runs.

Rename some methods for clarity.

Task-number: QTBUG-138061
Task-number: QTBUG-128232
Change-Id: Ib6302f609e182e622015293366c8b42425566a0e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-08-05 17:06:32 +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
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
Fabian Kosmale 87e225300c qmllint: Update help to correctly describe warning behavior
Amends 74ec76d5ed

Pick-to: 6.9 6.8
Change-Id: Ibeeeff03587abaff3853b2983cceb76c8d74dd33
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Albert Astals Cid <aacid@kde.org>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2025-02-18 20:02:01 +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 2529b4515b qmllint: add an "error" logging category
Add support for a critical error category in qmllint called "error",
so that the qds plugin can show errors for unsupported components for
example.

Add a test. The error category makes qmllint return -1.

Simplify a bit the logic of the "success" bool in lintFile() by making
it a LintResult and returning it.

Change-Id: Ide6a6a265f1aeede0fcbc35d9e4d0abe3f5c2aa3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-12-12 18:20:55 +01:00
Olivier De Cannière 63337b80c9 qmllint: Flip back argc and argv in main
For some reason, the argument count is called argv and the argument
values are stored in argc. That should probably be the other way around.

Change-Id: I60361cc6d84cefb9599ea349a40e77c5eaf0c581
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-11-22 14:39:37 +01:00
Sami Shalayel 8e17600786 qmllint: load plugins from the correct paths
Make qmllint load plugins from the same default directories as
QFactoryLoader does, in addition to the extra paths passed by
command line arguments to qmllint. Remove the static helper
method to get the custom qmllint default plugin directories and
use QCoreApplication::libraryPaths() instead.

This allows to ship the qmllint plugins with qmlls's standalone build,
because QCoreApplication::libraryPaths() contains the
current application path and allows a standalone qmlls to load plugins
for linting or completion from a subfolder.

Fix tst_sanity to continue ignoring the warnings from all other plugin
as QQmlJSLinter will load all available default plugins now, like the
Quick plugin for example.

Change-Id: I9edaddb0fd5da27f68da9ceca76a9351fc0c6aee
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-11-13 16:08:08 +00:00
André Klitzing 4f6519eed0 Fix "MaxWarnings" settings in .qmllint.ini
This amends 74ec76d5ed.

Task-number: QTBUG-128221
Pick-to: 6.8
Change-Id: Ia7ccf4212fdca35fb3ecaae8e97bb046765b61ba
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2024-11-08 12:37:49 +01:00
Sami Shalayel 27ee3aa440 qmllint: load plugin categories before parsing arguments
Make sure to load categories from plugins before writing the
settings file, parsing qmllints commandline arguments or
before writing out the help text, so that the
plugin-dependent categories are also present there.

This allows to:
* print plugin categories into the --help text
* write default values for plugins on --write-defaults
* remove buggy warning about plugin categories not existing when
  passing them by commandline

Pick-to: 6.8
Fixes: QTBUG-130358
Change-Id: I282059c78a0379e611914a2df78bb1d3540692c0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-10-25 19:57:42 +02:00
Sami Shalayel 8cae0aeff4 qmlls: follow .qmllint.ini warning configurations
Move the methods used to set the linting category level from
qmllint/main.cpp to qqmljsloggingutils{.cpp,_p.h} so that qmlls can
reuse them to follow .qmllint.ini warning configuration files.

Also add early returns to the code of updateLogLevels.

Pick-to: 6.8 6.7
Fixes: QTBUG-127602
Change-Id: I12919226c340a2c7a16aac6cd319ca2483611530
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-08-01 13:23:43 +02:00
Fabian Kosmale 74ec76d5ed qmllint: don't set error exit code if there are warnings
[ChangeLog][qmllint][Important Behavior Change] qmllint no longer exits
with an error code if there are warnings by default. Actual errors will
still cause the exit code to be set.

[ChangeLog][qmllint] qmllint now accepts a max-warning flag. When set,
it will set an error exit code if there are more warnings than
specified.

Pick-to: 6.8
Fixes: QTBUG-115856
Change-Id: I88810795a494ba249b0b39fd7f245229b1f0c959
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2024-06-17 17:35:59 +02:00
Ulf Hermann 9b78434579 qmlcompiler: Sanitize qmldir paths before using them
They may contain backslashes.

Pick-to: 6.7 6.5
Fixes: QTBUG-125393
Change-Id: Ifd8c97c44b036ab64a221775a7fe6316445f6cf8
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-05-17 17:34:33 +02:00
Sami Shalayel f1051cb482 qmllint: enable environment variables like QML_IMPORT_PATH via -E
Add a -E commandline option for qmllint to enable using environment
variables. For now, this only allows using QML_IMPORT_PATH and
QML2_IMPORT_PATH to pass import paths to qmllint.

Task-number: QTBUG-114969
Change-Id: Ie6baf9c8035703a456ba1e7e575ba424f89d287a
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2024-04-18 11:39:16 +02:00
Sami Shalayel 7f2f329dcd qmllint: do not ignore command line options with --ignore-settings
Remove a misplaced pair of braces that made --ignore-settings ignore the
parsing of command line options like "-I", "-E" and "--bare".

Do not populate the settings from a settings file when --ignore-settings
is set to make QQmlToolingSettings::isSet() always return false.

Discovered while working on QTBUG-114969.

Pick-to: 6.7 6.6 6.5
Task-number: QTBUG-114969
Change-Id: Ia8719b33af4a2ebdcb2b81194e0c028164775327
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
2024-04-17 12:27:35 +02:00
Giuseppe D'Angelo 50b9979f89 QML Tools: add some checks for QFile::open failures
Change-Id: Ic95509efbd7ce33d6e98a52eef3dd319cd328306
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2024-03-26 21:33:04 +01:00
Ulf Hermann 7fae7bf04a qmllint: With --bare do not use the current directory
That's what --bare promises after all.

Pick-to: 6.7 6.6 6.5
Fixes: QTBUG-115478
Change-Id: Iae7563203709bc28b7bcaa0da68cad1826c035d9
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2024-02-23 10:11:42 +01:00
Alexandru Croitor da1741d4c8 qmllint: Add response file support
Adapt CMake code to use a response file instead of a long string of
arguments when calling the various qmllint targets.

Avoids long command line errors on Windows.

Pick-to: 6.5 6.6 6.7
Fixes: QTBUG-119675
Change-Id: I49041ffff2724fb36b8127b2a08127a9b740db7d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-12-14 12:28:13 +01: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
Sami Shalayel 3a985babf9 qmlls: move into own private static library
Qmlls was completely implemented in the ./tools directory, which made
its code complicated to test and try out. Also, it required some "dirty"
hacks in the actual tests (including files from others targets to be
able to use them) and made testing new features for qmlls more
complicated.

To remedy this, the qmlls code was split into a tool (qmlls) and
a static library (QmlLSPrivate). The tool only contains
tools/qmlls/qmllanguageservertool.cpp (which has the qmlls main method)
and links to QmlLSPrivate, that contains all the other qmlls-related
code. This way, the tests can also link to QmlLSPrivate and test out
individual functions there without needing to include files from other
targets.

Also rename all the files to make syncqt happy (adding "_p" to headers
and prepending "q" to headers and files and includeguards), and use
QString::fromUtf8() to silence the QString()-constructor deprecation
warnings.

On the way, move tools/shared/qqmltoolingsettings.* into its own private
static library, instead of recompiling it for each tool that requires
it. Move the qqmltoolingsettings stuff into the qt namespace to be
usable.

Also, add qmlls as a dependency to the qmlls tests to avoid testing an
outdated qmlls-binary.

This commit prepares qmlls's code to implement the go-to and
find-usages features.

Task-number: QTBUG-109006
Change-Id: I91eed689c68a0c53fb88006de335b0f852cc1a83
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-02-07 19:23:13 +01:00
Ulf Hermann 5c594515f6 qmllint: Provide import paths and resource files when linting modules
Those are just as important for modules as for single files.

Pick-to: 6.5
Change-Id: I201d62c61988abc2dfba6300a1cfc355203fec75
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-02-07 19:23:12 +01:00
Ulf Hermann ddba87612d QML: Turn singleton/type mismatch into a run time type error
There are many ways to "hide" the qmldir from the engine at run time,
which turns singletons into regular types. While all of this is invalid,
we should not assert on it, but rather produce a legible warning.

Furthermore, sharpen the importing of extra modules from qrc as implicit
imports. We should really only import modules the file in question can
ever be part of. Otherwise we needlessly produce the above situation and
hide legitimate warning messages.

Amends commit 7517c1b3ae.

Now we need to teach our tools about the default import paths in the
resorurce file system. They cannot guess any type they may find in any
resource file anymore.

Pick-to: 6.5
Task-number: QTBUG-106929
Change-Id: Ic8c02396d10830a7f461e8a81649bb8c9a1add1f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-01-27 10:42:06 +01:00
Sami Shalayel e11c1eda4f qmllint: document new behavior of --json
Amends 5c04d17428.
The behavior of qmllint changed in the above-mentioned commit, as it
started expecting a file argument for the --json option. Before, it was
not expecting any and always writing to stdout.

Document the new behavior in the docs and in the --help command,
especially the part about using '-' to restore the old behavior.

Fixes: QTBUG-108913
Pick-to: 6.4
Change-Id: I3a69a794a5362a575437d3d832d6e038c7a0755a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-28 10:49:23 +01:00
Ivan Solovev 309e2e864f QtDeclarative: port away from deprecated qSetGlobalQHashSeed(0)
Use QHashSeed::setDeterministicGlobalSeed() instead

Task-number: QTBUG-105102
Change-Id: I1d13f3872b335ff9998f7c4538d3b9c3c77fe232
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-08-29 20:48:09 +02:00
Maximilian Goldstein 34d52f8b2c qmllint: Implement module linting
This change allows for modules to be linted via the -M flag.
This will check whether an individual module has a sound qmldir and
qmltypes. It will also verify whether all its types and the types of
properties can be resolved.

It does not lint individual QML files.

[ChangeLog][qmllint][New Feature] Individual modules can now be linted
via the -M option

Fixes: QTBUG-103264
Change-Id: I3ced4b0bc05358e9216c9819f1dca67af909405e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-07-25 12:26:06 +02:00
Maximilian Goldstein a9038a6cc6 QQmlJSLogger: Switch to an ID based system
This change makes qmljslogger use an ID based system for categorizing
logging entries instead of using an enum. This allows plugins to
register their own logging categories after the fact.

It's also necessary for us to later show the warning ID when
printing warnings and for creating documentation for each ID entry.

Currently not every ID maps cleanly to only one type of warning,
this has to be cleaned up in a follow-up change.

Task-number: QTBUG-103453
Change-Id: I4cac6be7ca165b938e0ea032d077823bf17baf75
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-30 11:23:36 +02:00
Lucie Gérard 0dc4fd240a Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.

Pick-to: 6.4
Task-number: QTBUG-67283
Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-06-11 08:05:15 +02:00
Sona Kurazyan 2c9c1590e6 Replace uses of deprecated _qs with _s/QStringLiteral
Task-number: QTBUG-101408
Change-Id: Ic925751b73f52d8fa5add5cacc52d6dd6ea2dc27
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-04-29 09:47:43 +02:00
Maximilian Goldstein 756b54bd83 qmllint: Show whether a plugin is built-in or not
Display whether a plugin is built-in or not when listing them via
--list-plugins.

Fixes: QTBUG-102419
Change-Id: I2b2dc40933402ec9e4a1dd6153971e4371ef76e8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2022-04-26 12:36:58 +02:00
Maximilian Goldstein 1552b00d1e qmllint: Add option to disable individual plugins
Adds a command line option and settings entry in order to
disable individual plugins. Previously you could only
disable all of them.

Fixes: QTBUG-102420
Change-Id: I5a35093c32f5f86eef1e31dd42b77c95e38bb01f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-21 21:04:01 +02:00
Maximilian Goldstein 5c04d17428 CMake: Add _qmllint_json target
Adds an additional _qmllint_json target for use in CI settings and a
all_qmllint_json target to run all of them.

Since the output of ninja sub-commands can not be directly processed by
piping it into a script, the output of the qmllint command is instead
written to ${target}_qmllint.json.

[ChangeLog][qmllint][Important Behavior Changes] The --json option now has
a mandatory file argument and writes its output there. You may also pass
"-" to write it to stdout.

Fixes: QTBUG-95157
Change-Id: I3806c4113235d3aa06d3b3310e1cc7b0171b3eca
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-11 14:12:09 +02:00
Maximilian Goldstein 324b625f9f Turn the QtQuick qmllint plugin into a proper shared library
Previously it was just a static library that we linked qmllint against
now it's properly installed in the qmllint plugins folder and can be
utilized in the language server as well.

Fixes: QTBUG-102278
Change-Id: I4aec42d1e2ba113237ee5ba148085e69b7251506
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-11 14:12:09 +02:00
Maximilian Goldstein 55c7f1ad13 qmllint: Implement QtQuick plugin
This plugin is meant to contain all the linting logic that is specific
to QtQuick. For now it only contains a pass that verifies that layout
items don't use anchors.

Original-patch-by: Fabian Kosmale <fabian.kosmale@qt.io>
Change-Id: Ie75351442596c9c42ae05ab11b3156eff4e56ad5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2022-04-05 14:06:59 +02:00
Maximilian Goldstein 7c9276d38b qmllint: Integrate plugin infrastructure
Integrates the plugin and pass infrastructure into qmlcompiler and qmllint proper.
Plugins are searched for in the "qmllint" subfolder of the Qt installation's plugin
directory. In addition we also support loading statically linked plugins.

[ChangeLog][qmllint][New Feature] qmllint can now be extended via plugins. Use --plugins
to get a list of available plugins.

Original-patch-by: Fabian Kosmale <fabian.kosmale@qt.io>
Change-Id: I75a09dd978fc7724aca4931f055cc71c7ced971b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-05 14:06:56 +02:00
Maximilian Goldstein 5a57bd47fb qmllint: Fix broken argument help entries
The fix and dry-run argument had broken help entries, this change fixes
this issue.

Change-Id: I744592e610f3d9941a2a54e4153cb2a92fbe9f1b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-03-22 21:53:20 +01:00
Maximilian Goldstein a398e06c61 qmllint: Support automatically applying suggestions
We now support automatically applying fix suggestions that don't
need any additional user input. This allows us to automatically
solve issues such as unqualified access and multiline strings.

[ChangeLog][qmllint][New Feature] Added the ability to automatically
fix some warnings, use -f to automatically fix your files or add
--dry-run to see what changes would be made first.

Change-Id: I2dc7587137d74267f60c08bb94a035f1a85a62b1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-14 09:43:15 +01:00
Maximilian Goldstein 07917626f5 qmlcompiler: Remove qmllint library
Since all of the superfluous components of qmllint have been
removed now, we can just move what little custom linter logic
remains to qmlcompiler.

Change-Id: I91c752cb895e7d6c6f2dd4e2ccafb6cd05afa225
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-03 22:55:53 +01:00
Fabian Kosmale fdc2608c31 tools: Unconditionally depend on QCommandLineParser
qmllint's utility is rather limited when we can pass it neither the
qmldir nor qmltypes files. Instead of trying to somehow handle the case
with ifdefs, move the feature check into the build system and
completely disable the tool if we lack the parser.
The same holds for qmltc, which is already completely unusable without
the parser (and just prints an error message if build without the
feature enabled).

Change-Id: I31828bb7d551caeaffd1974d1dff14a25446ce95
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-01-24 13:25:13 +01:00
Maximilian Goldstein f19582f630 qmllint: Enable compiler warnings for pragma Strict
If a file sets pragma Strict, it expects to be fully compiler
compliant, so let's enable the warnings for that by default.

Fixes: QTBUG-97081
Change-Id: I0b388f64d99846ee0c03e24397b3a997d4b0173b
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-01-17 12:35:54 +01:00
Ulf Hermann 576fafd1e6 Pass qmldir to qmlcachegen, qmllint and qmltc, not the qmltypes file
The tools will still grudgingly accept qmltypes files being passed via
the -i option. We generally expect qmldir files, though. Ignoring the
qmldir file and importing the qmltypes directly, ignores qmldir imports,
dependencies and other component entries. This leads to unresolvable
types.

[ChangeLog][QML Tooling] qmllint expects qmldir files, not qmltypes
files to be passed via the -i option now. This enables it to see the
imports and dependencies of the module being imported. For backwards
compatibility it still accepts qmltypes files, with a warning.

Pick-to: 6.3
Fixes: QTBUG-99043
Change-Id: I5ed32d7e78df1e604aaf1bfa2ebda09d5d57b628
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-13 11:51:13 +00:00
Maximilian Goldstein 52c09a27ef qmllint: Use fix suggestions in a more structured way
Fix suggestions are now attached to the warnings they are caused by
and are also accessible via JSON.

This allows us to use the qmllint library for more of tst_qmllint,
greatly improving performance.

Change-Id: Idd0398028bff1272a75dc1193d2c15a25d335dbf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-10 17:11:05 +01:00
Ulf Hermann 0b175cb865 qmllint: Fix diagnostics output for test run
We do want to see the output if the cleanQmlCode test fails.

Change-Id: I6b7e9d3412af9fffac68d2e394418de2faf09626
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2021-12-07 16:01:02 +01:00
Maximilian Goldstein ff8139d23c qmllint: Expand qmllint library API
The API now allows for specifying the file contents yourself for either
on-the-fly editing or if you have your own caching scheme.
It's now also possible to access the logger directly in order to read
diagnostic messages instead of structured JSON output.

Change-Id: I4eb8440c7b25068cd09f28a5f3cbd0a318774522
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-11-25 10:03:46 +01:00
Maximilian Goldstein a98747ab6c qmllint: Move most code into a separate library
This is necessary step for both making qmllint viable for use in
controls' tst_sanity, as well as for integration with the
language server.

As an additional upside it allows us to run our tests up to 10x faster.

Eventually we want to integrate all of this into qmlcompiler but due
to the state of some of the code we will keep qmllint in a separate
library as to keep qmlcompiler tidier.

Change-Id: Ic057ef0cd4424d28aa05e517d74280a442ec9c5a
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-11-23 18:45:06 +01:00
Maximilian Goldstein edeaf70d9a qmllint: Fix typo in app description
Disabling uses the keyword "disable" not "disabled".
Fixed in this change.

Pick-to: 6.2
Change-Id: I544a543043627121a11ca3ab56ad3d967707efb6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-19 12:35:34 +01:00
Maximilian Goldstein 2248ee16e0 qmllint: Add option for logging absolute paths
Some IDEs might want to parse qmllints logging messages directly instead
of using the structured JSON output.

For these a hidden --absolute-path option has been introduced so the
messages can more easily be mapped to the actual files.

Task-number: QTCREATORBUG-17224
Change-Id: I23c4272a45adcb2bf7aeb6ae7b130839b9f05b72
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-17 20:59:23 +01:00
Kai Köhne d17a49a5c5 Explicitly include qloggingcategory.h
Do not rely on QLoggingCategory being implicitly declared through
other headers.

Pick-to: 6.2
Change-Id: Ib6cda43f281d31a7127dd591be2540fb00a0a699
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2021-11-15 15:38:11 +01:00