Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit e5b0520

Browse files
committed
lints!
1 parent 9f83dd4 commit e5b0520

8 files changed

+52
-65
lines changed

analysis_options.yaml

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,40 @@
11
analyzer:
2-
strong-mode: true
3-
errors:
4-
unused_element: error
5-
unused_import: error
6-
unused_local_variable: error
7-
dead_code: error
2+
strong-mode:
3+
implicit-casts: false
4+
errors:
5+
dead_code: error
6+
override_on_non_overriding_method: error
7+
unused_element: error
8+
unused_import: error
9+
unused_local_variable: error
810
linter:
911
rules:
10-
#- always_declare_return_types
11-
#- always_specify_types
1212
#- annotate_overrides
13-
#- avoid_as
1413
- avoid_empty_else
1514
- avoid_init_to_null
16-
- avoid_null_checks_in_equality_operators
17-
#- avoid_return_types_on_setters
15+
- avoid_return_types_on_setters
1816
- await_only_futures
1917
- camel_case_types
20-
- cancel_subscriptions
21-
#- close_sinks
2218
- comment_references
23-
- constant_identifier_names
2419
- control_flow_in_finally
2520
- directives_ordering
2621
- empty_catches
2722
- empty_constructor_bodies
2823
- empty_statements
2924
- hash_and_equals
3025
- implementation_imports
31-
- iterable_contains_unrelated_type
3226
- library_names
3327
- library_prefixes
34-
- list_remove_unrelated_type
35-
#- non_constant_identifier_names
36-
#- one_member_abstracts
28+
- non_constant_identifier_names
29+
- omit_local_variable_types
3730
- only_throw_errors
38-
- overridden_fields
39-
- package_api_docs
40-
- package_names
41-
- package_prefixed_library_names
4231
- prefer_final_fields
4332
- prefer_is_not_empty
44-
#- public_member_api_docs
33+
#- prefer_single_quotes
4534
- slash_for_doc_comments
46-
#- sort_constructors_first
47-
#- sort_unnamed_constructors_first
48-
- super_goes_last
35+
- test_types_in_equals
4936
- test_types_in_equals
5037
- throw_in_finally
51-
#- type_annotate_public_apis
5238
- type_init_formals
53-
#- unawaited_futures
54-
- unnecessary_brace_in_string_interps
55-
#- unnecessary_getters_setters
5639
- unrelated_type_equality_checks
5740
- valid_regexps

