aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2026-09-10 10:59:33 +0200
committerSami Shalayel <sami.shalayel@qt.io>2026-09-16 13:24:53 +0000
commite71da1f0fe4ffd572dd50df94b2d8410a7587f1e (patch)
treec2e92d51f27fd3fe44bf9baa26be7a15638a2ee2
parent928e4d00129e727d6954a3af0306fb54ffcd10a0 (diff)
qmllint: complain on disrespected max warnings
Make qmllint warn when MaxWarnings is not respected. This should help spot the current number of warnings more easily when trying to set MaxWarnings to an initial value on a QML project with QML warnings. Make the new max-warnings-exceeded warning category an Error so that qmllint returns a non-zero exit code when exceeding MaxWarnings, an remove the custom logic in qmllint/main.cpp that set success to false. The new category is Essential so that users can't downgrade it via commandline or settings files. Note that qmllint can override MaxWarnings from the settings file with its command-line parameter, while qmlls only accepts MaxWarnings from the settings file. Fixes: QTBUG-150177 Change-Id: Ia5e9e360d5fa495d9cf80f48e4074dddf161bdd4 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
-rw-r--r--src/qml/CMakeLists.txt1
-rw-r--r--src/qml/doc/snippets/qmllint/config.ini1
-rw-r--r--src/qml/doc/src/qmllint/max-warnings-exceeded.qdoc32
-rw-r--r--src/qmlcompiler/qqmljslogger.cpp2
-rw-r--r--src/qmlcompiler/qqmljsloggingutils.h1
-rw-r--r--src/qmllint/qqmljslinter.cpp25
-rw-r--r--src/qmllint/qqmljslinter_p.h9
-rw-r--r--src/qmllint/qqmllintsettings.cpp10
-rw-r--r--src/qmllint/qqmllintsettings_p.h3
-rw-r--r--src/qmlls/qqmllintsuggestions.cpp6
-rw-r--r--src/qmltc/qqmltcvisitor.cpp1
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp40
-rw-r--r--tests/auto/quickcontrols/sanity/tst_sanity.cpp4
-rw-r--r--tests/benchmarks/qml/qmllint/tst_qmllint_benchmark.cpp2
-rw-r--r--tools/qmllint/main.cpp40
15 files changed, 124 insertions, 53 deletions
diff --git a/src/qml/CMakeLists.txt b/src/qml/CMakeLists.txt
index b0250d7e21..e2e80994d6 100644
--- a/src/qml/CMakeLists.txt
+++ b/src/qml/CMakeLists.txt
@@ -861,6 +861,7 @@ target_sources(Qml
doc/src/qmllint/attached-property-reuse.qdoc
doc/src/qmllint/compiler.qdoc
doc/src/qmllint/deferred-property-id.qdoc
+ doc/src/qmllint/max-warnings-exceeded.qdoc
doc/src/external-resources.qdoc
doc/src/qmllanguageref/modules/cmake-module-integration.qdoc
doc/src/qmllanguageref/modules/cppplugins.qdoc
diff --git a/src/qml/doc/snippets/qmllint/config.ini b/src/qml/doc/snippets/qmllint/config.ini
index 98ed48cca4..27cb1dbc5e 100644
--- a/src/qml/doc/snippets/qmllint/config.ini
+++ b/src/qml/doc/snippets/qmllint/config.ini
@@ -32,6 +32,7 @@ InheritanceCycle=warning
InvalidLintDirective=warning
LintPluginWarnings=disable
LiteralConstructor=warning
+MaxWarningsExceeded=error
MissingEnumEntry=warning
MissingProperty=warning
MissingType=warning
diff --git a/src/qml/doc/src/qmllint/max-warnings-exceeded.qdoc b/src/qml/doc/src/qmllint/max-warnings-exceeded.qdoc
new file mode 100644
index 0000000000..8dd389a0b5
--- /dev/null
+++ b/src/qml/doc/src/qmllint/max-warnings-exceeded.qdoc
@@ -0,0 +1,32 @@
+// Copyright (C) 2026 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+\page qmllint-warnings-and-errors-max-warnings-exceeded.html
+\ingroup qmllint-warnings-and-errors
+
+\title Max warnings exceeded
+\brief [max-warnings-exceeded] A regression on qmllint warnings was detected.
+
+\qmllintwarningcategory max-warnings-exceeded
+
+\section1 Amount of warnings exceeded the limit set by MaxWarnings
+
+\section2 What happened?
+The number of qmllint warnings on a QML file exceeded the threshold set via the
+\c MaxWarnings value in the \l {qmllint#Settings}{qmllint settings file}.
+
+\section2 Why is that bad?
+\c MaxWarnings can be set to control or forbid the introduction of non-clean QML
+code to ensure a certain level of QML code quality. Introducing new qmllint
+warnings in a project decreases the code quality of the project.
+
+To fix this warning,
+\list
+\li Fix the new warnings to decrease the number of total warnings back to the
+ configured threshold.
+\li Increase the number of allowed max warnings via the \l {qmllint#Settings}
+ {qmllint settings file} if fixing the new warnings is not feasible.
+\endlist
+
+*/
diff --git a/src/qmlcompiler/qqmljslogger.cpp b/src/qmlcompiler/qqmljslogger.cpp
index e4430d5f00..09dd298208 100644
--- a/src/qmlcompiler/qqmljslogger.cpp
+++ b/src/qmlcompiler/qqmljslogger.cpp
@@ -115,6 +115,8 @@ warning levels.
X(qmlLiteralConstructor, "literal-constructor", "LiteralConstructor", \
"Warn about using literal constructors, like Boolean or String for example.", Warning, \
NonEssential) \
+ X(qmlMaxWarningsExceeded, "max-warnings-exceeded", "MaxWarningsExceeded", \
+ "Warn when exceeding the allowed maximum number of warnings.", Error, Essential) \
X(qmlMissingEnumEntry, "missing-enum-entry", "MissingEnumEntry", \
"Warn about using missing enum values.", Warning, NonEssential) \
X(qmlMissingProperty, "missing-property", "MissingProperty", "Warn about missing properties", \
diff --git a/src/qmlcompiler/qqmljsloggingutils.h b/src/qmlcompiler/qqmljsloggingutils.h
index bcc44afd6b..bbe9fc6d5a 100644
--- a/src/qmlcompiler/qqmljsloggingutils.h
+++ b/src/qmlcompiler/qqmljsloggingutils.h
@@ -84,6 +84,7 @@ extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlInheritanceCycle;
extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlInlineComponentEnums;
extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlInvalidLintDirective;
extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlLiteralConstructor;
+extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlMaxWarningsExceeded;
extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlMissingEnumEntry;
extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlMissingProperty;
extern const Q_QMLCOMPILER_EXPORT QQmlSA::LoggerWarningId qmlMissingType;
diff --git a/src/qmllint/qqmljslinter.cpp b/src/qmllint/qqmljslinter.cpp
index 548de7871e..69af1d9dda 100644
--- a/src/qmllint/qqmljslinter.cpp
+++ b/src/qmllint/qqmljslinter.cpp
@@ -544,7 +544,8 @@ bool QQmlJSLinter::prepareFileForBatchLinting(const QString &dirtyFilename,
const QStringList &qmlImportPaths,
const QStringList &qmldirFiles,
const QStringList &resourceFiles,
- const QList<QQmlJS::LoggerCategory> &categories)
+ const QList<QQmlJS::LoggerCategory> &categories,
+ qsizetype maxWarnings)
{
QFileInfo info(dirtyFilename);
const QString filenameFromUser =
@@ -556,6 +557,7 @@ bool QQmlJSLinter::prepareFileForBatchLinting(const QString &dirtyFilename,
lintInfo.qmlImportPaths = qmlImportPaths;
lintInfo.qmldirFiles = qmldirFiles;
lintInfo.categories = categories;
+ lintInfo.maxWarnings = maxWarnings;
const QString lowerSuffix = info.suffix().toLower();
lintInfo.isESModule = lowerSuffix == QLatin1String("mjs");
@@ -757,6 +759,17 @@ void QQmlJSLinter::typeReader(const QString &filename)
parser.rootNode()->accept(&*lintInfo.visitor);
}
+static void checkMaxWarnings(QQmlJSLogger *logger, qsizetype maxWarnings)
+{
+ const qsizetype warnings = logger->numWarnings();
+ if (maxWarnings != -1 && maxWarnings < warnings) {
+ logger->log("Amount of warnings exceeded the limit set by MaxWarnings.\n"
+ "Current limit: %1\nFound warnings: %2"_L1.arg(QString::number(maxWarnings),
+ QString::number(warnings)),
+ qmlMaxWarningsExceeded, QQmlJS::SourceLocation(0, 0, 1, 1), false);
+ }
+}
+
void QQmlJSLinter::lintFileImpl(const QString &filename)
{
Q_ASSERT(m_lintInfo.count(filename) == 1);
@@ -855,14 +868,16 @@ void QQmlJSLinter::lintFileImpl(const QString &filename)
lintInfo.result.logger->processMessages(globalWarnings, qmlImport);
}
+ checkMaxWarnings(lintInfo.result.logger.get(), lintInfo.maxWarnings);
lintInfo.result.setStatusFromLogger();
}
QQmlJSLinter::Result QQmlJSLinter::lintModule(const QString &module, LintOptions options,
const QStringList &qmlImportPaths,
- const QStringList &resourceFiles)
+ const QStringList &resourceFiles,
+ qsizetype maxWarnings)
{
- Result lintResult = lintModuleImpl(module, options, qmlImportPaths, resourceFiles);
+ Result lintResult = lintModuleImpl(module, options, qmlImportPaths, resourceFiles, maxWarnings);
if (!options.testFlag(GenerateJson))
return lintResult;
@@ -878,7 +893,8 @@ QQmlJSLinter::Result QQmlJSLinter::lintModule(const QString &module, LintOptions
QQmlJSLinter::Result QQmlJSLinter::lintModuleImpl(const QString &module, LintOptions options,
const QStringList &qmlImportPaths,
- const QStringList &resourceFiles)
+ const QStringList &resourceFiles,
+ qsizetype maxWarnings)
{
Result result;
result.logger = std::make_unique<QQmlJSLogger>();
@@ -1021,6 +1037,7 @@ QQmlJSLinter::Result QQmlJSLinter::lintModuleImpl(const QString &module, LintOpt
result.logger->log(message, qmlUnresolvedType, QQmlJS::SourceLocation());
}
+ checkMaxWarnings(result.logger.get(), maxWarnings);
result.status = (result.logger->hasWarnings() || result.logger->hasErrors()) ? HasWarnings
: LintSuccess;
return result;
diff --git a/src/qmllint/qqmljslinter_p.h b/src/qmllint/qqmljslinter_p.h
index 843090faee..ac87fb696e 100644
--- a/src/qmllint/qqmljslinter_p.h
+++ b/src/qmllint/qqmljslinter_p.h
@@ -127,10 +127,11 @@ public:
LintOptions options, const QStringList &qmlImportPaths,
const QStringList &qmldirFiles,
const QStringList &resourceFiles,
- const QList<QQmlJS::LoggerCategory> &categories);
+ const QList<QQmlJS::LoggerCategory> &categories,
+ qsizetype maxWarnings);
Result lintModule(const QString &uri, LintOptions options, const QStringList &qmlImportPaths,
- const QStringList &resourceFiles);
+ const QStringList &resourceFiles, qsizetype maxWarnings);
static FixResult applyFixes(const QQmlJSLogger *logger, QString *fixedCode, bool silent);
@@ -149,7 +150,8 @@ public:
private:
void lintFileImpl(const QString &filename);
Result lintModuleImpl(const QString &uri, LintOptions options,
- const QStringList &qmlImportPaths, const QStringList &resourceFiles);
+ const QStringList &qmlImportPaths, const QStringList &resourceFiles,
+ qsizetype maxWarnings);
void setupLoggingCategoriesInLogger(QQmlJSLogger *logger,
const QList<QQmlJS::LoggerCategory> &categories);
void parseComments(QQmlJSLogger *logger, const QList<QQmlJS::SourceLocation> &comments);
@@ -180,6 +182,7 @@ private:
QQmlJS::Engine engine; // needs to outlive the lintFileInBatch() call.
+ qsizetype maxWarnings;
bool isESModule;
bool isJavaScript;
};
diff --git a/src/qmllint/qqmllintsettings.cpp b/src/qmllint/qqmllintsettings.cpp
index 55c1411fc4..6f97b360b7 100644
--- a/src/qmllint/qqmllintsettings.cpp
+++ b/src/qmllint/qqmllintsettings.cpp
@@ -11,6 +11,16 @@ using namespace Qt::StringLiterals;
QQmlLintSettings::QQmlLintSettings(const QString &name)
: QQmlToolingSettings(name, { "General"_L1, "Warnings"_L1 })
{
+ addOption(s_maxWarnings, -1);
+}
+
+qsizetype QQmlLintSettings::maxWarnings() const
+{
+ if (!isSet(QQmlLintSettings::s_maxWarnings))
+ return -1;
+ bool ok = false;
+ qsizetype result = value(QQmlLintSettings::s_maxWarnings).toLongLong(&ok);
+ return ok ? result : -1;
}
QT_END_NAMESPACE
diff --git a/src/qmllint/qqmllintsettings_p.h b/src/qmllint/qqmllintsettings_p.h
index f20dc86572..70f29fa026 100644
--- a/src/qmllint/qqmllintsettings_p.h
+++ b/src/qmllint/qqmllintsettings_p.h
@@ -25,6 +25,9 @@ class QQmlLintSettings : public QQmlToolingSettings
{
public:
QQmlLintSettings(const QString &name = QLatin1String("qmllint"));
+
+ static const inline QLatin1StringView s_maxWarnings = QLatin1String("MaxWarnings");
+ qsizetype maxWarnings() const;
};
QT_END_NAMESPACE
diff --git a/src/qmlls/qqmllintsuggestions.cpp b/src/qmlls/qqmllintsuggestions.cpp
index 8ae0788d6e..f78a75c8ce 100644
--- a/src/qmlls/qqmllintsuggestions.cpp
+++ b/src/qmlls/qqmllintsuggestions.cpp
@@ -305,9 +305,9 @@ void QmlLintSuggestions::diagnoseHelper(const QByteArray &url,
QQmlJSLinter::LintOptions lintOptions;
lintOptions.setFlag(QQmlJSLinter::Silent);
- const bool wasPrepared =
- linter.prepareFileForBatchLinting(filename, &fileContents, lintOptions, imports,
- qmltypesFiles, resourceFiles, categories);
+ const bool wasPrepared = linter.prepareFileForBatchLinting(
+ filename, &fileContents, lintOptions, imports, qmltypesFiles, resourceFiles, categories,
+ settings.maxWarnings());
Q_ASSERT(wasPrepared);
QQmlJSLinter::Result result = linter.lintFileInBatch(filename);
diff --git a/src/qmltc/qqmltcvisitor.cpp b/src/qmltc/qqmltcvisitor.cpp
index 0cad42cf0b..18e32deda6 100644
--- a/src/qmltc/qqmltcvisitor.cpp
+++ b/src/qmltc/qqmltcvisitor.cpp
@@ -65,6 +65,7 @@ QSpan<const QmltcLoggingCategoryOverride> categoryOverrides()
QmltcLoggingCategoryOverride{ qmlInlineComponentEnums, std::nullopt },
QmltcLoggingCategoryOverride{ qmlInvalidLintDirective, std::nullopt },
QmltcLoggingCategoryOverride{ qmlLiteralConstructor, Error },
+ QmltcLoggingCategoryOverride{ qmlMaxWarningsExceeded, std::nullopt },
QmltcLoggingCategoryOverride{ qmlMissingEnumEntry, std::nullopt },
QmltcLoggingCategoryOverride{ qmlMissingProperty, Error },
QmltcLoggingCategoryOverride{ qmlMissingType, Error },
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index 739bef1ef4..9a96c211bf 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -373,6 +373,7 @@ private:
QStringList rootUrls = {};
QHash<QString, QString> qrcToFilePaths = {};
QStringList plugins;
+ qsizetype maxWarnings = -1;
};
QJsonArray callQmllintImpl(const QString &fileToLint, const QString &fileCpntent,
@@ -435,16 +436,17 @@ private:
LintOptions options, const QStringList &qmlImportPaths,
const QStringList &qmldirFiles,
const QStringList &resourceFiles,
- const QList<QQmlJS::LoggerCategory> &categories)
+ const QList<QQmlJS::LoggerCategory> &categories,
+ qsizetype maxWarnings = -1)
{
if (!prepareFileForBatchLinting(filename, fileContents, options, qmlImportPaths,
- qmldirFiles, resourceFiles, categories)) {
+ qmldirFiles, resourceFiles, categories, maxWarnings)) {
// Calling clearCache for each linted file/snippet slows down the tests by a factor of 2.5.
// Therefore, only call it when scope re-using happens (prepareFileForBatchLinting returns false).
clearCache();
- const bool result =
- prepareFileForBatchLinting(filename, fileContents, options, qmlImportPaths,
- qmldirFiles, resourceFiles, categories);
+ const bool result = prepareFileForBatchLinting(
+ filename, fileContents, options, qmlImportPaths, qmldirFiles, resourceFiles,
+ categories, maxWarnings);
Q_ASSERT(result);
}
return lintFileInBatch(filename);
@@ -2090,6 +2092,22 @@ void TestQmllint::dirtyQmlSnippet_data()
"qmllint directive on unknown category \"ThisCategoryDoesNotExist\""_L1, 1, 11)
<< defaultOptions;
+ {
+ CallQmllintOptions options = defaultOptions;
+ options.maxWarnings = 0;
+ QTest::newRow("maxWarnings=0")
+ << u"id: Bad"_s
+ << ResultBuilder()
+ .addExpected(
+ "Amount of warnings exceeded the limit set by MaxWarnings.\nCurrent limit: 0\nFound warnings: 1"_L1,
+ 0, 0, QtCriticalMsg)
+ .build()
+ << options;
+ options.maxWarnings = 1;
+ QTest::newRow("maxWarnings=1")
+ << u"id: Bad"_s << ResultBuilder().addUnexpected("MaxWarnings"_L1).build()
+ << options;
+ }
QTest::newRow("missingTypeAccessMethod")
<< u"MyThing { id: bad } Component.onCompleted: console.log(bad.asdf())"_s
<< ResultBuilder()
@@ -3631,7 +3649,7 @@ void TestQmllint::batches()
for (const auto &element : std::as_const(batch.elements)) {
QVERIFY(m_linter.prepareFileForBatchLinting(testFile("batches/" + element.file), nullptr,
options, m_defaultImportPaths, { }, { },
- m_categories));
+ m_categories, -1));
}
for (const auto &element : std::as_const(batch.elements)) {
@@ -3654,7 +3672,7 @@ void TestQmllint::cycles_data()
options.setFlag(QQmlJSLinter::Silent);
options.setFlag(QQmlJSLinter::GenerateJson);
m_linter.prepareFileForBatchLinting(file.filePath(), nullptr, options, m_defaultImportPaths,
- { }, { }, m_categories);
+ { }, { }, m_categories, -1);
}
}
@@ -3673,7 +3691,7 @@ void TestQmllint::jsFileInBatch() {
for (const auto& filename: filenames) {
m_linter.prepareFileForBatchLinting(testFile(filename), nullptr, options,
QLibraryInfo::paths(QLibraryInfo::QmlImportsPath), { },
- { }, m_categories);
+ { }, m_categories, -1);
}
for (const auto& filename: filenames) {
@@ -3848,10 +3866,10 @@ QJsonArray TestQmllint::callQmllintImpl(const QString &fileToLint, const QString
QTest::failOnWarning();
lintResult = m_linter.lintFile(lintedFile, content.isEmpty() ? nullptr : &content,
lintOptions, resolvedImportPaths, options.qmldirFiles,
- resourceFiles, resolvedCategories);
+ resourceFiles, resolvedCategories, options.maxWarnings);
} else {
lintResult = m_linter.lintModule(fileToLint, lintOptions, resolvedImportPaths,
- options.resources);
+ options.resources, options.maxWarnings);
}
[&]() {
@@ -5928,7 +5946,7 @@ void TestQmllint::weakPointers()
// actual testing, prove that this bug does not happen anymore in linter:
for (const auto &file : filesToLint) {
m_linter.prepareFileForBatchLinting(file, nullptr, { }, m_defaultImportPaths, { }, { },
- m_categories);
+ m_categories, -1);
}
for (const auto &file : filesToLint) {
diff --git a/tests/auto/quickcontrols/sanity/tst_sanity.cpp b/tests/auto/quickcontrols/sanity/tst_sanity.cpp
index 24ffc799ac..0986537e0d 100644
--- a/tests/auto/quickcontrols/sanity/tst_sanity.cpp
+++ b/tests/auto/quickcontrols/sanity/tst_sanity.cpp
@@ -114,7 +114,7 @@ void tst_Sanity::qmllint_data()
options.setFlag(QQmlJSLinter::Silent);
options.setFlag(QQmlJSLinter::GenerateJson);
m_linter.prepareFileForBatchLinting(it->absolutePath, nullptr, options, m_importPaths, { },
- { }, m_categories);
+ { }, m_categories, -1);
}
}
@@ -127,7 +127,7 @@ void tst_Sanity::quickControlsSanityPlugin()
options.setFlag(QQmlJSLinter::Silent);
options.setFlag(QQmlJSLinter::GenerateJson);
QVERIFY(m_linter.prepareFileForBatchLinting(testFile(filePath), nullptr, options, m_importPaths,
- { }, { }, m_categories));
+ { }, { }, m_categories, -1));
QQmlJSLinter::Result lintResult = m_linter.lintFileInBatch(testFile(filePath));
QCOMPARE(lintResult.status, QQmlJSLinter::HasWarnings);
const auto &warningsOutput = lintResult.json.value("warnings").toArray();
diff --git a/tests/benchmarks/qml/qmllint/tst_qmllint_benchmark.cpp b/tests/benchmarks/qml/qmllint/tst_qmllint_benchmark.cpp
index 28aa8e0a9c..0441e4ba3f 100644
--- a/tests/benchmarks/qml/qmllint/tst_qmllint_benchmark.cpp
+++ b/tests/benchmarks/qml/qmllint/tst_qmllint_benchmark.cpp
@@ -147,7 +147,7 @@ void tst_qmllint_benchmark::runOnFile(const QString &fileName, PluginSelection a
options.setFlag(QQmlJSLinter::Silent);
QVERIFY(linter.prepareFileForBatchLinting(fileName, &content, options, imports, { }, { },
- categories));
+ categories, -1));
QBENCHMARK {
results.push_back(linter.lintFileInBatch(fileName));
}
diff --git a/tools/qmllint/main.cpp b/tools/qmllint/main.cpp
index 8c8aca929d..cf06c5fd8a 100644
--- a/tools/qmllint/main.cpp
+++ b/tools/qmllint/main.cpp
@@ -527,24 +527,21 @@ All warnings can be set to four levels of severity:
QQmlJSLinter::Result lintResult;
+ const qsizetype maxWarningsValue = parser.isSet(maxWarnings)
+ ? parser.value(maxWarnings).toInt()
+ : (settings.isSet(maxWarningsSetting)
+ ? settings.value(maxWarningsSetting).toInt()
+ : defaultSettings.value(maxWarningsSetting).toInt());
+
if (parser.isSet(moduleOption)) {
QQmlJSLinter::LintOptions options;
options.setFlag(QQmlJSLinter::Silent, silent);
options.setFlag(QQmlJSLinter::GenerateJson, useJson);
- lintResult = linter.lintModule(filename, options, qmlImportPaths, resourceFiles);
+ lintResult = linter.lintModule(filename, options, qmlImportPaths, resourceFiles,
+ maxWarningsValue);
jsonFiles.append(lintResult.json);
success &= (lintResult.status == QQmlJSLinter::LintSuccess
|| lintResult.status == QQmlJSLinter::HasWarnings);
- if (success) {
- const qsizetype value = parser.isSet(maxWarnings)
- ? parser.value(maxWarnings).toInt()
- : (settings.isSet(maxWarningsSetting)
- ? settings.value(maxWarningsSetting).toInt()
- : defaultSettings.value(maxWarningsSetting).toInt());
- if (value != -1 && value < lintResult.logger->numWarnings())
- success = false;
- }
-
if (isFixing)
success &= applyFixes(lintResult, silent, parser.isSet(dryRun));
} else {
@@ -552,8 +549,10 @@ All warnings can be set to four levels of severity:
QQmlJSLinter::LintOptions options;
options.setFlag(QQmlJSLinter::Silent, silent || isFixing);
options.setFlag(QQmlJSLinter::GenerateJson, useJson);
+
linter.prepareFileForBatchLinting(filename, nullptr, options, qmlImportPaths,
- qmldirFiles, resourceFiles, categories);
+ qmldirFiles, resourceFiles, categories,
+ maxWarningsValue);
}
}
if (!parser.isSet(moduleOption)) {
@@ -563,23 +562,6 @@ All warnings can be set to four levels of severity:
success &= (lintResult.status == QQmlJSLinter::LintSuccess
|| lintResult.status == QQmlJSLinter::HasWarnings);
- if (success) {
- QQmlLintSettings settings;
- if (!parser.isSet(ignoreSettings)) {
- QQmlToolingSettings::SearchOptions options;
- options.isQmllintSilent = silent;
- settings.search(filename, options);
- }
-
- const qsizetype value = parser.isSet(maxWarnings)
- ? parser.value(maxWarnings).toInt()
- : (settings.isSet(maxWarningsSetting)
- ? settings.value(maxWarningsSetting).toInt()
- : defaultSettings.value(maxWarningsSetting).toInt());
- if (value != -1 && value < lintResult.logger->numWarnings())
- success = false;
- }
-
if (isFixing)
success &= applyFixes(lintResult, silent, parser.isSet(dryRun));
}