Skip to content

Commit

Permalink
Merge branch 'main' into guidelines-update-v1
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpryan committed Mar 4, 2025
2 parents 9f57c4a + 532a8e9 commit c0cbf6f
Show file tree
Hide file tree
Showing 89 changed files with 6,070 additions and 3,238 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0
uses: github/codeql-action/init@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -44,7 +44,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0
uses: github/codeql-action/autobuild@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -58,4 +58,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0
uses: github/codeql-action/analyze@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d
6 changes: 3 additions & 3 deletions .github/workflows/scorecards-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186
with:
results_file: results.sarif
results_format: sarif
Expand All @@ -41,14 +41,14 @@ jobs:

# Upload the results as artifacts (optional).
- name: "Upload artifact"
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0
uses: github/codeql-action/upload-sarif@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d
with:
sarif_file: results.sarif
11 changes: 9 additions & 2 deletions examples/misc/lib/effective_dart/style_good.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,18 @@ class Dice {

void unusedCallbackParams() {
var futureOfVoid = Future<void>.value();
// #docregion unused-callback-params
// #docregion unused-callback-param
futureOfVoid.then((_) {
print('Operation complete.');
});
// #enddocregion unused-callback-params
// #enddocregion unused-callback-param

futureOfVoid
// #docregion unused-callback-params-multiple
.onError((_, _) {
print('Operation failed.');
});
// #enddocregion unused-callback-params-multiple
}

//----------------------------------------------------------------------------
Expand Down
26 changes: 23 additions & 3 deletions examples/misc/test/language_tour/generics_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// ignore_for_file: argument_type_not_assignable, prefer_collection_literals
// ignore_for_file: type_annotate_public_apis
import 'dart:collection';

import 'package:examples/language_tour/generics/base_class.dart';
import 'package:test/test.dart';

Expand All @@ -9,14 +11,14 @@ void main() {
var names = <String>[];
names.addAll(['Seth', 'Kathy', 'Lars']);
// #docregion constructor-1
var nameSet = Set<String>.from(names);
var nameSet = Set<String>.of(names);
// #enddocregion constructor-1
expect(nameSet.length, 3);
});

test('constructor-2', () {
// #docregion constructor-2
var views = Map<int, View>();
var views = SplayTreeMap<int, View>();
// #enddocregion constructor-2
expect(views.length, 0);
});
Expand Down Expand Up @@ -65,3 +67,21 @@ void main() {
}

class View {}

// #docregion f-bound
// ignore: one_member_abstracts
abstract interface class Comparable<T> {
int compareTo(T o);
}

int compareAndOffset<T extends Comparable<T>>(T t1, T t2) =>
t1.compareTo(t2) + 1;

class A implements Comparable<A> {
@override
int compareTo(A other) => /*...implementation...*/ 0;
}

var useIt = compareAndOffset(A(), A());

// #enddocregion f-bound
16 changes: 8 additions & 8 deletions examples/misc/test/library_tour/core_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,32 +166,32 @@ void main() {
test('RegExp', () {
// #docregion regexp
// Here's a regular expression for one or more digits.
var numbers = RegExp(r'\d+');
var digitSequence = RegExp(r'\d+');

var allCharacters = 'llamas live fifteen to twenty years';
var lettersOnly = 'llamas live fifteen to twenty years';
var someDigits = 'llamas live 15 to 20 years';

// contains() can use a regular expression.
assert(!allCharacters.contains(numbers));
assert(someDigits.contains(numbers));
assert(!lettersOnly.contains(digitSequence));
assert(someDigits.contains(digitSequence));

// Replace every match with another string.
var exedOut = someDigits.replaceAll(numbers, 'XX');
var exedOut = someDigits.replaceAll(digitSequence, 'XX');
assert(exedOut == 'llamas live XX to XX years');
// #enddocregion regexp
});

test('match', () {
void testMatch() {
// #docregion match
var numbers = RegExp(r'\d+');
var digitSequence = RegExp(r'\d+');
var someDigits = 'llamas live 15 to 20 years';

// Check whether the reg exp has a match in a string.
assert(numbers.hasMatch(someDigits));
assert(digitSequence.hasMatch(someDigits));

// Loop through all matches.
for (final match in numbers.allMatches(someDigits)) {
for (final match in digitSequence.allMatches(someDigits)) {
print(match.group(0)); // 15, then 20
}
// #enddocregion match
Expand Down
10 changes: 10 additions & 0 deletions examples/type_system/lib/bounded/instantiate_to_bound.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ void cannotRunThis() {
c.add(2);
// #enddocregion undefined-method
}

// #docregion inference-using-bounds-2
X max<X extends Comparable<X>>(X x1, X x2) => x1.compareTo(x2) > 0 ? x1 : x2;

void main() {
// Inferred as `max<num>(3, 7)` with the feature, fails without it.
max(3, 7);
}

// #enddocregion inference-using-bounds-2
21 changes: 21 additions & 0 deletions examples/type_system/lib/strong_analysis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,24 @@ void _miscDeclAnalyzedButNotTested() {
// #enddocregion generic-type-assignment-implied-cast
}
}

// #docregion inference-using-bounds
class A<X extends A<X>> {}

class B extends A<B> {}

class C extends B {}

void f<X extends A<X>>(X x) {}

void main() {
f(B()); // OK.

// OK. Without using bounds, inference relying on best-effort approximations
// would fail after detecting that `C` is not a subtype of `A<C>`.
f(C());

f<B>(C()); // OK.
}

// #enddocregion inference-using-bounds
9 changes: 5 additions & 4 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
}
],
"redirects": [
{ "regex": "(?P<basename>.*)\\.html$", "destination": ":basename", "type": 301 },
{ "regex": "(?P<basename>.*)\\.$", "destination": ":basename", "type": 301 },
{ "regex": "(.*)\\.html$", "destination": ":1", "type": 301 },
{ "regex": "(.*)\\.$", "destination": ":1", "type": 301 },

{ "source": "/+", "destination": "/community", "type": 301 },
{ "source": "/+dart2js", "destination": "/tools/dart-compile#js", "type": 301 },
Expand Down Expand Up @@ -387,6 +387,8 @@
{ "source": "/to/pub-workspaces", "destination": "/tools/pub/workspaces", "type": 301 },
{ "source": "/to/publish-from-github", "destination": "/tools/pub/automated-publishing#publishing-packages-using-github-actions", "type": 301 },
{ "source": "/to/publish-with-service-account", "destination": "/tools/pub/automated-publishing#publishing-from-google-cloud-build", "type": 301 },
{ "source": "/to/pubspec-overrides", "destination": "/tools/pub/dependencies#pubspec-overrides", "type": 301 },
{ "source": "/to/sdk-support-policy", "destination": "/tools/sdk#support-policy", "type": 301 },
{ "source": "/to/sdk-constraint", "destination": "/tools/pub/pubspec#sdk-constraints", "type": 301 },
{ "source": "/to/sdk-version-pinning", "destination": "https://github.com/dart-lang/sdk/blob/main/docs/Flutter-Pinned-Packages.md", "type": 301 },
{ "source": "/to/web-debug-extension", "destination": "https://chromewebstore.google.com/detail/dart-debug-extension/eljbmlghnomdjgdjmbdekegdkbabckhm", "type": 301 },
Expand Down Expand Up @@ -446,8 +448,7 @@
},
"emulators": {
"hosting": {
"port": 5500,
"host": "0.0.0.0"
"port": 5501
}
}
}
19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
"node": ">=22.10.0",
"pnpm": ">=9.12.3"
},
"packageManager": "pnpm@9.15.2",
"packageManager": "pnpm@10.5.0",
"devDependencies": {
"@11ty/eleventy": "^3.0.0",
"@types/hast": "^3.0.4",
"@types/markdown-it": "^14.1.2",
"@types/node": "^22.13.4",
"firebase-tools": "^13.31.1",
"@types/node": "^22.13.9",
"firebase-tools": "^13.32.0",
"hast-util-from-html": "^2.0.3",
"hast-util-select": "^6.0.3",
"hast-util-select": "^6.0.4",
"hast-util-to-text": "^4.0.2",
"html-minifier-terser": "^7.2.0",
"js-yaml": "^4.1.0",
Expand All @@ -34,8 +34,13 @@
"markdown-it-attrs": "^4.3.1",
"markdown-it-container": "^4.0.0",
"markdown-it-deflist": "^3.0.0",
"sass": "^1.84.0",
"shiki": "^2.3.2",
"tsx": "^4.19.2"
"sass": "^1.85.1",
"shiki": "^3.1.0",
"tsx": "^4.19.3"
},
"pnpm": {
"onlyBuiltDependencies": [
"esbuild"
]
}
}
Loading

0 comments on commit c0cbf6f

Please sign in to comment.