Skip to content

Commit 9cbfee3

Browse files
authored
Lint fixes (#2004)
Fix lints associated with pedantic v1.8 Enable and fix prefer_generic_function_type_aliases lint fix associated builder
1 parent 2e401d7 commit 9cbfee3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+884
-974
lines changed

analysis_options.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include: package:pedantic/analysis_options.1.7.0.yaml
1+
include: package:pedantic/analysis_options.1.8.0.yaml
22

33
analyzer:
44
exclude:
@@ -17,7 +17,8 @@ linter:
1717
- directives_ordering
1818
- no_adjacent_strings_in_list
1919
- package_api_docs
20-
- slash_for_doc_comments
2120
- prefer_final_fields
21+
- prefer_generic_function_type_aliases
22+
- slash_for_doc_comments
2223
- unawaited_futures
2324
# - unnecessary_brace_in_string_interps

bin/dartdoc.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ class DartdocProgramOptionContext extends DartdocGeneratorOptionContext
2727

2828
Future<List<DartdocOption>> createDartdocProgramOptions() async {
2929
return <DartdocOption>[
30-
new DartdocOptionArgOnly<bool>('asyncStackTraces', false,
30+
DartdocOptionArgOnly<bool>('asyncStackTraces', false,
3131
help: 'Display coordinated asynchronous stack traces (slow)',
3232
negatable: true),
33-
new DartdocOptionArgOnly<bool>('generateDocs', true,
33+
DartdocOptionArgOnly<bool>('generateDocs', true,
3434
help:
3535
'Generate docs into the output directory (or only display warnings if false).',
3636
negatable: true),
37-
new DartdocOptionArgOnly<bool>('help', false,
37+
DartdocOptionArgOnly<bool>('help', false,
3838
abbr: 'h', help: 'Show command help.', negatable: false),
39-
new DartdocOptionArgOnly<bool>('version', false,
39+
DartdocOptionArgOnly<bool>('version', false,
4040
help: 'Display the version for $name.', negatable: false),
4141
];
4242
}
@@ -76,7 +76,7 @@ Future<void> main(List<String> arguments) async {
7676

7777
DartdocProgramOptionContext config;
7878
try {
79-
config = new DartdocProgramOptionContext(optionSet, null);
79+
config = DartdocProgramOptionContext(optionSet, null);
8080
} on DartdocOptionError catch (e) {
8181
stderr.writeln(' fatal error: ${e.message}');
8282
stderr.writeln('');
@@ -94,7 +94,7 @@ Future<void> main(List<String> arguments) async {
9494
try {
9595
await Chain.capture(() async {
9696
await runZoned(dartdoc.generateDocs,
97-
zoneSpecification: new ZoneSpecification(
97+
zoneSpecification: ZoneSpecification(
9898
print: (Zone self, ZoneDelegate parent, Zone zone, String line) =>
9999
logPrint(line)));
100100
}, onError: (e, Chain chain) {

lib/dartdoc.dart

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ class DartdocGeneratorOptionContext extends DartdocOptionContext
4848
/// directory.
4949
class Dartdoc extends PackageBuilder {
5050
final List<Generator> generators;
51-
final Set<String> writtenFiles = new Set();
51+
final Set<String> writtenFiles = Set();
5252
Directory outputDir;
5353

5454
// Fires when the self checks make progress.
5555
final StreamController<String> _onCheckProgress =
56-
new StreamController(sync: true);
56+
StreamController(sync: true);
5757

5858
Dartdoc._(DartdocOptionContext config, this.generators) : super(config) {
59-
outputDir = new Directory(config.output)..createSync(recursive: true);
59+
outputDir = Directory(config.output)..createSync(recursive: true);
6060
generators.forEach((g) => g.onFileCreated.listen(logProgress));
6161
}
6262

@@ -65,19 +65,19 @@ class Dartdoc extends PackageBuilder {
6565
static Future<Dartdoc> withDefaultGenerators(
6666
DartdocGeneratorOptionContext config) async {
6767
List<Generator> generators = await initGenerators(config);
68-
return new Dartdoc._(config, generators);
68+
return Dartdoc._(config, generators);
6969
}
7070

7171
/// An asynchronous factory method that builds
7272
static Future<Dartdoc> withEmptyGenerator(DartdocOptionContext config) async {
7373
List<Generator> generators = await initEmptyGenerators(config);
74-
return new Dartdoc._(config, generators);
74+
return Dartdoc._(config, generators);
7575
}
7676

7777
/// Basic synchronous factory that gives a stripped down Dartdoc that won't
7878
/// use generators. Useful for testing.
7979
factory Dartdoc.withoutGenerators(DartdocOptionContext config) {
80-
return new Dartdoc._(config, []);
80+
return Dartdoc._(config, []);
8181
}
8282

8383
Stream<String> get onCheckProgress => _onCheckProgress.stream;
@@ -90,7 +90,7 @@ class Dartdoc extends PackageBuilder {
9090
/// thrown if dartdoc fails in an expected way, for example if there is an
9191
/// analysis error in the code.
9292
Future<DartdocResults> generateDocsBase() async {
93-
Stopwatch _stopwatch = new Stopwatch()..start();
93+
Stopwatch _stopwatch = Stopwatch()..start();
9494
double seconds;
9595
packageGraph = await buildPackageGraph();
9696
seconds = _stopwatch.elapsedMilliseconds / 1000.0;
@@ -125,23 +125,21 @@ class Dartdoc extends PackageBuilder {
125125
logInfo(
126126
"Documented ${packageGraph.localPublicLibraries.length} public librar${packageGraph.localPublicLibraries.length == 1 ? 'y' : 'ies'} "
127127
"in ${seconds.toStringAsFixed(1)} seconds");
128-
return new DartdocResults(
129-
config.topLevelPackageMeta, packageGraph, outputDir);
128+
return DartdocResults(config.topLevelPackageMeta, packageGraph, outputDir);
130129
}
131130

132131
Future<DartdocResults> generateDocs() async {
133132
logPrint("Documenting ${config.topLevelPackageMeta}...");
134133

135134
DartdocResults dartdocResults = await generateDocsBase();
136135
if (dartdocResults.packageGraph.localPublicLibraries.isEmpty) {
137-
throw new DartdocFailure(
138-
"dartdoc could not find any libraries to document");
136+
throw DartdocFailure("dartdoc could not find any libraries to document");
139137
}
140138

141139
final int errorCount =
142140
dartdocResults.packageGraph.packageWarningCounter.errorCount;
143141
if (errorCount > 0) {
144-
throw new DartdocFailure(
142+
throw DartdocFailure(
145143
"dartdoc encountered $errorCount} errors while processing.");
146144
}
147145
logInfo(
@@ -156,7 +154,7 @@ class Dartdoc extends PackageBuilder {
156154
// Ordinarily this would go in [Package.warn], but we don't actually know what
157155
// ModelElement to warn on yet.
158156
Warnable warnOnElement;
159-
Set<Warnable> referredFromElements = new Set();
157+
Set<Warnable> referredFromElements = Set();
160158
Set<Warnable> warnOnElements;
161159

162160
// Make all paths relative to origin.
@@ -202,7 +200,7 @@ class Dartdoc extends PackageBuilder {
202200
String indexJson = path.joinAll([normalOrigin, 'index.json']);
203201
bool foundIndexJson = false;
204202
for (FileSystemEntity f
205-
in new Directory(normalOrigin).listSync(recursive: true)) {
203+
in Directory(normalOrigin).listSync(recursive: true)) {
206204
var fullPath = path.normalize(f.path);
207205
if (f is Directory) {
208206
continue;
@@ -240,7 +238,7 @@ class Dartdoc extends PackageBuilder {
240238
// This is extracted to save memory during the check; be careful not to hang
241239
// on to anything referencing the full file and doc tree.
242240
Tuple2<Iterable<String>, String> _getStringLinksAndHref(String fullPath) {
243-
File file = new File("$fullPath");
241+
File file = File("$fullPath");
244242
if (!file.existsSync()) {
245243
return null;
246244
}
@@ -256,21 +254,21 @@ class Dartdoc extends PackageBuilder {
256254
.where((href) => href != null)
257255
.toList();
258256

259-
return new Tuple2(stringLinks, baseHref);
257+
return Tuple2(stringLinks, baseHref);
260258
}
261259

262260
void _doSearchIndexCheck(
263261
PackageGraph packageGraph, String origin, Set<String> visited) {
264262
String fullPath = path.joinAll([origin, 'index.json']);
265263
String indexPath = path.joinAll([origin, 'index.html']);
266-
File file = new File("$fullPath");
264+
File file = File("$fullPath");
267265
if (!file.existsSync()) {
268266
return null;
269267
}
270-
JsonDecoder decoder = new JsonDecoder();
268+
JsonDecoder decoder = JsonDecoder();
271269
List jsonData = decoder.convert(file.readAsStringSync());
272270

273-
Set<String> found = new Set();
271+
Set<String> found = Set();
274272
found.add(fullPath);
275273
// The package index isn't supposed to be in the search, so suppress the
276274
// warning.
@@ -322,9 +320,9 @@ class Dartdoc extends PackageBuilder {
322320
// here instead -- occasionally, very large jobs have overflowed
323321
// the stack without this.
324322
// (newPathToCheck, newFullPath)
325-
Set<Tuple2<String, String>> toVisit = new Set();
323+
Set<Tuple2<String, String>> toVisit = Set();
326324

327-
final RegExp ignoreHyperlinks = new RegExp(r'^(https:|http:|mailto:|ftp:)');
325+
final RegExp ignoreHyperlinks = RegExp(r'^(https:|http:|mailto:|ftp:)');
328326
for (String href in stringLinks) {
329327
if (!href.startsWith(ignoreHyperlinks)) {
330328
Uri uri;
@@ -345,7 +343,7 @@ class Dartdoc extends PackageBuilder {
345343
String newFullPath = path.joinAll([origin, newPathToCheck]);
346344
newFullPath = path.normalize(newFullPath);
347345
if (!visited.contains(newFullPath)) {
348-
toVisit.add(new Tuple2(newPathToCheck, newFullPath));
346+
toVisit.add(Tuple2(newPathToCheck, newFullPath));
349347
visited.add(newFullPath);
350348
}
351349
}
@@ -366,7 +364,7 @@ class Dartdoc extends PackageBuilder {
366364
assert(_hrefs == null);
367365
_hrefs = packageGraph.allHrefs;
368366

369-
final Set<String> visited = new Set();
367+
final Set<String> visited = Set();
370368
final String start = 'index.html';
371369
logInfo('Validating docs...');
372370
_doCheck(packageGraph, origin, visited, start);

0 commit comments

Comments
 (0)