Use clang-tidy config file from repo instead of default (flutter/engine#29595)

This commit is contained in:
Jenn Magder
2021-11-09 09:53:03 -08:00
committed by GitHub
parent 214178f553
commit 64f7c65f27
4 changed files with 23 additions and 10 deletions

View File

@@ -184,7 +184,7 @@ class ClangTidy {
Future<_ComputeJobsResult> _computeJobs(
List<Command> commands,
io.Directory repoPath,
String checks,
String? checks,
) async {
bool sawMalformed = false;
final List<WorkerJob> jobs = <WorkerJob>[];

View File

@@ -126,8 +126,13 @@ class Command {
}
/// The job for the process runner for the lint needed for this command.
WorkerJob createLintJob(String checks) {
final List<String> args = <String>[filePath, checks, '--'];
WorkerJob createLintJob(String? checks) {
final List<String> args = <String>[
filePath,
if (checks != null)
checks,
'--',
];
args.addAll(tidyArgs.split(' '));
return WorkerJob(
<String>[tidyPath, ...args],

View File

@@ -19,10 +19,8 @@ class Options {
this.lintAll = false,
this.errorMessage,
StringSink? errSink,
}) {
checks = checksArg.isNotEmpty ? '--checks=$checksArg' : '--config=';
_errSink = errSink ?? io.stderr;
}
}) : checks = checksArg.isNotEmpty ? '--checks=$checksArg' : null,
_errSink = errSink ?? io.stderr;
factory Options._error(
String message, {
@@ -131,7 +129,7 @@ class Options {
final String checksArg;
/// Check arguments to plumb through to clang-tidy.
late final String checks;
final String? checks;
/// Whether all files should be linted.
final bool lintAll;
@@ -140,7 +138,7 @@ class Options {
/// contains the error message.
final String? errorMessage;
late final StringSink _errSink;
final StringSink _errSink;
/// Print command usage with an additional message.
void printUsage({String? message}) {

View File

@@ -7,6 +7,7 @@ import 'dart:io' as io show Directory, File, Platform, stderr;
import 'package:clang_tidy/clang_tidy.dart';
import 'package:clang_tidy/src/command.dart';
import 'package:litetest/litetest.dart';
import 'package:process_runner/process_runner.dart';
Future<int> main(List<String> args) async {
if (args.length < 2) {
@@ -199,7 +200,16 @@ Future<int> main(List<String> args) async {
);
expect(commands, isNotEmpty);
expect(commands.first.tidyPath, contains('clang/bin/clang-tidy'));
final Command command = commands.first;
expect(command.tidyPath, contains('clang/bin/clang-tidy'));
final WorkerJob job = command.createLintJob(null);
expect(job.command, <String>[
'../../buildtools/mac-x64/clang/bin/clang-tidy',
filePath,
'--',
'',
filePath,
]);
});
test('Command getLintAction flags third_party files', () async {