Skip to content

Commit 1e3adf8

Browse files
committed
Strong mode
1 parent 467e50c commit 1e3adf8

34 files changed

+110
-138
lines changed

example/user_info.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void loadUser() {
3333
<b>Name</b>: ${user.name}
3434
""");
3535

36-
void append(String name, value) {
36+
void append(String name, dynamic value) {
3737
if (value != null) {
3838
info.appendHtml("""
3939
<br/>

lib/browser.dart

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
/**
2-
* GitHub for the Browser
3-
*
4-
* This contains a few utilities that are browser specific.
5-
* See [GitHubBrowserHelper] for more information.
6-
*/
1+
/// GitHub for the Browser
2+
///
3+
/// This contains a few utilities that are browser specific.
4+
75
library github.browser;
86

97
import "src/common.dart";
108

119
export "src/browser/helper.dart";
1210
export "src/common.dart";
1311

14-
/**
15-
* Creates a GitHub Client
16-
*/
12+
/// Creates a GitHub Client
1713
GitHub createGitHubClient(
1814
{Authentication auth, String endpoint: "https://api.github.com"}) {
1915
return new GitHub(auth: auth, endpoint: endpoint);

lib/server.dart

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/**
2-
* GitHub for the Server
3-
*/
1+
/// GitHub for the Server
42
library github.server;
53

64
import "dart:io";
@@ -10,12 +8,9 @@ import "src/common.dart";
108
export "src/common.dart";
119
export "src/server/hooks.dart";
1210

13-
/**
14-
* Creates a GitHub Client.
15-
*
16-
* If [auth] is not specified, then it will be automatically configured
17-
* from the environment as per [findAuthenticationFromEnvironment].
18-
*/
11+
/// Creates a GitHub Client.
12+
/// If [auth] is not specified, then it will be automatically configured
13+
/// from the environment as per [findAuthenticationFromEnvironment].
1914
GitHub createGitHubClient(
2015
{Authentication auth, String endpoint: "https://api.github.com"}) {
2116
if (auth == null) {
@@ -55,7 +50,9 @@ Authentication findAuthenticationFromEnvironment() {
5550
String password = result.stderr.toString().split("password:")[1].trim();
5651
password = password.substring(1, password.length - 1);
5752
return new Authentication.basic(username.trim(), password.trim());
58-
} catch (e) {}
53+
} catch (e) {
54+
print(e);
55+
}
5956
}
6057

6158
Map<String, String> env = Platform.environment;

lib/src/browser/helper.dart

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@ import 'dart:html' hide Client;
22

33
import '../common.dart';
44

5-
/**
6-
* Browser-Specific Helpers
7-
*/
5+
/// Browser-Specific Helpers
86
class GitHubBrowserHelper {
9-
/**
10-
* Renders Markdown in HTML using the GitHub API
11-
*
12-
* TODO: Remove the requirement of [indent] and auto-detect it.
13-
*
14-
* [github] is the GitHub instance to use.
15-
* [selector] is the selector to use to find markdown elements.
16-
* [indent] is the indent that needs to be stripped out.
17-
*/
7+
/// Renders Markdown in HTML using the GitHub API
8+
///
9+
/// TODO: Remove the requirement of [indent] and auto-detect it.
10+
///
11+
/// [github] is the GitHub instance to use.
12+
/// [selector] is the selector to use to find markdown elements.
13+
/// [indent] is the indent that needs to be stripped out.
1814
static void renderMarkdown(GitHub github, String selector, {int indent: 4}) {
1915
ElementList elements = document.querySelectorAll(selector);
2016

@@ -36,9 +32,7 @@ class GitHubBrowserHelper {
3632
}
3733
}
3834

39-
/**
40-
* Creates an Image Element from a User that has the user's avatar.
41-
*/
35+
/// Creates an Image Element from a User that has the user's avatar.
4236
static ImageElement createAvatarImage(User user,
4337
{int width: 128, int height: 128}) {
4438
return new ImageElement(src: user.avatarUrl, width: width, height: height);

lib/src/common.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
/**
2-
* The Core of GitHub for Dart.
3-
*
4-
* Contains the Models and other GitHub stuff.
5-
*/
1+
/// The Core of GitHub for Dart.
2+
/// Contains the Models and other GitHub stuff.
63
library github.common;
74

85
import "dart:async";
96
import "dart:convert" show BASE64, JSON, UTF8;
107

118
import "package:html/dom.dart" as html;
12-
import "package:html/parser.dart" as htmlParser;
9+
import "package:html/parser.dart" as html_parser;
1310
import "package:http/http.dart" as http;
1411
import "package:quiver/async.dart" show FutureGroup;
1512
import "package:xml/xml.dart" as xml;

lib/src/common/explore_service.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ExploreService extends Service {
1818
var controller = new StreamController<TrendingRepository>();
1919

2020
_github.client.get(url).then((response) {
21-
var doc = htmlParser.parse(response.body);
21+
var doc = html_parser.parse(response.body);
2222
var items = doc.querySelectorAll(
2323
"li.repo-leaderboard-list-item.leaderboard-list-item");
2424

@@ -48,7 +48,7 @@ class ExploreService extends Service {
4848
var completer = new Completer<Showcase>();
4949

5050
_github.client.get(info.url).then((response) {
51-
var doc = htmlParser.parse(response.body);
51+
var doc = html_parser.parse(response.body);
5252
var showcase = new Showcase();
5353

5454
var title = doc.querySelector(".collection-header").text;
@@ -95,7 +95,7 @@ class ExploreService extends Service {
9595
Function handleResponse;
9696

9797
handleResponse = (response) {
98-
var doc = htmlParser.parse(response.body);
98+
var doc = html_parser.parse(response.body);
9999

100100
var cards = doc.querySelectorAll(".collection-card");
101101

lib/src/common/gists_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class GistsService extends Service {
145145
return _github
146146
.request("POST", "/gists/${id}/forks", statusCode: 201)
147147
.then((response) {
148-
return Gist.fromJSON(JSON.decode(response.body));
148+
return Gist.fromJSON(JSON.decode(response.body) as Map<String, dynamic>);
149149
});
150150
}
151151

lib/src/common/misc_service.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ class MiscService extends Service {
8181
.get(
8282
"${cors ? "http://whateverorigin.org/get?url=" : ""}${cors ? Uri.encodeComponent(u) : u}")
8383
.then((response) {
84-
var document = htmlParser.parse(response.body);
84+
var document = html_parser.parse(response.body);
8585
document.querySelectorAll("entry").forEach((entry) {
8686
var name = entry.querySelector("title").text;
8787
var c = "<html><body>" +
8888
entry.querySelector("content").innerHtml +
8989
"</body></html>";
90-
var content = htmlParser.parse(c);
90+
var content = html_parser.parse(c);
9191
var image = content.querySelector("a img").attributes['src'];
9292
var url = entry.querySelector("link").attributes['href'];
9393

lib/src/common/model/activity.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Event {
3333
..org = Organization.fromJSON(input['org'] as Map<String, dynamic>)
3434
..createdAt = parseDateTime(input['created_at'])
3535
..id = input['id']
36-
..actor = User.fromJSON(input['actor'])
36+
..actor = User.fromJSON(input['actor'] as Map<String, dynamic>)
3737
..payload = input['payload'] as Map<String, dynamic>;
3838

3939
return event;

lib/src/common/model/authorizations.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ class Authorization {
2222
..id = input['id']
2323
..scopes = input['scopes'] as List<String>
2424
..token = input['token']
25-
..app = AuthorizationApplication.fromJSON(input['app'])
25+
..app = AuthorizationApplication.fromJSON(input['app'] as Map<String, dynamic>)
2626
..note = input['note']
2727
..noteUrl = input['note_url']
2828
..createdAt = parseDateTime(input['created_at'])
2929
..updatedAt = parseDateTime(input['updated_at'])
3030
..json = input
31-
..user = User.fromJSON(input['user']);
31+
..user = User.fromJSON(input['user'] as Map<String, dynamic>);
3232
}
3333
}
3434

@@ -42,7 +42,7 @@ class AuthorizationApplication {
4242

4343
AuthorizationApplication();
4444

45-
static AuthorizationApplication fromJSON(input) {
45+
static AuthorizationApplication fromJSON(Map<String, dynamic> input) {
4646
if (input == null) return null;
4747

4848
return new AuthorizationApplication()

lib/src/common/model/gists.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ class Gist {
2727
@ApiName("updated_at")
2828
DateTime updatedAt;
2929

30-
static Gist fromJSON(input) {
30+
static Gist fromJSON(Map<String, dynamic> input) {
3131
if (input == null) return null;
3232

3333
var gist = new Gist()
3434
..id = input['id']
3535
..description = input['description']
3636
..public = input['public']
37-
..owner = User.fromJSON(input['owner'])
38-
..user = User.fromJSON(input['user']);
37+
..owner = User.fromJSON(input['owner'] as Map<String, dynamic>)
38+
..user = User.fromJSON(input['user'] as Map<String, dynamic>);
3939

4040
if (input['files'] != null) {
4141
gist.files = [];
4242

4343
for (var key in input['files'].keys) {
44-
var map = copyOf(input['files'][key]);
44+
var map = copyOf(input['files'][key]) as Map<String, dynamic>;
4545
map['name'] = key;
4646
gist.files.add(GistFile.fromJSON(map));
4747
}
@@ -71,7 +71,7 @@ class GistFile {
7171
bool truncated;
7272
String content;
7373

74-
static GistFile fromJSON(input) {
74+
static GistFile fromJSON(Map<String, dynamic> input) {
7575
if (input == null) return null;
7676

7777
return new GistFile()
@@ -96,11 +96,11 @@ class GistFork {
9696
@ApiName("updated_at")
9797
DateTime updatedAt;
9898

99-
static GistFork fromJSON(input) {
99+
static GistFork fromJSON(Map<String, dynamic> input) {
100100
if (input == null) return null;
101101

102102
return new GistFork()
103-
..user = User.fromJSON(input['user'])
103+
..user = User.fromJSON(input['user'] as Map<String, dynamic>)
104104
..id = input['id']
105105
..createdAt = parseDateTime(input['created_at'])
106106
..updatedAt = parseDateTime(input['updated_at']);
@@ -125,12 +125,12 @@ class GistHistoryEntry {
125125
@ApiName("committed_at")
126126
DateTime committedAt;
127127

128-
static GistHistoryEntry fromJSON(input) {
128+
static GistHistoryEntry fromJSON(Map<String, dynamic> input) {
129129
if (input == null) return null;
130130

131131
return new GistHistoryEntry()
132132
..version = input['version']
133-
..user = User.fromJSON(input['user'])
133+
..user = User.fromJSON(input['user'] as Map<String, dynamic>)
134134
..deletions = input['change_status']['deletions']
135135
..additions = input['change_status']['additions']
136136
..totalChanges = input['change_status']['total']
@@ -156,7 +156,7 @@ class GistComment {
156156

157157
return new GistComment()
158158
..id = input['id']
159-
..user = User.fromJSON(input['user'])
159+
..user = User.fromJSON(input['user'] as Map<String, dynamic>)
160160
..createdAt = parseDateTime(input['created_at'])
161161
..updatedAt = parseDateTime(input['updated_at'])
162162
..body = input['body'];

lib/src/common/model/issues.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ class Issue {
7171
..number = input['number']
7272
..state = input['state']
7373
..title = input['title']
74-
..user = User.fromJSON(input['user'])
74+
..user = User.fromJSON(input['user'] as Map<String, dynamic>)
7575
..labels = labels.map(IssueLabel.fromJSON).toList(growable: false)
76-
..assignee = User.fromJSON(input['assignee'])
76+
..assignee = User.fromJSON(input['assignee'] as Map<String, dynamic>)
7777
..milestone =
7878
Milestone.fromJSON(input['milestone'] as Map<String, dynamic>)
7979
..commentsCount = input['comments']
@@ -82,7 +82,7 @@ class Issue {
8282
..createdAt = parseDateTime(input['created_at'])
8383
..updatedAt = parseDateTime(input['updated_at'])
8484
..closedAt = parseDateTime(input['closed_at'])
85-
..closedBy = User.fromJSON(input['closed_by'])
85+
..closedBy = User.fromJSON(input['closed_by'] as Map<String, dynamic>)
8686
..body = input['body'];
8787
}
8888

@@ -163,7 +163,7 @@ class IssueComment {
163163
return new IssueComment()
164164
..id = input['id']
165165
..body = input['body']
166-
..user = User.fromJSON(input['user'])
166+
..user = User.fromJSON(input['user'] as Map<String, dynamic>)
167167
..createdAt = parseDateTime(input['created_at'])
168168
..updatedAt = parseDateTime(input['updated_at'])
169169
..url = input['url']
@@ -244,7 +244,7 @@ class Milestone {
244244
..state = input['state']
245245
..title = input['title']
246246
..description = input['description']
247-
..creator = User.fromJSON(input['creator'])
247+
..creator = User.fromJSON(input['creator'] as Map<String, dynamic>)
248248
..openIssuesCount = input['open_issues']
249249
..closedIssuesCount = input['closed_issues']
250250
..createdAt = parseDateTime(input['created_at'])

lib/src/common/model/misc.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class GitignoreTemplate {
88
/// Template Source
99
String source;
1010

11-
static GitignoreTemplate fromJSON(input) {
11+
static GitignoreTemplate fromJSON(Map<String, dynamic> input) {
1212
if (input == null) return null;
1313

1414
return new GitignoreTemplate()
@@ -52,7 +52,7 @@ class APIStatus {
5252
@ApiName("body")
5353
String message;
5454

55-
static APIStatus fromJSON(input) {
55+
static APIStatus fromJSON(Map<String, dynamic> input) {
5656
if (input == null) return null;
5757

5858
return new APIStatus()

lib/src/common/model/pulls.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class PullRequestInformation {
7474
pr.updatedAt = parseDateTime(input['updated_at']);
7575
pr.closedAt = parseDateTime(input['closed_at']);
7676
pr.mergedAt = parseDateTime(input['merged_at']);
77-
pr.user = User.fromJSON(input['user']);
77+
pr.user = User.fromJSON(input['user'] as Map<String, dynamic>);
7878
return pr;
7979
}
8080
}
@@ -121,7 +121,7 @@ class PullRequest extends PullRequestInformation {
121121
pr.mergeable = input['mergeable'];
122122
pr.merged = input['merged'];
123123
pr.id = input['id'];
124-
pr.mergedBy = User.fromJSON(input['merged_by']);
124+
pr.mergedBy = User.fromJSON(input['merged_by'] as Map<String, dynamic>);
125125
pr.mergeCommitSha = input['merge_commit_sha'];
126126
pr.commentsCount = input['comments'];
127127
pr.commitsCount = input['commits'];
@@ -174,7 +174,7 @@ class PullRequestHead {
174174
head.label = input['label'];
175175
head.ref = input['ref'];
176176
head.sha = input['sha'];
177-
head.user = User.fromJSON(input['user']);
177+
head.user = User.fromJSON(input['user'] as Map<String, dynamic>);
178178
head.repo = Repository.fromJSON(input['repo'] as Map<String, dynamic>);
179179
return head;
180180
}
@@ -252,13 +252,13 @@ class PullRequestComment {
252252
..originalPosition = input['original_position']
253253
..commitID = input['commit_id']
254254
..originalCommitID = input['original_commit_id']
255-
..user = User.fromJSON(input['user'])
255+
..user = User.fromJSON(input['user'] as Map<String, dynamic>)
256256
..body = input['body']
257257
..createdAt = parseDateTime(input['created_at'])
258258
..updatedAt = parseDateTime(input['updated_at'])
259259
..url = input['html_url']
260260
..pullRequestUrl = input['pull_request_url']
261-
..links = Links.fromJSON(input['_links']);
261+
..links = Links.fromJSON(input['_links'] as Map<String, dynamic>);
262262
}
263263
}
264264

lib/src/common/model/repos_commits.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class RepositoryCommit {
4747
..htmlUrl = input['html_url']
4848
..commentsUrl = input['comments_url']
4949
..commit = GitCommit.fromJSON(input['commit'] as Map<String, dynamic>)
50-
..author = User.fromJSON(input['author'])
51-
..committer = User.fromJSON(input['committer'])
50+
..author = User.fromJSON(input['author'] as Map<String, dynamic>)
51+
..committer = User.fromJSON(input['committer'] as Map<String, dynamic>)
5252
..stats = CommitStats.fromJSON(input['stats'] as Map<String, dynamic>);
5353

5454
if (input['parents'] != null) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy