From 8782b5d5b4eeed30cc37d5ce3965e4f3c348fc1b Mon Sep 17 00:00:00 2001 From: Florian Rival Date: Wed, 22 Jan 2025 19:24:17 +0100 Subject: [PATCH 1/3] Enable clang-tidy on extension C++ files --- GDevelop.js/scripts/lint-with-clang-tidy.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/GDevelop.js/scripts/lint-with-clang-tidy.js b/GDevelop.js/scripts/lint-with-clang-tidy.js index 110d40947f37..065e4f03ec8f 100644 --- a/GDevelop.js/scripts/lint-with-clang-tidy.js +++ b/GDevelop.js/scripts/lint-with-clang-tidy.js @@ -4,10 +4,11 @@ const path = require('path'); const { makeSimplePromisePool } = require('./utils/SimplePromisePool'); const gdevelopRootPath = path.resolve(__dirname, '../../'); -const sourcesRootPath = path.join(gdevelopRootPath, 'Core/GDCore'); +const coreSourcesRootPath = path.join(gdevelopRootPath, 'Core/GDCore'); +const extensionSourcesRootPath = path.join(gdevelopRootPath, 'Extensions'); const excludedPaths = [ - 'Tools/Localization.cpp', // emscripten code which can't be linted - 'Serialization/Serializer.cpp', // Diagnostic that can't be ignored in rapidjson. + 'Core/GDCore/Tools/Localization.cpp', // emscripten code which can't be linted + 'Core/GDCore/Serialization/Serializer.cpp', // Diagnostic that can't be ignored in rapidjson. ]; async function findClangTidy() { @@ -78,7 +79,7 @@ function findFiles(directoryPath) { list.forEach((file) => { const filePath = path.resolve(directoryPath, file); - const relativePath = path.relative(sourcesRootPath, filePath); + const relativePath = path.relative(gdevelopRootPath, filePath); const stat = fs.statSync(filePath); if (stat && stat.isDirectory() && !excludedPaths.includes(relativePath)) { @@ -89,7 +90,7 @@ function findFiles(directoryPath) { path.basename(filePath) === '.gitignore' || excludedPaths.includes(relativePath) ) { - // Ignore .inl files + // Ignore the file. } else { results.push(filePath); } @@ -108,7 +109,9 @@ async function main() { process.exit(1); } - const filesToCheck = findFiles(sourcesRootPath); + const coreFilesToCheck = findFiles(coreSourcesRootPath); + const extensionFilesToCheck = findFiles(extensionSourcesRootPath); + const filesToCheck = [...coreFilesToCheck, ...extensionFilesToCheck]; // Run clang-tidy on each file. const filesWithErrors = []; From 542d799cc7b786c4d3d0aebacbe8519b0744c95c Mon Sep 17 00:00:00 2001 From: Florian Rival Date: Wed, 22 Jan 2025 19:25:21 +0100 Subject: [PATCH 2/3] Temporarily run clang-tidy on this branch --- .circleci/config.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5d6471103a25..1ff373563cbc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -301,13 +301,7 @@ workflows: - build-gdevelop_js-wasm-only gdevelop_js-wasm-extra-checks: jobs: - - build-gdevelop_js-debug-sanitizers-and-extra-checks: - # Extra checks are resource intensive so don't all run them. - filters: - branches: - only: - - master - - /experimental-build.*/ + - build-gdevelop_js-debug-sanitizers-and-extra-checks builds: jobs: - build-macos: From 9bfde5425f60866df2d60ecf7e5c3575fddaea7a Mon Sep 17 00:00:00 2001 From: Florian Rival Date: Wed, 22 Jan 2025 19:35:46 +0100 Subject: [PATCH 3/3] Update lint-with-clang-tidy.js --- GDevelop.js/scripts/lint-with-clang-tidy.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GDevelop.js/scripts/lint-with-clang-tidy.js b/GDevelop.js/scripts/lint-with-clang-tidy.js index 065e4f03ec8f..4b269697818b 100644 --- a/GDevelop.js/scripts/lint-with-clang-tidy.js +++ b/GDevelop.js/scripts/lint-with-clang-tidy.js @@ -10,6 +10,7 @@ const excludedPaths = [ 'Core/GDCore/Tools/Localization.cpp', // emscripten code which can't be linted 'Core/GDCore/Serialization/Serializer.cpp', // Diagnostic that can't be ignored in rapidjson. ]; +const supportedExtensions = ['.cpp', '.h', '.hpp']; async function findClangTidy() { const tryClangTidy = (clangTidyCommandName) => @@ -86,7 +87,7 @@ function findFiles(directoryPath) { results = results.concat(findFiles(filePath)); } else { if ( - path.extname(filePath) === '.inl' || + (!supportedExtensions.includes(path.extname(filePath))) || path.basename(filePath) === '.gitignore' || excludedPaths.includes(relativePath) ) {