Skip to content

[code_builder] Minor style fixes - #2501

Merged
natebosch merged 2 commits into
mainfrom
code_builder-cleanup
Aug 7, 2026
Merged

natebosch merged 2 commits into
mainfrom
code_builder-cleanup

Conversation

@natebosch

Copy link
Copy Markdown
Member

Reapplies some of the unrelated style cleanups that had originally
landed in #2135 and were reverted in #2499

  • Fix typos in some test names.
  • Use a consistent bullet character in the changelog.
  • Expand README info about Emitter.

Reapplies some of the unrelated style cleanups that had originally
landed in #2135 and were reverted in #2499

- Fix typos in some test names.
- Use a consistent bullet character in the changelog.
- Expand README info about Emitter.
@natebosch
natebosch requested a review from a team as a code owner August 7, 2026 21:09
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Package publishing

If you have publishing permissions, you can use the links below to publish the changes after merging this PR.

Package Version Status Publish tag (post-merge)
package:api_summary 0.1.0-wip WIP (no publish necessary)
package:bazel_worker 1.1.5 already published at pub.dev
package:benchmark_harness 2.4.0 already published at pub.dev
package:boolean_selector 2.1.2 already published at pub.dev
package:browser_launcher 1.2.0-wip WIP (no publish necessary)
package:cli_config 0.2.1-wip WIP (no publish necessary)
package:cli_util 0.5.2 already published at pub.dev
package:clock 1.1.3-wip WIP (no publish necessary)
package:code_builder 4.12.0-wip WIP (no publish necessary)
package:coverage 1.15.1 already published at pub.dev
package:csslib 1.0.2 already published at pub.dev
package:extension_discovery 2.1.0 already published at pub.dev
package:file 7.0.2-wip WIP (no publish necessary)
package:file_testing 3.1.0-wip WIP (no publish necessary)
package:glob 2.1.4-wip WIP (no publish necessary)
package:graphs 2.4.0-wip WIP (no publish necessary)
package:html 0.15.7-wip WIP (no publish necessary)
package:io 1.1.0-wip WIP (no publish necessary)
package:json_rpc_2 4.1.0 already published at pub.dev
package:markdown 7.4.0 ready to publish markdown-v7.4.0
package:mime 2.1.0-wip WIP (no publish necessary)
package:oauth2 2.0.5 already published at pub.dev
package:package_config 3.0.0 already published at pub.dev
package:pool 1.5.3-wip WIP (no publish necessary)
package:process 5.0.5 (error) pubspec version (5.0.5) and changelog (5.0.6-wip) don't agree
package:pub_semver 2.2.0 already published at pub.dev
package:pubspec_parse 1.6.0-wip WIP (no publish necessary)
package:source_map_stack_trace 2.1.3-wip WIP (no publish necessary)
package:source_maps 0.10.14 ready to publish source_maps-v0.10.14
package:source_span 1.10.2 already published at pub.dev
package:sse 4.2.1-wip WIP (no publish necessary)
package:stack_trace 1.12.2-wip (error) pubspec version (1.12.2-wip) and changelog (1.12.2-dev) don't agree
package:stream_channel 2.1.4 already published at pub.dev
package:stream_transform 2.1.2-wip WIP (no publish necessary)
package:string_scanner 1.4.2-wip WIP (no publish necessary)
package:term_glyph 1.2.3-wip WIP (no publish necessary)
package:test_reflective_loader 0.6.0 ready to publish test_reflective_loader-v0.6.0
package:timing 1.0.2 already published at pub.dev
package:unified_analytics 8.0.16 already published at pub.dev
package:watcher 1.2.2-wip WIP (no publish necessary)
package:yaml 3.1.4-wip WIP (no publish necessary)
package:yaml_edit 2.2.4 already published at pub.dev

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the README.md to improve the basic usage examples, updates CHANGELOG.md formatting, and fixes several typos in the expression tests. The reviewer feedback recommends adding missing imports to the README code snippets and formatting the DartFormatter instantiations to ensure the examples are complete and highly readable.

