Skip to content

Enable clang-tidy on extension C++ files #7336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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:
18 changes: 11 additions & 7 deletions GDevelop.js/scripts/lint-with-clang-tidy.js
Original file line number Diff line number Diff line change
@@ -4,11 +4,13 @@ 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.
];
const supportedExtensions = ['.cpp', '.h', '.hpp'];

async function findClangTidy() {
const tryClangTidy = (clangTidyCommandName) =>
@@ -78,18 +80,18 @@ 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)) {
results = results.concat(findFiles(filePath));
} else {
if (
path.extname(filePath) === '.inl' ||
(!supportedExtensions.includes(path.extname(filePath))) ||
path.basename(filePath) === '.gitignore' ||
excludedPaths.includes(relativePath)
) {
// Ignore .inl files
// Ignore the file.
} else {
results.push(filePath);
}
@@ -108,7 +110,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 = [];