21 Commits

Author SHA1 Message Date
44ee590f33 [ci] Run Swift formatter and linter during CI formatting (#5928)
Make `swift-format` CIPD package available on the `PATH` https://flutter-review.googlesource.com/c/recipes/+/54020

Run `format --no-clang-format --no-java --no-kotlin --no-dart`  on the macOS builder so it doesn't duplicate same `format` call run on Linux.

Filter out generated files until https://github.com/flutter/flutter/issues/141799 is done.

Also add `swift-format lint` call during `format` command.  Fix the one casing issue it found in a test file.

Failing run:
https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8758535881172004177/+/u/Run_package_tests/Swift_format/stdout

Successful run:
https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8758492350529121249/+/u/Run_package_tests/Swift_format/stdout

Fixes https://github.com/flutter/flutter/issues/41129
2024-01-19 22:38:11 +00:00
8ab9b253b6 [ci] Add flags to formatter command to decide which formatters to run (#5905)
Get ready for a world where `swift-format` is available on the `PATH` https://flutter-review.googlesource.com/c/recipes/+/54020

1. Add `format --clang-format --java --kotlin --swift --dart` flags to decide whether to run specific formatters, as opposed to using the `path`.  Keep `swift-format` optional but default the others to run.  This matches the current behavior on Linux.
2. Add `*-path` variants of each.

This will allow us to run `format --swift --no-clang-format --no-java --no-kotlin --no-dart`  on the macOS bot so it doesn't duplicate same `format` call run on Linux.

Part of https://github.com/flutter/flutter/issues/41129
2024-01-18 15:59:25 +00:00
72de224b08 [tool] Add Kotlin autoformatting (#5374)
Updates the tooling to fetch and use `ktfmt` for Kotlin code, the same way it currently does for the Google Java formatter, and applies that formatting (in the default mode; see discussion in the linked issue) to the repository.

In the future we could revisit the formatter or mode, but since this currently seems to be the most consistent with our other languages and to google3 formatting this is likely the option we'll want to stick with.

Fixes https://github.com/flutter/flutter/issues/118756
2023-11-13 16:18:25 +00:00
e73b364bc7 [tool] Add optional swift-format support (#5204)
Adds support for swift-format in the `format` command. For now this is optional, so is only triggered if the flag is explictly passed. In the future, once we have CI support for swift-format, we will likely want to make it on-by-default as with the other formatters.

Part of https://github.com/flutter/flutter/issues/41129
2023-10-23 16:10:19 +00:00
04bb2ac418 [tools] Fix format instructions (#4259)
The instructions for `format` failures still referred to using `activate`, which is no longer how tools are invoked. Replace the specific instructions with a link to the relevant README section to make them evergreen.
2023-06-21 20:28:09 +00:00
f224eea858 [tool] Add pigeon support to update-dependency (#3640)
[tool] Add pigeon support to update-dependency
2023-04-05 10:44:19 +00:00
bbab349927 [tool] Replace flutter format (#6946)
`flutter format` is deprecated on `master`, and prints a warning saying
to switch to `dart format` instead. This updates `format` to make that
switch.
2023-01-11 22:11:35 +00:00
c1ec012a22 [flutter_plugin_tools] If clang-format does not run, fall back to other executables in PATH (#6853)
* If clang-format does not run, fall back to other executables in PATH

* Review edits
2022-12-16 21:05:49 +00:00
92330dbd2c Enable no_leading_underscores_for_local_identifiers (#6509) 2022-09-28 18:22:46 +00:00
9974a8ef44 [tool] Clean up "plugin" references (#6503) 2022-09-27 19:43:04 +00:00
e8b4147fcc Re-sync analysis_options.yaml with flutter/flutter (#5695)
The analysis options have gotten behind; this re-syncs to the current state of flutter/flutter. For options that are non-trivial to enable, either because they are non-trivial to fix, or touch a very large number of files, they are locally disabled with clear "LOCAL CHANGE" markers so that it's obvious where we are out of sync. For options that are simple to resolve, they are enabled in the PR.

Part of https://github.com/flutter/flutter/issues/76229
2022-05-11 11:48:47 -04:00
5ec6644f3f [tools] Convert test utils to RepositoryPackage (#5605) 2022-05-03 14:14:11 -07:00
4cecb9b264 [flutter_plugin_tools] Adds update-excerpts command (#5339) 2022-04-28 09:34:11 -07:00
7009234867 Enforce asterisk alignment for C++ and ObjC pointers (#4703)
So far we've been using the default mode of prevailing-in-file, which
means we aren't consistent within each language what mode we use. Now
that clang-format can identify ObjC headers (which didn't used to be the
case), we can enforce different styles for the two languages.

This sets left-aligned for C++ to match the Flutter engine, and
right-aligned for ObjC to match the prevaling Apple style.
2022-01-26 17:59:32 -05:00
e8d657cf96 Add a way to opt a file out of Dart formatting (#4292) 2021-09-01 13:11:03 -07:00
41f1c806f2 [flutter_plugin_tools] Introduce a class for packages (#4252)
Packages are the primary conceptual object in the tool, but currently they are represented simply as Directory (or occasionally a path string). This introduces an object for packages and:
- moves a number of existing utility methods into it
- sweeps the code for the obvious cases of using `Directory` to represent a package, especially in method signatures and migrates them
- notes a few places where we should migrate later, to avoid ballooning the size of the PR

There are no doubt other cases not caught in the sweep, but this gives us a foundation both for new code, and to migrate incrementally toward as we find existing code that was missed.
2021-08-24 13:29:56 -07:00
74cf0287f9 [flutter_plugin_tools] Improve process mocking (#4254)
The mock process runner used in most of the tests had poor handling of
stdout/stderr:
- By default it would return the `List<int>` output from the mock
  process, which was never correct since the parent process runner
  interface always sets encodings, thus the `dynamic` should always be
  of type `String`
- The process for setting output on a `MockProcess` was awkward, since
  it was based on a `Stream<Lint<int>>`, even though in every case what
  we actually want to do is just set the full output to a string.
- A hack was at some point added (presumably due to the above issues)
  to bypass that flow at the process runner level, and instead return a
  `String` set there. That meant there were two ways of setting output
  (one of which that only worked for one of the ways of running
  processes)
  - That hack wasn't updated when the ability to return multiple mock
    processes instead of a single global mock process was added, so the
    API was even more confusing, and there was no way to set different
    output for different processes.

This changes the test APIs so that:
- `MockProcess` takes stdout and stderr as strings, and internally
  manages converting them to a `Stream<List<int>>`.
- `RecordingProcessRunner` correctly decodes and returns the output
  streams when constructing a process result.

It also removes the resultStdout and resultStderr hacks, as well as the
legacy `processToReturn` API, and converts all uses to the new
structure, which is both simpler to use, and clearly associates output
with specific processes.
2021-08-24 11:42:21 -07:00
a206782759 [flutter_plugin_tools] Use -version with java (#4171) 2021-07-20 10:01:07 -07:00
5f7735d16c [flutter_plugin_tools] Support format on Windows (#4150)
Allows `format` to run successfully on Windows:
- Ensures that no calls exceed the command length limit.
- Allows specifying a `java` path to make it easier to run without a system Java (e.g., by pointing to the `java` binary in an Android Studio installation).
- Adds clear error messages when `java` or `clang-format` is missing since it's very non-obvious what's wrong otherwise.

Bumps the version, which I intended to do in the previous PR but apparently didn't push to the PR.
2021-07-12 17:57:39 -07:00
77460f03f2 [flutter_plugin_tools] Make unit tests pass on Windows (#4149)
The purpose of this PR is to make running all unit tests on Windows pass (vs failing a large portion of the tests as currently happens). This does not mean that the commands actually work when run on Windows, or that Windows support is tested, only that it's possible to actually run the tests themselves. This is prep for actually supporting parts of the tool on Windows in future PRs.

Major changes:
- Make the tests significantly more hermetic:
  - Make almost all tools take a `Platform` constructor argument that can be used to inject a mock platform to control what OS the command acts like it is running on under test.
  - Add a path `Context` object to the base command, whose style matches the `Platform`, and use that almost everywhere instead of the top-level `path` functions.
  - In cases where Posix behavior is always required (such as parsing `git` output), explicitly use the `posix` context object for `path` functions.
- Start laying the groundwork for actual Windows support:
  - Replace all uses of `flutter` as a command with a getter that returns `flutter` or `flutter.bat` as appropriate.
  - For user messages that include relative paths, use a helper that always uses Posix-style relative paths for consistent output.

This bumps the version since quite a few changes have built up, and having a cut point before starting to make more changes to the commands to support Windows seems like a good idea.

Part of https://github.com/flutter/flutter/issues/86113
2021-07-09 19:38:13 -04:00
ac0eed1ac1 [flutter_plugin_tools] Improve and test 'format' (#4145)
- Adds unit tests, as there are currently none.
- Adds more graceful failure handling.
- Adds an internal ignore list to skip files that don't need to be
  formatted that showed up during local testing.
- Adds a note explaining that it's intentially not using the new base
  command due to performance issues.
2021-07-08 12:44:31 -07:00