Comment thread pkgs/code_builder/README.md Outdated
Comment on lines +16 to +19
final animal = Class((builder) => builder
..name = 'Animal'
..extend = refer('Organism')
..methods.add(Method.returnsVoid((b) => b
..name = 'eat'
..body = const Code("print('Yum!');"))));
final emitter = DartEmitter();
print(
DartFormatter(languageVersion: DartFormatter.latestLanguageVersion)
.format('${animal.accept(emitter)}'),
);
}
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The code snippet is missing the import statement for package:code_builder/code_builder.dart. Adding the import makes the basic usage example self-contained and easier for new users to copy and run.

Suggested change
final animal = Class((builder) => builder
..name = 'Animal'
..extend = refer('Organism')
..methods.add(Method.returnsVoid((b) => b
..name = 'eat'
..body = const Code("print('Yum!');"))));
final emitter = DartEmitter();
print(
DartFormatter(languageVersion: DartFormatter.latestLanguageVersion)
.format('${animal.accept(emitter)}'),
);
}
);
import 'package:code_builder/code_builder.dart';
final animal = Class((builder) => builder
..name = 'Animal'
..extend = refer('Organism')
);
References
  1. Optimize for readability - code is read more often than it is written. (link)

Comment thread pkgs/code_builder/README.md Outdated
Comment on lines +32 to +48
import 'package:dart_style/dart_style.dart';

// ... //

final emitter = DartEmitter();

// Generate code for 'animal' into a new StringBuffer
final StringSink result = animal.accept(emitter);

// or, add it to an existing one
final buffer = StringBuffer();
animal.accept(emitter, buffer);

// format the output using package:dart_style
final String formatted = DartFormatter(
languageVersion: DartFormatter.latestLanguageVersion)
.format(result.toString());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Add the missing import for package:code_builder/code_builder.dart to make the snippet complete. Additionally, format the DartFormatter instantiation with a trailing comma and standard method call chaining to improve readability.

Suggested change
import 'package:dart_style/dart_style.dart';
// ... //
final emitter = DartEmitter();
// Generate code for 'animal' into a new StringBuffer
final StringSink result = animal.accept(emitter);
// or, add it to an existing one
final buffer = StringBuffer();
animal.accept(emitter, buffer);
// format the output using package:dart_style
final String formatted = DartFormatter(
languageVersion: DartFormatter.latestLanguageVersion)
.format(result.toString());
import 'package:code_builder/code_builder.dart';
import 'package:dart_style/dart_style.dart';
// ... //
final emitter = DartEmitter();
// Generate code for 'animal' into a new StringBuffer
final StringSink result = animal.accept(emitter);
// or, add it to an existing one
final buffer = StringBuffer();
animal.accept(emitter, buffer);
// format the output using package:dart_style
final String formatted = DartFormatter(
languageVersion: DartFormatter.latestLanguageVersion,
).format(result.toString());
References
  1. Optimize for readability - code is read more often than it is written. (link)

Comment on lines +87 to +89
final formatted = DartFormatter(
languageVersion: DartFormatter.latestLanguageVersion)
.format(library.accept(emitter).toString());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Format the DartFormatter instantiation with a trailing comma and standard method call chaining to improve readability and maintain consistent style.

Suggested change
final formatted = DartFormatter(
languageVersion: DartFormatter.latestLanguageVersion)
.format(library.accept(emitter).toString());
final formatted = DartFormatter(
languageVersion: DartFormatter.latestLanguageVersion,
).format(library.accept(emitter).toString());
References
  1. Optimize for readability - code is read more often than it is written. (link)

@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

PR Health

License Headers ✔️
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

Files
no missing headers

All source files should start with a license header.

This check can be disabled by tagging the PR with skip-license-check.

Unused Dependencies ✔️
Package Status
code_builder ✔️ All dependencies utilized correctly.

For details on how to fix these, see dependency_validator.

This check can be disabled by tagging the PR with skip-unused-dependencies-check.

Coverage ✔️
File Coverage

This check for test coverage is informational (issues shown here will not fail the PR).