example/app.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void main() {
3232
versionSpan.text = 'v${md.version}';
3333
markdownInput.onKeyUp.listen(_renderMarkdown);
3434

35-
String savedMarkdown = window.localStorage['markdown'];
35+
var savedMarkdown = window.localStorage['markdown'];
3636

3737
if (savedMarkdown != null &&
3838
savedMarkdown.isNotEmpty &&

lib/src/block_parser.dart

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class SetextHeaderSyntax extends BlockSyntax {
221221

222222
bool canParse(BlockParser parser) {
223223
if (!_interperableAsParagraph(parser.current)) return false;
224-
int i = 1;
224+
var i = 1;
225225
while (true) {
226226
var nextLine = parser.peek(i);
227227
if (nextLine == null) {
@@ -241,7 +241,7 @@ class SetextHeaderSyntax extends BlockSyntax {
241241

242242
Node parse(BlockParser parser) {
243243
var lines = <String>[];
244-
var tag;
244+
String tag;
245245
while (!parser.isDone) {
246246
var match = _setextPattern.firstMatch(parser.current);
247247
if (match == null) {
@@ -534,15 +534,13 @@ class OtherTagBlockHtmlSyntax extends BlockTagBlockHtmlSyntax {
534534
/// In practice this means that the syntax dominates; it is allowed to eat
535535
/// many lines, including blank lines, before matching its `endPattern`.
536536
class LongBlockHtmlSyntax extends BlockHtmlSyntax {
537-
final RegExp _pattern;
537+
final RegExp pattern;
538538
final RegExp _endPattern;
539539

540-
LongBlockHtmlSyntax(pattern, endPattern)
541-
: _pattern = new RegExp(pattern),
540+
LongBlockHtmlSyntax(String pattern, String endPattern)
541+
: pattern = new RegExp(pattern),
542542
_endPattern = new RegExp(endPattern);
543543

544-
RegExp get pattern => _pattern;
545-
546544
Node parse(BlockParser parser) {
547545
var childLines = <String>[];
548546
// Eat until we hit [endPattern].
@@ -723,7 +721,7 @@ abstract class ListSyntax extends BlockSyntax {
723721

724722
/// Removes any trailing empty lines and notes whether any items are separated
725723
/// by such lines.
726-
bool removeTrailingEmptyLines(List items) {
724+
bool removeTrailingEmptyLines(List<ListItem> items) {
727725
var anyEmpty = false;
728726
for (var i = 0; i < items.length; i++) {
729727
if (items[i].lines.length == 1) continue;
@@ -803,7 +801,8 @@ class TableSyntax extends BlockSyntax {
803801
}).toList();
804802
}
805803

806-
Node parseRow(BlockParser parser, List<String> alignments, String cellType) {
804+
Element parseRow(
805+
BlockParser parser, List<String> alignments, String cellType) {
807806
var line = parser.current
808807
.replaceFirst(_openingPipe, '')
809808
.replaceFirst(_closingPipe, '');
@@ -812,7 +811,7 @@ class TableSyntax extends BlockSyntax {
812811
var row = <Element>[];
813812
String preCell;
814813

815-
for (String cell in cells) {
814+
for (var cell in cells) {
816815
if (preCell != null) {
817816
cell = preCell + cell;
818817
preCell = null;
@@ -873,7 +872,7 @@ class ParagraphSyntax extends BlockSyntax {
873872
bool lineStartsReflinkDefinition(int i) =>
874873
lines[i].startsWith(_reflinkDefinitionStart);
875874

876-
int i = 0;
875+
var i = 0;
877876
loopOverDefinitions:
878877
while (true) {
879878
// Check for reflink definitions.

lib/src/document.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Document {
3333

3434
/// Parses the given [lines] of Markdown to a series of AST nodes.
3535
List<Node> parseLines(List<String> lines) {
36-
List<Node> nodes = new BlockParser(lines, this).parseLines();
36+
var nodes = new BlockParser(lines, this).parseLines();
3737
_parseInlineContent(nodes);
3838
return nodes;
3939
}
@@ -42,10 +42,10 @@ class Document {
4242
List<Node> parseInline(String text) => new InlineParser(text, this).parse();
4343

4444
void _parseInlineContent(List<Node> nodes) {
45-
for (int i = 0; i < nodes.length; i++) {
45+
for (var i = 0; i < nodes.length; i++) {
4646
var node = nodes[i];
4747
if (node is UnparsedContent) {
48-
List<Node> inlineNodes = parseInline(node.textContent);
48+
var inlineNodes = parseInline(node.textContent);
4949
nodes.removeAt(i);
5050
nodes.insertAll(i, inlineNodes);
5151
i += inlineNodes.length - 1;

lib/src/html_renderer.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ class HtmlRenderer implements NodeVisitor {
105105
return id;
106106
}
107107

108-
int suffix = 2;
109-
String suffixedId = '$id-$suffix';
108+
var suffix = 2;
109+
var suffixedId = '$id-$suffix';
110110
while (uniqueIds.contains(suffixedId)) {
111111
suffixedId = '$id-${suffix++}';
112112
}

lib/src/inline_parser.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,9 @@ class LinkSyntax extends TagSyntax {
383383

384384
return new Link(null, url, title);
385385
} else {
386-
var id;
386+
String id;
387387
String _contents() {
388-
int offset = pattern.pattern.length - 1;
388+
var offset = pattern.pattern.length - 1;
389389
return parser.source.substring(state.startPos + offset, parser.pos);
390390
}
391391

tool/dartdoc-compare.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void main(List<String> arguments) {
2323
..addFlag(_help, abbr: "h", hide: true);
2424

2525
var options = parser.parse(arguments);
26-
if (options[_help]) {
26+
if (options[_help] as bool) {
2727
print(parser.usage);
2828
exitCode = 0;
2929
return;
@@ -36,12 +36,12 @@ void main(List<String> arguments) {
3636
return;
3737
}
3838
var comparer = new DartdocCompare(
39-
options[_dartdocDir],
40-
options[_markdownBefore],
41-
options[_markdownAfter],
42-
absolute(options[_dartdocDir], "bin/dartdoc.dart"),
43-
absolute(options[_dartdocDir], "pubspec.yaml"),
44-
options[_sdk]);
39+
options[_dartdocDir] as String,
40+
options[_markdownBefore] as String,
41+
options[_markdownAfter] as String,
42+
absolute(options[_dartdocDir] as String, "bin/dartdoc.dart"),
43+
absolute(options[_dartdocDir] as String, "pubspec.yaml"),
44+
options[_sdk] as bool);
4545

4646
String path;
4747
if (comparer.sdk) {
@@ -72,15 +72,15 @@ class DartdocCompare {
7272

7373
bool compare(String package) {
7474
// Generate docs with Markdown "A".
75-
var out_before = _runDartdoc(markdownBefore, package);
75+
var outBefore = _runDartdoc(markdownBefore, package);
7676

7777
// Generate docs with Markdown "B".
78-
var out_after = _runDartdoc(markdownAfter, package);
78+
var outAfter = _runDartdoc(markdownAfter, package);
7979

8080
// Compare outputs
81-
var diffOptions = ["-r", "-B", out_before, out_after];
81+
var diffOptions = ["-r", "-B", outBefore, outAfter];
8282
var result = Process.runSync("diff", diffOptions, runInShell: true);
83-
var nlines = "\n".allMatches(result.stdout).length;
83+
var nlines = "\n".allMatches(result.stdout as String).length;
8484
print("Diff lines: $nlines");
8585
print("diff ${diffOptions.join(" ")}");
8686
return result.exitCode == 0;
@@ -120,7 +120,7 @@ class DartdocCompare {
120120
var dartdocPubspec =
121121
loadYaml(new File(dartdocPubspecPath).readAsStringSync()) as Map;
122122
// make modifiable copy
123-
dartdocPubspec = JSON.decode(JSON.encode(dartdocPubspec));
123+
dartdocPubspec = JSON.decode(JSON.encode(dartdocPubspec)) as Map;
124124

125125
dartdocPubspec['dependencies']['markdown'] = {
126126
'git': {

tool/stats.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Future main(List<String> args) async {
4949
return;
5050
}
5151

52-
if (options['help']) {
52+
if (options['help'] as bool) {
5353
print(parser.usage);
5454
return;
5555
}
@@ -67,7 +67,7 @@ Future main(List<String> args) async {
6767
return;
6868
}
6969

70-
final testPrefix = options['flavor'];
70+
final testPrefix = options['flavor'] as String;
7171

7272
var baseUrl = 'http://spec.commonmark.org/0.28/';
7373
ExtensionSet extensionSet;
@@ -343,7 +343,12 @@ class CommonMarkTestCase {
343343
this.markdown, this.html);
344344

345345
factory CommonMarkTestCase.fromJson(Map<String, dynamic> json) {
346-
return new CommonMarkTestCase(json['example'], json['section'],
347-
json['start_line'], json['end_line'], json['markdown'], json['html']);
346+
return new CommonMarkTestCase(
347+
json['example'] as int,
348+
json['section'] as String,
349+
json['start_line'] as int,
350+
json['end_line'] as int,
351+
json['markdown'] as String,
352+
json['html'] as String);
348353
}
349354
}

0 commit comments

Comments
 (0)