From c7f0bb30caceb75f0a4736ca2fc99008b48da1aa Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 27 Jan 2022 10:31:32 -0800 Subject: [PATCH 1/2] Move to pkg:lints --- CHANGELOG.md | 8 +++++--- analysis_options.yaml | 2 +- example/languages.dart | 15 ++++++++------- example/organization.dart | 1 - example/pr.dart | 2 -- example/readme.dart | 2 -- example/releases.dart | 2 -- example/repos.dart | 6 ++---- example/stars.dart | 1 - example/user_info.dart | 1 - example/users.dart | 2 -- lib/src/common/activity_service.dart | 4 +--- lib/src/common/authorizations_service.dart | 2 +- lib/src/common/checks_service.dart | 1 - lib/src/common/gists_service.dart | 2 +- lib/src/common/git_service.dart | 2 +- lib/src/common/github.dart | 1 - lib/src/common/issues_service.dart | 2 -- lib/src/common/model/activity.dart | 1 - lib/src/common/model/git.dart | 1 - lib/src/common/model/pulls.dart | 1 - lib/src/common/model/repos.dart | 4 ++-- lib/src/common/model/repos_commits.dart | 1 - lib/src/common/orgs_service.dart | 3 +-- lib/src/common/pulls_service.dart | 11 +++++------ lib/src/common/repos_service.dart | 5 +---- lib/src/common/search_service.dart | 3 +-- lib/src/common/users_service.dart | 4 +--- lib/src/common/util/utils.dart | 2 ++ lib/src/const/token_env_keys.dart | 1 + pubspec.yaml | 4 ++-- test/experiment/limit_pager.dart | 10 +++++----- test/src/mocks.mocks.dart | 2 ++ 33 files changed, 43 insertions(+), 66 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85c3a591..19f36604 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 9.0.2-dev + +## 9.0.1 +- Add `conclusion` property in class `CheckRun` + ## 9.0.0 **Breaking change:** In the Gist class, the old type of files was @@ -15,9 +20,6 @@ Map? files; **Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/8.5.0...9.0.0 -## 9.0.1 -- Add `conclusion` property in class `CheckRun` - ## 8.5.0 * Adds listing and creating PR Reviews, listing users in an org by @robrbecker in https://github.com/SpinlockLabs/github.dart/pull/287 diff --git a/analysis_options.yaml b/analysis_options.yaml index 442b7c0c..1b107aa5 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.yaml +include: package:lints/recommended.yaml analyzer: strong-mode: diff --git a/example/languages.dart b/example/languages.dart index 526950ed..02da85e0 100644 --- a/example/languages.dart +++ b/example/languages.dart @@ -1,6 +1,5 @@ import 'dart:html'; -import 'package:github/github.dart'; import 'common.dart'; DivElement? tableDiv; @@ -49,15 +48,17 @@ String generateMarkdown(int accuracy) { final total = totalBytes(breakdown); final data = breakdown.toList(); - var md = '|Name|Bytes|Percentage|\n'; - md += '|-----|-----|-----|\n'; + var md = StringBuffer(''' +|Name|Bytes|Percentage| +|-----|-----|-----| +'''); data.sort((a, b) => b[1].compareTo(a[1])); - data.forEach((info) { + for (final info in data) { final String? name = info[0]; final int bytes = info[1]; final num percentage = (bytes / total) * 100; - md += '|$name|$bytes|${percentage.toStringAsFixed(accuracy)}|\n'; - }); - return md; + md.writeln('|$name|$bytes|${percentage.toStringAsFixed(accuracy)}|'); + } + return md.toString(); } diff --git a/example/organization.dart b/example/organization.dart index fdea07d3..ef7135f8 100644 --- a/example/organization.dart +++ b/example/organization.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:html'; -import 'package:github/github.dart'; import 'common.dart'; DivElement? $output; diff --git a/example/pr.dart b/example/pr.dart index 2805646a..15e18180 100644 --- a/example/pr.dart +++ b/example/pr.dart @@ -1,8 +1,6 @@ import 'dart:async'; import 'dart:html'; -import 'package:github/github.dart'; - import 'common.dart'; Future main() async { diff --git a/example/readme.dart b/example/readme.dart index fb6c29e0..ad9ec300 100644 --- a/example/readme.dart +++ b/example/readme.dart @@ -1,7 +1,5 @@ import 'dart:html'; -import 'package:github/github.dart'; - import 'common.dart'; Future main() async { diff --git a/example/releases.dart b/example/releases.dart index 62db5136..ddd19570 100644 --- a/example/releases.dart +++ b/example/releases.dart @@ -1,7 +1,5 @@ import 'dart:html'; -import 'package:github/github.dart'; - import 'common.dart'; DivElement? releasesDiv; diff --git a/example/repos.dart b/example/repos.dart index 4fdd085c..e7b21da4 100644 --- a/example/repos.dart +++ b/example/repos.dart @@ -1,8 +1,6 @@ import 'dart:async'; import 'dart:html'; -import 'package:github/github.dart'; - import 'common.dart'; DivElement? repositoriesDiv; @@ -29,14 +27,14 @@ Future main() async { loadRepos(); }); - sorts.keys.forEach((name) { + for (final name in sorts.keys) { querySelector('#sort-$name')!.onClick.listen((event) { if (_reposCache == null) { loadRepos(sorts[name]); } updateRepos(_reposCache!, sorts[name]); }); - }); + } } List? _reposCache; diff --git a/example/stars.dart b/example/stars.dart index 16767cfe..a7c96bc4 100644 --- a/example/stars.dart +++ b/example/stars.dart @@ -1,6 +1,5 @@ import 'dart:html'; -import 'package:github/github.dart'; import 'common.dart'; DivElement? $stars; diff --git a/example/user_info.dart b/example/user_info.dart index 074f645c..a5113646 100644 --- a/example/user_info.dart +++ b/example/user_info.dart @@ -1,6 +1,5 @@ import 'dart:html'; -import 'package:github/github.dart'; import 'common.dart'; DivElement? info; diff --git a/example/users.dart b/example/users.dart index 7f9428c8..ab75a061 100644 --- a/example/users.dart +++ b/example/users.dart @@ -1,8 +1,6 @@ import 'dart:async'; import 'dart:html'; -import 'package:github/github.dart'; - import 'common.dart'; DivElement? usersDiv; diff --git a/lib/src/common/activity_service.dart b/lib/src/common/activity_service.dart index 12420eba..16b7b84a 100644 --- a/lib/src/common/activity_service.dart +++ b/lib/src/common/activity_service.dart @@ -1,9 +1,7 @@ import 'dart:async'; import 'dart:convert'; + import 'package:github/src/common.dart'; -import 'package:github/src/common/model/users.dart'; -import 'package:github/src/common/util/pagination.dart'; -import 'package:github/src/common/util/utils.dart'; import 'package:http/http.dart' as http; /// The [ActivityService] handles communication with activity related methods diff --git a/lib/src/common/authorizations_service.dart b/lib/src/common/authorizations_service.dart index 5673001f..7e714afb 100644 --- a/lib/src/common/authorizations_service.dart +++ b/lib/src/common/authorizations_service.dart @@ -1,6 +1,6 @@ import 'dart:async'; + import 'package:github/src/common.dart'; -import 'package:github/src/common/util/pagination.dart'; /// The [AuthorizationsService] handles communication with authorizations related methods /// of the GitHub API. diff --git a/lib/src/common/checks_service.dart b/lib/src/common/checks_service.dart index b0a269ee..d3b63f77 100644 --- a/lib/src/common/checks_service.dart +++ b/lib/src/common/checks_service.dart @@ -1,7 +1,6 @@ import 'dart:convert'; import 'package:github/github.dart'; -import 'package:github/src/common/util/utils.dart'; const _previewHeader = 'application/vnd.github.antiope-preview+json'; diff --git a/lib/src/common/gists_service.dart b/lib/src/common/gists_service.dart index dc0f7316..9f64717e 100644 --- a/lib/src/common/gists_service.dart +++ b/lib/src/common/gists_service.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'dart:convert'; + import 'package:github/src/common.dart'; -import 'package:github/src/common/util/pagination.dart'; /// The [GistsService] handles communication with gist /// methods of the GitHub API. diff --git a/lib/src/common/git_service.dart b/lib/src/common/git_service.dart index d3541ed8..1165eeb0 100644 --- a/lib/src/common/git_service.dart +++ b/lib/src/common/git_service.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'dart:convert'; + import 'package:github/src/common.dart'; -import 'package:github/src/common/util/pagination.dart'; /// The [GitService] handles communication with git related methods of the /// GitHub API. diff --git a/lib/src/common/github.dart b/lib/src/common/github.dart index b92749f0..31605c91 100644 --- a/lib/src/common/github.dart +++ b/lib/src/common/github.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'dart:convert'; import 'package:github/src/common.dart'; -import 'package:github/src/common/util/utils.dart'; import 'package:http/http.dart' as http; import 'package:http_parser/http_parser.dart' as http_parser; import 'package:meta/meta.dart'; diff --git a/lib/src/common/issues_service.dart b/lib/src/common/issues_service.dart index 8fcc9a1a..b20d809a 100644 --- a/lib/src/common/issues_service.dart +++ b/lib/src/common/issues_service.dart @@ -2,8 +2,6 @@ import 'dart:async'; import 'dart:convert'; import 'package:github/src/common.dart'; -import 'package:github/src/common/model/users.dart'; -import 'package:github/src/common/util/pagination.dart'; /// The [IssuesService] handles communication with issues related methods of the /// GitHub API. diff --git a/lib/src/common/model/activity.dart b/lib/src/common/model/activity.dart index ee517ed5..cdb873ec 100644 --- a/lib/src/common/model/activity.dart +++ b/lib/src/common/model/activity.dart @@ -1,5 +1,4 @@ import 'package:github/src/common.dart'; -import 'package:github/src/common/model/users.dart'; import 'package:json_annotation/json_annotation.dart'; part 'activity.g.dart'; diff --git a/lib/src/common/model/git.dart b/lib/src/common/model/git.dart index 861a7028..136c01c4 100644 --- a/lib/src/common/model/git.dart +++ b/lib/src/common/model/git.dart @@ -1,5 +1,4 @@ import 'package:github/src/common.dart'; -import 'package:github/src/common/model/users.dart'; import 'package:json_annotation/json_annotation.dart'; part 'git.g.dart'; diff --git a/lib/src/common/model/pulls.dart b/lib/src/common/model/pulls.dart index 456e5a39..fd6e8d70 100644 --- a/lib/src/common/model/pulls.dart +++ b/lib/src/common/model/pulls.dart @@ -1,5 +1,4 @@ import 'package:github/src/common.dart'; -import 'package:github/src/common/model/users.dart'; import 'package:json_annotation/json_annotation.dart'; import 'package:meta/meta.dart'; diff --git a/lib/src/common/model/repos.dart b/lib/src/common/model/repos.dart index 0a00f26a..739d6ca2 100644 --- a/lib/src/common/model/repos.dart +++ b/lib/src/common/model/repos.dart @@ -309,8 +309,8 @@ class RepositorySlug { String get fullName => '$owner/$name'; @override - bool operator ==(Object obj) => - obj is RepositorySlug && obj.fullName == fullName; + bool operator ==(Object other) => + other is RepositorySlug && other.fullName == fullName; @override int get hashCode => fullName.hashCode; diff --git a/lib/src/common/model/repos_commits.dart b/lib/src/common/model/repos_commits.dart index e3698663..940917ab 100644 --- a/lib/src/common/model/repos_commits.dart +++ b/lib/src/common/model/repos_commits.dart @@ -1,5 +1,4 @@ import 'package:github/src/common.dart'; -import 'package:github/src/common/model/users.dart'; import 'package:json_annotation/json_annotation.dart'; part 'repos_commits.g.dart'; diff --git a/lib/src/common/orgs_service.dart b/lib/src/common/orgs_service.dart index a8a54b25..f72f93b1 100644 --- a/lib/src/common/orgs_service.dart +++ b/lib/src/common/orgs_service.dart @@ -1,8 +1,7 @@ import 'dart:async'; import 'dart:convert'; + import 'package:github/src/common.dart'; -import 'package:github/src/common/util/pagination.dart'; -import 'package:github/src/common/util/utils.dart'; import 'package:http/http.dart' as http; /// The [OrganizationsService] handles communication with organization diff --git a/lib/src/common/pulls_service.dart b/lib/src/common/pulls_service.dart index 01f51722..8c1d3633 100644 --- a/lib/src/common/pulls_service.dart +++ b/lib/src/common/pulls_service.dart @@ -1,8 +1,7 @@ import 'dart:async'; import 'dart:convert'; + import 'package:github/src/common.dart'; -import 'package:github/src/common/util/pagination.dart'; -import 'package:github/src/common/util/utils.dart'; /// The [PullRequestsService] handles communication with pull request /// methods of the GitHub API. @@ -182,9 +181,9 @@ class PullRequestsService extends Service { Future createReview( RepositorySlug slug, CreatePullRequestReview review) { return github.postJSON( - '/repos/${slug.fullName}/pulls/${review.pullNumber}/reviews', - body: GitHubJson.encode(review), - convert: (dynamic i) => PullRequestReview.fromJson(i)) - as Future; + '/repos/${slug.fullName}/pulls/${review.pullNumber}/reviews', + body: GitHubJson.encode(review), + convert: (dynamic i) => PullRequestReview.fromJson(i), + ); } } diff --git a/lib/src/common/repos_service.dart b/lib/src/common/repos_service.dart index 16e573f8..04163260 100644 --- a/lib/src/common/repos_service.dart +++ b/lib/src/common/repos_service.dart @@ -1,10 +1,7 @@ import 'dart:async'; import 'dart:convert'; + import 'package:github/src/common.dart'; -import 'package:github/src/common/model/repos_releases.dart'; -import 'package:github/src/common/model/users.dart'; -import 'package:github/src/common/util/pagination.dart'; -import 'package:github/src/common/util/utils.dart'; import 'package:http/http.dart' as http; /// The [RepositoriesService] handles communication with repository related diff --git a/lib/src/common/search_service.dart b/lib/src/common/search_service.dart index 72da0465..e98344a6 100644 --- a/lib/src/common/search_service.dart +++ b/lib/src/common/search_service.dart @@ -1,8 +1,7 @@ import 'dart:async'; import 'dart:convert'; + import 'package:github/src/common.dart'; -import 'package:github/src/common/model/users.dart'; -import 'package:github/src/common/util/pagination.dart'; /// The [SearchService] handles communication with search related methods of /// the GitHub API. diff --git a/lib/src/common/users_service.dart b/lib/src/common/users_service.dart index ac19ae69..3a469401 100644 --- a/lib/src/common/users_service.dart +++ b/lib/src/common/users_service.dart @@ -1,8 +1,6 @@ import 'dart:async'; + import 'package:github/src/common.dart'; -import 'package:github/src/common/model/users.dart'; -import 'package:github/src/common/util/pagination.dart'; -import 'package:github/src/common/util/utils.dart'; import 'package:http/http.dart' as http; /// The [UsersService] handles communication with user related methods of the diff --git a/lib/src/common/util/utils.dart b/lib/src/common/util/utils.dart index 23dd5307..57bd6712 100644 --- a/lib/src/common/util/utils.dart +++ b/lib/src/common/util/utils.dart @@ -1,3 +1,5 @@ +// ignore_for_file: constant_identifier_names + import 'package:github/src/common.dart'; import 'package:meta/meta.dart'; diff --git a/lib/src/const/token_env_keys.dart b/lib/src/const/token_env_keys.dart index 15d23a83..7a65804e 100644 --- a/lib/src/const/token_env_keys.dart +++ b/lib/src/const/token_env_keys.dart @@ -1,3 +1,4 @@ +// ignore: constant_identifier_names const List COMMON_GITHUB_TOKEN_ENV_KEYS = [ 'GITHUB_ADMIN_TOKEN', 'GITHUB_DART_TOKEN', diff --git a/pubspec.yaml b/pubspec.yaml index 6c039ca0..5ca5bfbd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: github -version: 9.0.1 +version: 9.0.2-dev description: A high-level GitHub API Client Library that uses Github's v3 API homepage: https://github.com/SpinlockLabs/github.dart @@ -18,7 +18,7 @@ dev_dependencies: build_test: any build_web_compilers: any json_serializable: ^6.0.0 + lints: ^1.0.0 mockito: ^5.0.0 - pedantic: ^1.10.0 test: ^1.16.0 yaml: ^3.0.0 diff --git a/test/experiment/limit_pager.dart b/test/experiment/limit_pager.dart index c8b14739..05654bfa 100755 --- a/test/experiment/limit_pager.dart +++ b/test/experiment/limit_pager.dart @@ -5,8 +5,8 @@ void main() { print(solve(201)); } -const int MAX_PER_PAGE = 100; -const int ACCURACY_RANGE = 5; +const int maxPerPage = 100; +const int accuracyRange = 5; /// Solves the most efficient way to fetch the number of objects [limit] with the least requests. PaginationInformation solve(int limit) { @@ -14,12 +14,12 @@ PaginationInformation solve(int limit) { throw RangeError('limit cannot be less than zero (was $limit)'); } - if (limit < MAX_PER_PAGE) { + if (limit < maxPerPage) { return PaginationInformation(limit, 1, limit); } - if ((limit % MAX_PER_PAGE) == 0) { - return PaginationInformation(limit, limit ~/ MAX_PER_PAGE, MAX_PER_PAGE); + if ((limit % maxPerPage) == 0) { + return PaginationInformation(limit, limit ~/ maxPerPage, maxPerPage); } const itemsPerPage = 100; diff --git a/test/src/mocks.mocks.dart b/test/src/mocks.mocks.dart index 6a673895..bd1c1b8c 100644 --- a/test/src/mocks.mocks.dart +++ b/test/src/mocks.mocks.dart @@ -10,10 +10,12 @@ import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_setters_without_getters +// ignore_for_file: camel_case_types // ignore_for_file: comment_references // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_overrides // ignore_for_file: unnecessary_parenthesis class _FakeClient_0 extends _i1.Fake implements _i2.Client {} From e91bdd823fe28de7c521b4632208d98fba717e8d Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Sun, 13 Mar 2022 08:42:44 -0600 Subject: [PATCH 2/2] prep 9.0.2 --- CHANGELOG.md | 3 ++- pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19f36604..afffef1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ -## 9.0.2-dev +## 9.0.2 +- Switched to use the lints package instead of pedantic https://github.com/SpinlockLabs/github.dart/pull/301 ## 9.0.1 - Add `conclusion` property in class `CheckRun` diff --git a/pubspec.yaml b/pubspec.yaml index 5ca5bfbd..4a035a95 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: github -version: 9.0.2-dev +version: 9.0.2 description: A high-level GitHub API Client Library that uses Github's v3 API homepage: https://github.com/SpinlockLabs/github.dart