This check can be disabled by tagging the PR with skip-coverage-check.

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbol Leaking sources

This check can be disabled by tagging the PR with skip-leaking-check.

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
code_builder None 4.11.1 4.12.0-wip 4.12.0-wip ✔️

This check can be disabled by tagging the PR with skip-breaking-check.

@natebosch
natebosch requested a review from kevmoo August 7, 2026 21:11

@kevmoo kevmoo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noice!

@natebosch
natebosch merged commit aec21da into main Aug 7, 2026
31 checks passed
@natebosch
natebosch deleted the code_builder-cleanup branch August 7, 2026 21:23
copybara-service Bot pushed a commit to dart-lang/sdk that referenced this pull request Aug 11, 2026
Revisions updated by `dart tools/rev_sdk_deps.dart`.

dartdoc (https://github.com/dart-lang/dartdoc/compare/1fd02f7..8be851e):
  8be851e2  Mon Aug 10 13:51:08 2026 +0200  Sarah Zakarias  Bump to 9.0.9 (dart-lang/dartdoc#4278)

http (https://github.com/dart-lang/http/compare/9cb80c7..a9176ac):
  a9176ac  Mon Aug 10 13:27:26 2026 +0200  dart-ecosystem-bot[bot]  Tidy: package:http2 (dart-lang/http#1967)
  9bd9ccb  Sat Aug 8 06:31:37 2026 +0300  Ellet  chore(ok_http): migrate to jni 1.0.0 (dart-lang/http#1943)
  107e4c7  Sat Aug 8 04:54:46 2026 +0300  Yauhen Sampir  [cronet_http] Add DNS configuration options to CronetEngine.build (dart-lang/http#1945)
  55c39c9  Sat Aug 8 07:57:20 2026 +0800  Seven Du  Fix RFC 850 two-digit year parsing (dart-lang/http#1951)
  c71cb6d  Sat Aug 8 01:47:35 2026 +0200  Moritz  Add ecosystem groundskeeper workflow (dart-lang/http#1959)

test (https://github.com/dart-lang/test/compare/dd426d4..55b186d):
  55b186dd  Mon Aug 10 22:18:01 2026 +0200  Sigurd Meldgaard  Fix race conditions in Chrome coverage collection (dart-lang/test#2715)
  51463b0e  Mon Aug 10 21:59:15 2026 +0300  Yusuf İhsan Görgel  Keep the browser executable env override through a settings merge (dart-lang/test#2722)
  b87a2492  Fri Aug 7 12:07:52 2026 -0700  Jacob MacDonald  Enable asserts (dart-lang/test#2719)

tools (https://github.com/dart-lang/tools/compare/f3ec9ed..d644cda):
  d644cdab  Mon Aug 10 11:24:43 2026 +0200  Sigurd Meldgaard  [pub_semver] Parse only pure-digit prerelease/build identifiers as integers (dart-lang/tools#2489)
  df06fed9  Fri Aug 7 15:37:45 2026 -0700  Nate Bosch  Update to Dart 3.10.0 and reformat (dart-lang/tools#2502)
  aec21dae  Fri Aug 7 14:23:11 2026 -0700  Nate Bosch  [code_builder] Minor style fixes (dart-lang/tools#2501)
  1bbcc309  Fri Aug 7 13:56:38 2026 -0700  Nate Bosch  Revert "[code_builder] Add control-flow support (`#2135`)" (dart-lang/tools#2499)
  77607740  Fri Aug 7 01:59:58 2026 +0530  Aman Maurya  Fix MultiChannel inner channel type constraint documentation (dart-lang/tools#2491)
  889787a8  Thu Aug 6 12:56:22 2026 -0700  Nate Bosch  Roll to the latest package:csv (dart-lang/tools#2497)

[email protected]

Change-Id: I4cb9a8839c9ae21c57eca7750c81fdbd1a58a09c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/534341
Auto-Submit: Nate Bosch <[email protected]>
Reviewed-by: Kevin Moore <[email protected]>
Commit-Queue: Kevin Moore <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants