Skip to content

Commit 5e64d59

Browse files
authored
Expose CheckSuitesService and ChuckRunsService classes (#351)
Require Dart 2.18 Also a bunch of other cleanup, enabled latest lints removed duplicate lints sorted lints etc
1 parent ed73adf commit 5e64d59

28 files changed

+258
-622
lines changed

Diff for: .github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
matrix:
1212
os: [ubuntu-latest]
13-
sdk: [2.17.7, stable] # Test with at least the declared minimum Dart version
13+
sdk: [2.18.7, stable] # Test with at least the declared minimum Dart version
1414
steps:
1515
- uses: actions/checkout@v2
1616
- uses: dart-lang/setup-dart@v1.3

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 9.10.0-dev
2+
3+
* Require Dart 2.18
4+
* Expose `CheckSuitesService` and `ChuckRunsService` classes.
5+
16
## 9.9.0
27

38
* Add "author_association" field to the IssueComment object by @ricardoamador in https://github.com/SpinlockLabs/github.dart/pull/348

Diff for: analysis_options.yaml

+3-339
Large diffs are not rendered by default.

Diff for: example/release_notes.dart

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import 'dart:html';
22

3-
import 'common.dart';
43
import 'package:pub_semver/pub_semver.dart';
54

5+
import 'common.dart';
6+
67
late DivElement releasesDiv;
78

89
Future<void> main() async {
@@ -28,12 +29,12 @@ Future<String> loadReleaseNotes() async {
2829
print('No unreleased PRs');
2930
return '';
3031
}
31-
var semvers = Set<String>();
32-
for (var pr in unreleasedPRs) {
32+
var semvers = <String>{};
33+
for (final pr in unreleasedPRs) {
3334
var prlabels = pr.labels
3435
.where((element) => element.name.startsWith('semver:'))
3536
.toList();
36-
for (var l in prlabels) {
37+
for (final l in prlabels) {
3738
semvers.add(l.name);
3839
}
3940
}
@@ -50,7 +51,9 @@ Future<String> loadReleaseNotes() async {
5051
newVersion = latestVersion.nextPatch.toString();
5152
}
5253
print(newVersion);
53-
if (newVersion.isEmpty) return '';
54+
if (newVersion.isEmpty) {
55+
return '';
56+
}
5457

5558
var notes = await github.repositories.generateReleaseNotes(CreateReleaseNotes(
5659
slug.owner, slug.name, newVersion,

Diff for: example/stars.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ void loadStars() {
3030
$stars!.append(h);
3131
}).onDone(() {
3232
querySelector('#total')!
33-
.appendText(querySelectorAll('.user').length.toString() + ' stars');
33+
.appendText('${querySelectorAll('.user').length} stars');
3434
});
3535
}

Diff for: lib/src/common/activity_service.dart

+28-36
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@ class ActivityService extends Service {
1515
///
1616
/// API docs: https://developer.github.com/v3/activity/events/#list-public-events
1717
Stream<Event> listPublicEvents({int pages = 2}) {
18-
return PaginationHelper(github).objects(
19-
'GET', '/events', (dynamic i) => Event.fromJson(i),
20-
pages: pages);
18+
return PaginationHelper(github)
19+
.objects('GET', '/events', Event.fromJson, pages: pages);
2120
}
2221

2322
/// Lists public events for a network of repositories.
2423
///
2524
/// API docs: https://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories
2625
Stream<Event> listRepositoryNetworkEvents(RepositorySlug slug,
2726
{int pages = 2}) {
28-
return PaginationHelper(github).objects('GET',
29-
'/networks/${slug.fullName}/events', (dynamic i) => Event.fromJson(i),
27+
return PaginationHelper(github).objects(
28+
'GET', '/networks/${slug.fullName}/events', Event.fromJson,
3029
pages: pages);
3130
}
3231

@@ -47,9 +46,7 @@ class ActivityService extends Service {
4746
/// API docs: https://developer.github.com/v3/activity/events/#list-repository-events
4847
Stream<Event> listRepositoryIssueEvents(RepositorySlug slug, {int? pages}) {
4948
return PaginationHelper(github).objects(
50-
'GET',
51-
'/repos/${slug.fullName}/issues/events',
52-
(dynamic i) => Event.fromJson(i),
49+
'GET', '/repos/${slug.fullName}/issues/events', Event.fromJson,
5350
pages: pages);
5451
}
5552

@@ -62,8 +59,8 @@ class ActivityService extends Service {
6259
///
6360
/// API docs: https://developer.github.com/v3/activity/events/#list-repository-events
6461
Stream<Event> listRepositoryEvents(RepositorySlug slug, {int? pages}) {
65-
return PaginationHelper(github).objects('GET',
66-
'/repos/${slug.fullName}/events', (dynamic i) => Event.fromJson(i),
62+
return PaginationHelper(github).objects(
63+
'GET', '/repos/${slug.fullName}/events', Event.fromJson,
6764
pages: pages);
6865
}
6966

@@ -77,9 +74,8 @@ class ActivityService extends Service {
7774
///
7875
/// API docs: https://developer.github.com/v3/activity/events/#list-public-events-for-an-organization
7976
Stream<Event> listEventsForOrganization(String name, {int? pages}) {
80-
return PaginationHelper(github).objects(
81-
'GET', '/orgs/$name/events', (dynamic i) => Event.fromJson(i),
82-
pages: pages);
77+
return PaginationHelper(github)
78+
.objects('GET', '/orgs/$name/events', Event.fromJson, pages: pages);
8379
}
8480

8581
/// Returns an [EventPoller] for public events for an organization.
@@ -105,16 +101,16 @@ class ActivityService extends Service {
105101
/// API docs: https://developer.github.com/v3/activity/events/#list-events-performed-by-a-user
106102
Stream<Event> listEventsPerformedByUser(String username, {int? pages}) {
107103
return PaginationHelper(github).objects(
108-
'GET', '/users/$username/events', (dynamic i) => Event.fromJson(i),
104+
'GET', '/users/$username/events', Event.fromJson,
109105
pages: pages);
110106
}
111107

112108
/// Lists the public events performed by a user.
113109
///
114110
/// API docs: https://developer.github.com/v3/activity/events/#list-public-events-performed-by-a-user
115111
Stream<Event> listPublicEventsPerformedByUser(String username, {int? pages}) {
116-
return PaginationHelper(github).objects('GET',
117-
'/users/$username/events/public', (dynamic i) => Event.fromJson(i),
112+
return PaginationHelper(github).objects(
113+
'GET', '/users/$username/events/public', Event.fromJson,
118114
pages: pages);
119115
}
120116

@@ -132,7 +128,7 @@ class ActivityService extends Service {
132128
Stream<Notification> listNotifications(
133129
{bool all = false, bool participating = false}) {
134130
return PaginationHelper(github).objects(
135-
'GET', '/notifications', (dynamic i) => Notification.fromJson(i),
131+
'GET', '/notifications', Notification.fromJson,
136132
params: {'all': all, 'participating': participating});
137133
}
138134

@@ -141,10 +137,8 @@ class ActivityService extends Service {
141137
/// API docs: https://developer.github.com/v3/activity/notifications/#list-your-notifications-in-a-repository
142138
Stream<Notification> listRepositoryNotifications(RepositorySlug repository,
143139
{bool all = false, bool participating = false}) {
144-
return PaginationHelper(github).objects(
145-
'GET',
146-
'/repos/${repository.fullName}/notifications',
147-
(dynamic i) => Notification.fromJson(i),
140+
return PaginationHelper(github).objects('GET',
141+
'/repos/${repository.fullName}/notifications', Notification.fromJson,
148142
params: {'all': all, 'participating': participating});
149143
}
150144

@@ -192,8 +186,7 @@ class ActivityService extends Service {
192186
/// API docs: https://developer.github.com/v3/activity/notifications/#view-a-single-thread
193187
Future<Notification> getThread(String threadId) =>
194188
github.getJSON('/notification/threads/$threadId',
195-
statusCode: StatusCodes.OK,
196-
convert: (dynamic i) => Notification.fromJson(i));
189+
statusCode: StatusCodes.OK, convert: Notification.fromJson);
197190

198191
/// Mark the specified notification thread as read.
199192
///
@@ -214,8 +207,8 @@ class ActivityService extends Service {
214207
///
215208
/// API docs: https://developer.github.com/v3/activity/starring/#list-stargazers
216209
Stream<User> listStargazers(RepositorySlug slug, {int perPage = 30}) {
217-
return PaginationHelper(github).objects('GET',
218-
'/repos/${slug.fullName}/stargazers', (dynamic i) => User.fromJson(i),
210+
return PaginationHelper(github).objects(
211+
'GET', '/repos/${slug.fullName}/stargazers', User.fromJson,
219212
params: {'per_page': perPage});
220213
}
221214

@@ -224,7 +217,7 @@ class ActivityService extends Service {
224217
/// API docs: https://developer.github.com/v3/activity/starring/#list-repositories-being-starred
225218
Stream<Repository> listStarredByUser(String user, {int perPage = 30}) {
226219
return PaginationHelper(github).objects(
227-
'GET', '/users/$user/starred', (dynamic i) => Repository.fromJson(i),
220+
'GET', '/users/$user/starred', Repository.fromJson,
228221
params: {'per_page': perPage});
229222
}
230223

@@ -233,7 +226,7 @@ class ActivityService extends Service {
233226
/// API docs: https://developer.github.com/v3/activity/starring/#list-repositories-being-starred
234227
Stream<Repository> listStarred({int perPage = 30}) {
235228
return PaginationHelper(github).objects(
236-
'GET', '/user/starred', (dynamic i) => Repository.fromJson(i),
229+
'GET', '/user/starred', Repository.fromJson,
237230
params: {'per_page': perPage});
238231
}
239232

@@ -272,24 +265,24 @@ class ActivityService extends Service {
272265
///
273266
/// API docs: https://developer.github.com/v3/activity/watching/#list-watchers
274267
Stream<User> listWatchers(RepositorySlug slug) {
275-
return PaginationHelper(github).objects('GET',
276-
'/repos/${slug.fullName}/subscribers', (dynamic i) => User.fromJson(i));
268+
return PaginationHelper(github)
269+
.objects('GET', '/repos/${slug.fullName}/subscribers', User.fromJson);
277270
}
278271

279272
/// Lists the repositories the specified user is watching.
280273
///
281274
/// API docs: https://developer.github.com/v3/activity/watching/#list-repositories-being-watched
282275
Stream<Repository> listWatchedByUser(String user) {
283-
return PaginationHelper(github).objects('GET', '/users/$user/subscriptions',
284-
(dynamic i) => Repository.fromJson(i));
276+
return PaginationHelper(github)
277+
.objects('GET', '/users/$user/subscriptions', Repository.fromJson);
285278
}
286279

287280
/// Lists the repositories the current user is watching.
288281
///
289282
/// API docs: https://developer.github.com/v3/activity/watching/#list-repositories-being-watched
290283
Stream<Repository> listWatched() {
291-
return PaginationHelper(github).objects(
292-
'GET', '/user/subscriptions', (dynamic i) => Repository.fromJson(i));
284+
return PaginationHelper(github)
285+
.objects('GET', '/user/subscriptions', Repository.fromJson);
293286
}
294287

295288
/// Fetches repository subscription information.
@@ -298,8 +291,7 @@ class ActivityService extends Service {
298291
Future<RepositorySubscription> getRepositorySubscription(
299292
RepositorySlug slug) =>
300293
github.getJSON('/repos/${slug.fullName}/subscription',
301-
statusCode: StatusCodes.OK,
302-
convert: (dynamic i) => RepositorySubscription.fromJson(i));
294+
statusCode: StatusCodes.OK, convert: RepositorySubscription.fromJson);
303295

304296
/// Sets the Repository Subscription Status
305297
///
@@ -315,7 +307,7 @@ class ActivityService extends Service {
315307
return github.putJSON(
316308
'/repos/${slug.fullName}/subscription',
317309
statusCode: StatusCodes.OK,
318-
convert: (dynamic i) => RepositorySubscription.fromJson(i),
310+
convert: RepositorySubscription.fromJson,
319311
body: GitHubJson.encode(map),
320312
);
321313
}

Diff for: lib/src/common/authorizations_service.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ class AuthorizationsService extends Service {
1616
///
1717
/// API docs: https://developer.github.com/v3/oauth_authorizations/#list-your-authorizations
1818
Stream<Authorization> listAuthorizations() {
19-
return PaginationHelper(github).objects(
20-
'GET', '/authorizations', (dynamic i) => Authorization.fromJson(i));
19+
return PaginationHelper(github)
20+
.objects('GET', '/authorizations', Authorization.fromJson);
2121
}
2222

2323
/// Fetches an authorization specified by [id].
2424
///
2525
/// API docs: https://developer.github.com/v3/oauth_authorizations/#get-a-single-authorization
2626
Future<Authorization> getAuthorization(int id) =>
2727
github.getJSON('/authorizations/$id',
28-
statusCode: 200, convert: (dynamic i) => Authorization.fromJson(i));
28+
statusCode: 200, convert: Authorization.fromJson);
2929

3030
// TODO: Implement remaining API methods of authorizations:
3131
// See https://developer.github.com/v3/oauth_authorizations/

0 commit comments

Comments
 (0)