Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit 4e5404c

Browse files
authored
Pass a Uri to package:http APIs (#2366)
Prepare for dart-lang/http#375
1 parent 0629001 commit 4e5404c

File tree

5 files changed

+34
-31
lines changed

5 files changed

+34
-31
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# 0.1.127-dev
2+
13
# 0.1.126
24

35
* fixed false negatives for `prefer_collection_literals` when a LinkedHashSet or

lib/src/util/score_utils.dart

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
import 'package:analyzer/src/lint/config.dart'; // ignore: implementation_imports
66
import 'package:http/http.dart' as http;
77

8-
const _pedanticOptionsRootUrl =
9-
'https://raw.githubusercontent.com/dart-lang/pedantic/master/lib';
10-
const _pedanticOptionsUrl = '$_pedanticOptionsRootUrl/analysis_options.yaml';
8+
final _pedanticOptionsRootUrl =
9+
Uri.https('raw.githubusercontent.com', '/dart-lang/pedantic/master/lib/');
10+
final _pedanticOptionsUrl =
11+
_pedanticOptionsRootUrl.resolve('analysis_options.yaml');
1112

1213
List<String> _pedanticRules;
1314

1415
Future<List<String>> get pedanticRules async =>
1516
_pedanticRules ??= await _fetchPedanticRules();
1617

17-
Future<List<String>> fetchRules(String optionsUrl) async {
18+
Future<List<String>> fetchRules(Uri optionsUrl) async {
1819
final config = await _fetchConfig(optionsUrl);
1920
if (config == null) {
2021
print('no config found for: $optionsUrl (SKIPPED)');
@@ -27,18 +28,16 @@ Future<List<String>> fetchRules(String optionsUrl) async {
2728
return rules;
2829
}
2930

30-
Future<LintConfig> _fetchConfig(String url) async {
31+
Future<LintConfig> _fetchConfig(Uri url) async {
3132
print('loading $url...');
32-
final client = http.Client();
33-
final req = await client.get(url);
33+
final req = await http.get(url);
3434
return processAnalysisOptionsFile(req.body);
3535
}
3636

3737
Future<List<String>> _fetchPedanticRules() async {
38-
final client = http.Client();
3938
print('loading $_pedanticOptionsUrl...');
40-
final req = await client.get(_pedanticOptionsUrl);
39+
final req = await http.get(_pedanticOptionsUrl);
4140
final includedOptions =
4241
req.body.split('include: package:pedantic/')[1].trim();
43-
return fetchRules('$_pedanticOptionsRootUrl/$includedOptions');
42+
return fetchRules(_pedanticOptionsRootUrl.resolve(includedOptions));
4443
}

lib/src/version.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
/// Package version. Synchronized w/ pubspec.yaml.
6-
const String version = '0.1.126';
6+
const String version = '0.1.127-dev';

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: linter
2-
version: 0.1.126
2+
version: 0.1.127-dev
33

44
description: >-
55
The implementation of the lint rules supported by the analyzer framework.

tool/crawl.dart

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,21 @@ import 'package:pub_semver/pub_semver.dart';
1414
import 'package:yaml/yaml.dart';
1515

1616
const _allPathSuffix = '/example/all.yaml';
17-
const _effectiveDartOptionsRootUrl =
18-
'https://raw.githubusercontent.com/tenhobi/effective_dart/master/lib';
19-
const _effectiveDartOptionsUrl =
20-
'$_effectiveDartOptionsRootUrl/analysis_options.yaml';
21-
22-
const _flutterOptionsUrl =
23-
'https://raw.githubusercontent.com/flutter/flutter/master/packages/flutter/lib/analysis_options_user.yaml';
24-
const _flutterRepoOptionsUrl =
25-
'https://raw.githubusercontent.com/flutter/flutter/master/analysis_options.yaml';
26-
const _repoPathPrefix = 'https://raw.githubusercontent.com/dart-lang/linter/';
27-
const _rulePathPrefix = 'https://raw.githubusercontent.com/dart-lang/linter';
28-
const _stagehandOptionsUrl =
29-
'https://raw.githubusercontent.com/dart-lang/stagehand/master/templates/analysis_options.yaml';
17+
final _effectiveDartOptionsRootUrl = Uri.https(
18+
'raw.githubusercontent.com', '/tenhobi/effective_dart/master/lib/');
19+
final _effectiveDartOptionsUrl =
20+
_effectiveDartOptionsRootUrl.resolve('analysis_options.yaml');
21+
22+
final _flutterOptionsUrl = Uri.https('raw.githubusercontent.com',
23+
'/flutter/flutter/master/packages/flutter/lib/analysis_options_user.yaml');
24+
final _flutterRepoOptionsUrl = Uri.https('raw.githubusercontent.com',
25+
'/flutter/flutter/master/analysis_options.yaml');
26+
final _repoPathPrefix =
27+
Uri.https('raw.githubusercontent.com', '/dart-lang/linter/');
28+
final _rulePathPrefix =
29+
Uri.https('raw.githubusercontent.com', '/dart-lang/linter/');
30+
final _stagehandOptionsUrl = Uri.https('raw.githubusercontent.com',
31+
'/dart-lang/stagehand/master/templates/analysis_options.yaml');
3032

3133
/// We don't care about SDKs previous to this bottom.
3234
final Version bottomDartSdk = Version(2, 0, 0);
@@ -88,7 +90,7 @@ Future<String> dartSdkForLinter(String version) async {
8890
}
8991

9092
Future<List<String>> fetchRulesForVersion(String version) async =>
91-
score_utils.fetchRules('$_repoPathPrefix$version$_allPathSuffix');
93+
score_utils.fetchRules(_repoPathPrefix.resolve('$version$_allPathSuffix'));
9294

9395
Future<String> findSinceDartSdk(String linterVersion) async =>
9496
await dartSdkForLinter(linterVersion);
@@ -131,8 +133,8 @@ Future<String> _crawlForVersion(String lint) async {
131133
var client = http.Client();
132134
for (var minor = 1; minor < 31; ++minor) {
133135
var version = '0.1.$minor';
134-
var req =
135-
await client.get('$_rulePathPrefix/$version/lib/src/rules/$lint.dart');
136+
var req = await client
137+
.get(_rulePathPrefix.resolve('$version/lib/src/rules/$lint.dart'));
136138
if (req.statusCode == 200) {
137139
return version;
138140
}
@@ -143,8 +145,8 @@ Future<String> _crawlForVersion(String lint) async {
143145
Future<String> _fetchDEPSforVersion(String version) async {
144146
var client = http.Client();
145147
//https://raw.githubusercontent.com/dart-lang/sdk/2.1.0-dev.1.0/DEPS
146-
var req = await client
147-
.get('https://raw.githubusercontent.com/dart-lang/sdk/$version/DEPS');
148+
var req = await client.get(
149+
Uri.https('raw.githubusercontent.com', '/dart-lang/sdk/$version/DEPS'));
148150
return req.body;
149151
}
150152

@@ -154,7 +156,7 @@ Future<List<String>> _fetchEffectiveDartRules() async {
154156
var includedOptions =
155157
req.body.split('include: package:effective_dart/')[1].trim();
156158
return score_utils
157-
.fetchRules('$_effectiveDartOptionsRootUrl/$includedOptions');
159+
.fetchRules(_effectiveDartOptionsRootUrl.resolve(includedOptions));
158160
}
159161

160162
Future<String> _fetchLinterForVersion(String version) async {

0 commit comments

Comments
 (0)