chore: chunk filenames when linting C++ files (#34237)

* chore: chunk filenames when linting C++ files

* chore: refactor code for better readability

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* chore: further tweak

* chore: limit all platforms to 4095 characters on command line

* chore: use python3

* Revert "chore: use python3"

Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: Cheng Zhao <zcbenz@gmail.com>
This commit is contained in:
David Sanders 2022-06-22 03:23:11 -07:00 committed by GitHub
parent f172136752
commit 5fee5b0e22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 32 deletions

View file

@ -9,6 +9,8 @@ const klaw = require('klaw');
const minimist = require('minimist');
const path = require('path');
const { chunkFilenames } = require('./lib/utils');
const ELECTRON_ROOT = path.normalize(path.dirname(__dirname));
const SOURCE_ROOT = path.resolve(ELECTRON_ROOT, '..');
const DEPOT_TOOLS = path.resolve(SOURCE_ROOT, 'third_party', 'depot_tools');
@ -69,12 +71,11 @@ const LINTERS = [{
roots: ['shell'],
test: filename => filename.endsWith('.cc') || (filename.endsWith('.h') && !isObjCHeader(filename)),
run: (opts, filenames) => {
if (opts.fix) {
spawnAndCheckExitCode('python3', ['script/run-clang-format.py', '-r', '--fix', ...filenames]);
} else {
spawnAndCheckExitCode('python3', ['script/run-clang-format.py', '-r', ...filenames]);
const clangFormatFlags = opts.fix ? ['--fix'] : [];
for (const chunk of chunkFilenames(filenames)) {
spawnAndCheckExitCode('python3', ['script/run-clang-format.py', ...clangFormatFlags, ...chunk]);
cpplint(chunk);
}
cpplint(filenames);
}
}, {
key: 'objc',