Previously some settings were only checked before any settings file
could be loaded, thus resulting in misapplied settings.
Now every settings option will be applied on a per-file basis as it
should be.
Pick-to: 6.2
Change-Id: Ib7c8a8d7dbec2d4379f634488e3899e1746c0c51
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Previously builtins not being found would lead to an endless loop that
crashes qmllint. Now missing builtins are handled gracefully,
aborting linting without crashing as this an unrecoverable error.
Change-Id: Ia585b1e0e5c972dad0eeabf8df06edf71eaea0c7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
We want it to be mutable even where Codegen itself is const. Therefore,
it needs to live outside Codegen.
Change-Id: Ie4997118a1fdf8d60bd5670baa506ed0bfb98bad
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
This puts them right below the description of warning levels and hopefully makes the whole help easier to read.
Task-number: QTBUG-95971
Change-Id: Iff6062e700c2c277fc4c69a8130ba6b2dd5e35c0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
QQmlImportVisitor was accepting ctor paratemeters for the QQmlJSLogger,
creating own logger internally. This seems wrong since in that case we
kind of have separate logger for visitor and type resolver (among other
entities)
On top of this, the import visitor had a silent logging by default
(and the QQmlJSLogger is not silent on the contrary) which in fact hid
some issues that should've been reported by qmllint (but they weren't)
For consistency, the silent logger is still used. And the ultimate fix
would be to use FindWarningsVisitor instead of QQmlJSImportVisitor
as currently we do 2 AST traversals in qmllint
Change-Id: I4c54b76d130e7e8f31c90a148edc1c02f7e86ab8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Another step to making checkidentifiers obsolete.
Change-Id: I14be7491387200101b66e0930faf16e9b61d4159
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Do not rely on checkidentifiers to provide unqualified access warnings anymore. Using the type propagator ought to be more accurate and will help remove the relatively hacky checkidentifiers code completely later on.
Change-Id: I40cc040b9455962abbd2ec84cdb494fcec1ab79d
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
In order to properly integrate the type propagator into qmllint we need to use the logging system instead of qWarning().
Change-Id: Ie9840066f8afa3d7f8a63a69444b6dc20c41a706
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This change helps bring in type inference and compiler warnings previously only generated by qmlcachegen+.
These warnings are disabled by default and have to be enabled manually via the --compiler option.
Also makes the logger handle zero length SourceLocations properly by just highlighting the entire line instead of hitting an assert.
Change-Id: Iebad6e9236214d9367f97487e7b5787592edab7d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
In order to use the source tree files, qmllint needs to know where they
will end up in the resource system. The source files could be at any
arbitrary location and have their resource path set by a
QT_RESOURCE_ALIAS source file property. Therefore, we have to give the
generated .qrc files to qmllint so it can work out where each source
file will end up.
The qmllint command previously only supported a single --resource
option, but now we need to potentially pass more than one .qrc file.
Extend qmllint to allow multiple --resource options to be given, in
the same way that multiple -I options can be given.
Task-number: QTBUG-94761
Pick-to: 6.2
Change-Id: Ibeb6541e1f54bea6eeeccd07426dd238b0459ff2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
qmllint now supports logging levels of different severities. Still lacking a good way to toggle the verbosity more granularly though (i.e. disabling only info messages while still receiving the rest).
Change-Id: I71abddcdf1adf60315a87d776af8085acf7aeffe
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
We kept these around for compatibility in Qt 6.2 but now it's time to get rid off them
[ChangeLog][QtQuick][qmllint] The deprecated --no-[category] options from Qt 6.1 are now fully removed, use the new style of options as outlined in --help.
Change-Id: Ie564a8262fdefa2685fe86b59b46dc3aa25d4958
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
We shouldn't keep advertising options we're deprecating anyway, just warn when they are still passed to qmllint.
Change-Id: Ibe53c51fc473719d021f912243921b6511ebd2f4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Use the Qt version instead of 1.0. Especially important since qmllint allows for mixing and matching the tool with other Qt versions.
Change-Id: Ib485578f93d8e61f2aa76bb610c3fd87ed71cd60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Allows users to ignore individual warnings by adding a "// qmllint disable" comment in the line that triggers the warning.
This feature is especially useful for use in pre-commit / CI tests as it allows to add exceptions for individual warnings that cannot be fixed immediately.
[ChangeLog][qmllint][New Feature] You can now ignore individual warnings by adding "// qmllint disable"
in the line causing it. You may also specify one or more warning type to ignore ("// qmllint disable warningtype1 warningtype2...") which is preferable. This can also be done for entire blocks of code by using "// qmllint disable" in an empty line and ending it with "// qmllint enable"
Change-Id: Iea6c29132d6b51ecfb5e5d8a19a43446a7286c24
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Adds the ability to output warnings as JSON, one line per file.
This makes it way easier to process qmllint warnings for use in CI tooling or IDEs.
[ChangeLog][QtQml][qmllint] Add the ability to output warnings as JSON for use in tooling.
Change-Id: Iecd48e123859aa939bd9753cb8f6e44d4d7e3667
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This change adds support for a reading a simple settings file (.qmllint.ini) to set log levels and various other options.
The settings file applies on a per-directory basis so linting files in two subdirectories with different settings will use their respective settings files.
If the directory of the linted file does not contain any settings we search through all parent directories.
This is implemented in a way that qmlformat can also utilize the settings file code.
This makes qmllint more useful for larger projects that might want different settings for different parts of their QML code.
It also allows for better integration in CI checks and pre-commit hooks.
[ChangeLog][General][qmllint] Adds the ability to set linting options via a settings file rather than using command line parameters. Use --write-defaults to generate a template with default values for editing. Use --ignore-settings to disable this feature
Change-Id: I94e4a47916b5dfd16c3a69efdba3858235cab738
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Previously we only cached processed qmldirs, now we cache full modules and dependencies.
This leads to manyfold speed increase (10 times in my tests) when lots of files are linted in one invocation of qmllint and those files have a lot of imports with shared dependencies.
Change-Id: Ifcd1eb9d620ca7a18c0a3d6395fbb6d003472dab
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Add the ability to individually disable and set the severity of all warnings produced by qmllint.
Change-Id: I46081f8b37fb90f8d0f4a5f2f08223d7b7285041
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Improves the logging situation greatly by allowing all logging messages to be assigned different severities,
highlighting the code that caused them and by now ensuring a qmllint warning will always result in a non-zero exit code.
A later patch will expose more of these options to the user.
Change-Id: Id9b036fe3ba80dd18e9f8cb1b05efa891713d5a8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Previously specifying any additional QML import directories would lead to the default directories to be excluded.
This can be useful if you want to run qmllint on a project using a different Qt version but
this is not behavior you want in most cases.
[ChangeLog][qmllint][Important Behavior Change] Using -I no longer excludes default QML import directories.
Use --bare to get the old behavior.
Change-Id: I2ca5789cd44306bcad54f7b1b82049c21f721d3d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
If a file is part of the resource file system, the implicit directory is
also in the resource file system. We can use QQmlJSResourceFileMapper to
figure this out.
Change-Id: I48d86c308c7ec38d9971b84e7f059daa3baf63ee
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
The "2" is meaningless and there is a better name available now.
Task-number: QTBUG-85064
Change-Id: I65d26b06712ed7dcf2825f16dffaa6060dd86985
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
They are both pretty much doing the same thing, except that the import
visitor is not as thorough. We need the full analysis in QtQmlCompiler,
so we successively move the code over.
Change-Id: If7fb47f88165fd8b61f4ccc408ccfbb7dad533e6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
builtins.qmltypes are imported separately now. Any other bare qmltypes
files without qmldir should be specified explicitly. If none are
specified, qmllint looks in the current directory for qmltypes files,
not in all possible import paths. This is still somewhat weird, but
admittedly it's handy for qmltypes files generated for application
binaries. For the same reason, we unconditionally include the current
directory in the list of default import paths. Previously this was done
if no explicit qmltypes files were specified, which makes little sense.
Change-Id: Iaa56f8b40b3ec3045f55928251d7efea5616d23b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Replace QLibaryInfo::location with QLibraryInfo::path, and remove usage of
Qt::AA_EnableHighDpiScaling, which doesn't have any effect anymore.
Change-Id: I347e8a83e0f4c2b4405f2512e569ad3234f05a98
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Enables all warnings by default and makes it possible to toggle
individual ones using command line flags.
Change-Id: Ie55f32f646fd9422313977969f9f00b59ee9ad99
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Due to the fact that multiple targets may be present in the same
directory we have to ensure they all get a unique qmltypes.
Fixes: QTBUG-82710
Change-Id: I4d7966035644b68f7d3330a4c974369503c48bf2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This is needed in a few places outside of declarative, so this change
restores the loc member in DiagnosticMessage and moves
QQmlJS::AST::SourceLocation into common's QQmlJS namespace/directory.
QQmlError is unaffected and retains only line/column.
Amends d4d197d062
Change-Id: Ifb9d344228e3c6e9e26fc4fe112686f9336ea2b2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
qmllint needed to be refactored before we can add any new functionality:
* Fix all the (C++) linter warnings
* Remove pointless namespaces
* Merge ScopeTree and FakeMetaObject into one class
* Remove the "Fake" from class and variable names
* Remove dead code
* Add "We mean it" warnings everywhere
* Unify #include style
This also "accidentally" fixes the automatic matching of signal handlers
in Connections elements to signals in their parent scopes.
Change-Id: Idf8daae34dfd6c0ee00da28b017f921da3eba25c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This makes it possible to resolve components which were either directly
registered in the application or specified as composite types in qmldir
files.
Change-Id: I42482563f31ac780d6b37e62375d09d122c4a308
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
The linter has gained a new option (-U/--check-unqualified).
If run with this option, it warns about occurrences of unqualified identifiers.
Furthermore, it attempts to detect the reason for why the identifier can be
used unqalified:
- If the id originates from the root element, it suggests to qualify the
access either with the root element's id, or with "parent" if applicable.
- If the id is the parameter of a signal, it suggests to use functions in the
handler, instead of relying on the signal parameters to be "magically"
injected into scope.
The linter does not attempt to handle with statements, but warns the
user instead that they are a bad idea.
Change-Id: I9aaf28c37595d84886a1071d49b86799b222a617
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
We only need two classes to describe all possible diagnostics:
* A low-level private POD DiagnosticMessage. This is easily copied and
passed around internally. It doesn't need to adhere to a stable API
and it doesn't carry any extra baggage.
* The high-level public QQmlError with its stable interface. This can
internally also use a DiagnosticMessage as storage.
Change-Id: I52be88d9b5d9855a661b8032b01eedb43a0fb0b3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
The static part can be used for compilation and won't resolve managed
objects. This allows us to remove all the remaining V4_BOOTSTRAP.
Change-Id: Id2f6feb64c48beb2a407697881aea8c0d791a532
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some
exceptions, see
http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/
Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one
(in those files which will be under GPL 3 with exceptions)
Change-Id: I04760a0801837cfc516d1c7c02d4f503f6bb70b6
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
For .pragmas we removed them explicitly but the correct fix is to
not use "qmlMode" when setting code in the lexer.
Change-Id: I6ffc0ca9e7ebab09fbf91e647d292ff0a3a1fd7d
Task-number: QTBUG-45916
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
This is a cleaner separation and further reduces include dependencies
in the definitions of our basic data structured.
Change-Id: I18aa86cdea0c0dfbc16075d4d617af97e638811e
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Qt copyrights are now in The Qt Company, so we could update the source
code headers accordingly. In the same go we should also fix the links to
point to qt.io.
Change-Id: I61120571787870c0ed17066afb31779b1e6e30e9
Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
A command line program that returns 0 if a .qml file is syntactically
correct.
Ideal to integrate into continuous integration systems.
[ChangeLog][QtQml] Added QML linter tool.
Change-Id: Id420159298e9d2390acd870fee9cf1c3d08e2dec
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>