Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove generated code filter from Swift formatting
  • Loading branch information
stuartmorgan-g committed Jan 20, 2024
commit c5057628aed09a4e38fde5675edf14e7205e17bc
13 changes: 2 additions & 11 deletions script/tool/lib/src/format_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,8 @@ class FormatCommand extends PackageCommand {
}

Future<void> _formatAndLintSwift(Iterable<String> files) async {
// TODO(jmagman): Remove generated file filter when pigeon Swift generation matches swift-format.
// https://github.com/flutter/flutter/issues/141799
final Iterable<String> swiftFiles = _filterGeneratedFiles(
_getPathsWithExtensions(files, <String>{'.swift'}));
final Iterable<String> swiftFiles =
_getPathsWithExtensions(files, <String>{'.swift'});
if (swiftFiles.isNotEmpty) {
final String swiftFormat = await _findValidSwiftFormat();
print('Formatting .swift files...');
Expand Down Expand Up @@ -359,13 +357,6 @@ class FormatCommand extends PackageCommand {
(String filePath) => extensions.contains(path.extension(filePath)));
}

Iterable<String> _filterGeneratedFiles(Iterable<String> files) {
return files.where((String filePath) {
final String basename = path.basename(filePath);
return !basename.contains('.gen.') && !basename.contains('.g.');
});
}

Future<String> _getJavaFormatterPath() async {
final String javaFormatterPath = path.join(
path.dirname(path.fromUri(platform.script)),
Expand Down
16 changes: 0 additions & 16 deletions script/tool/test/format_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -573,22 +573,6 @@ void main() {
]));
});

test('skips generated Swift files', () async {
const List<String> files = <String>[
'macos/foo.gen.swift',
'macos/foo.g.swift',
];
createFakePlugin(
'a_plugin',
packagesDir,
extraFiles: files,
);

await runCapturingPrint(runner, <String>['format', '--swift']);

expect(processRunner.recordedCalls, orderedEquals(<ProcessCall>[]));
});

test('skips Swift if --no-swift flag is provided', () async {
const List<String> files = <String>[
'macos/foo.swift',
Expand Down