use the package:pedantic analysis options (#1951)
diff --git a/analysis_options.yaml b/analysis_options.yaml
index e472853..b4a5769 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -1,3 +1,5 @@
+include: package:pedantic/analysis_options.yaml
+
analyzer:
exclude:
- 'doc/**'
diff --git a/lib/src/dartdoc_options.dart b/lib/src/dartdoc_options.dart
index 13b9d88..50fec98 100644
--- a/lib/src/dartdoc_options.dart
+++ b/lib/src/dartdoc_options.dart
@@ -657,7 +657,7 @@
}
/// Apply the function [visit] to [this] and all children.
- void traverse(void visit(DartdocOption)) {
+ void traverse(void visit(DartdocOption option)) {
visit(this);
_children.values.forEach((d) => d.traverse(visit));
}
@@ -832,7 +832,7 @@
/// Traverse skips this node, because it doesn't represent a real configuration object.
@override
- void traverse(void visitor(DartdocOption)) {
+ void traverse(void visitor(DartdocOption option)) {
_children.values.forEach((d) => d.traverse(visitor));
}
}
@@ -884,12 +884,12 @@
DartdocOptionArgFile(String name, T defaultsTo,
{String abbr,
bool mustExist = false,
- String help: '',
+ String help = '',
bool hide = false,
bool isDir = false,
bool isFile = false,
bool negatable = false,
- bool parentDirOverridesChild: false,
+ bool parentDirOverridesChild = false,
bool splitCommas})
: super(name, defaultsTo, help, isDir, isFile, mustExist, null) {
_abbr = abbr;
@@ -936,10 +936,10 @@
bool _parentDirOverridesChild;
DartdocOptionFileOnly(String name, T defaultsTo,
{bool mustExist = false,
- String help: '',
+ String help = '',
bool isDir = false,
bool isFile = false,
- bool parentDirOverridesChild: false,
+ bool parentDirOverridesChild = false,
T Function(YamlMap, pathLib.Context) convertYamlToType})
: super(name, defaultsTo, help, isDir, isFile, mustExist,
convertYamlToType) {
diff --git a/lib/src/element_type.dart b/lib/src/element_type.dart
index aa6c599..bba26f8 100644
--- a/lib/src/element_type.dart
+++ b/lib/src/element_type.dart
@@ -318,7 +318,7 @@
with GenericTypeAliasElementTypeMixin {
GenericTypeAliasElementType(TypeParameterType t, PackageGraph packageGraph,
ModelElement element, ElementType returnedFrom)
- : super(t, packageGraph, element, returnedFrom) {}
+ : super(t, packageGraph, element, returnedFrom);
}
/// A Callable generic type alias that may or may not have a name.
diff --git a/lib/src/html/html_generator.dart b/lib/src/html/html_generator.dart
index aac3023..b09db48 100644
--- a/lib/src/html/html_generator.dart
+++ b/lib/src/html/html_generator.dart
@@ -128,7 +128,7 @@
this.relCanonicalPrefix,
this.faviconPath,
String toolVersion,
- this.prettyIndexJson: false})
+ this.prettyIndexJson = false})
: this.toolVersion = toolVersion ?? 'unknown';
}
diff --git a/lib/src/io_utils.dart b/lib/src/io_utils.dart
index 9a79602..358d948 100644
--- a/lib/src/io_utils.dart
+++ b/lib/src/io_utils.dart
@@ -36,7 +36,7 @@
///
/// The returned paths are guaranteed to begin with [dir].
Iterable<String> listDir(String dir,
- {bool recursive: false,
+ {bool recursive = false,
Iterable<FileSystemEntity> listDir(Directory dir)}) {
if (listDir == null) listDir = (Directory dir) => dir.listSync();
diff --git a/lib/src/markdown_processor.dart b/lib/src/markdown_processor.dart
index ca97a0c..c71592c 100644
--- a/lib/src/markdown_processor.dart
+++ b/lib/src/markdown_processor.dart
@@ -153,7 +153,7 @@
class MatchingLinkResult {
final ModelElement element;
final bool warn;
- MatchingLinkResult(this.element, {this.warn: true});
+ MatchingLinkResult(this.element, {this.warn = true});
}
class IterableBlockParser extends md.BlockParser {
@@ -933,7 +933,7 @@
class Documentation {
final Canonicalization _element;
- Documentation.forElement(this._element) {}
+ Documentation.forElement(this._element);
bool _hasExtendedDocs;
bool get hasExtendedDocs {
diff --git a/lib/src/model.dart b/lib/src/model.dart
index baa36d9..454d84d 100644
--- a/lib/src/model.dart
+++ b/lib/src/model.dart
@@ -38,7 +38,7 @@
import 'package:analyzer/src/generated/engine.dart' hide AnalysisResult;
import 'package:analyzer/src/generated/java_io.dart';
import 'package:analyzer/src/generated/resolver.dart'
- show Namespace, NamespaceBuilder, InheritanceManager;
+ show Namespace, NamespaceBuilder, InheritanceManager; // ignore: deprecated_member_use
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/source_io.dart';
@@ -1043,9 +1043,9 @@
List<ExecutableElement> get _inheritedElements {
if (__inheritedElements == null) {
Map<String, ExecutableElement> cmap = definingLibrary.inheritanceManager
- .getMembersInheritedFromClasses(element);
+ .getMembersInheritedFromClasses(element); // ignore: deprecated_member_use
Map<String, ExecutableElement> imap = definingLibrary.inheritanceManager
- .getMembersInheritedFromInterfaces(element);
+ .getMembersInheritedFromInterfaces(element); // ignore: deprecated_member_use
__inheritedElements = new List.from(cmap.values)
..addAll(imap.values.where((e) => !cmap.containsKey(e.name)));
}
@@ -1515,7 +1515,7 @@
// Penalty for deprecated libraries.
if (lib.isDeprecated) scoredCandidate.alterScore(-1.0, 'is deprecated');
// Give a big boost if the library has the package name embedded in it.
- if (lib.package.namePieces.intersection(lib.namePieces).length > 0) {
+ if (lib.package.namePieces.intersection(lib.namePieces).isEmpty) {
scoredCandidate.alterScore(1.0, 'embeds package name');
}
// Give a tiny boost for libraries with long names, assuming they're
@@ -1523,7 +1523,7 @@
scoredCandidate.alterScore(.01 * lib.namePieces.length, 'name is long');
// If we don't know the location of this element, return our best guess.
// TODO(jcollins-g): is that even possible?
- assert(!locationPieces.isEmpty);
+ assert(locationPieces.isNotEmpty);
if (locationPieces.isEmpty) return scoredCandidate;
// The more pieces we have of the location in our library name, the more we should boost our score.
scoredCandidate.alterScore(
@@ -1928,7 +1928,7 @@
} else if (hasPublicSetter) {
_documentationFrom.addAll(setter.documentationFrom);
}
- if (_documentationFrom.length == 0 ||
+ if (_documentationFrom.isEmpty||
_documentationFrom.every((e) => e.documentationComment == ''))
_documentationFrom = computeDocumentationFrom;
}
@@ -2376,9 +2376,12 @@
return '${package.baseHref}${library.dirName}/$fileName';
}
+ // ignore: deprecated_member_use
InheritanceManager _inheritanceManager;
+ // ignore: deprecated_member_use
InheritanceManager get inheritanceManager {
if (_inheritanceManager == null) {
+ // ignore: deprecated_member_use
_inheritanceManager = new InheritanceManager(element);
}
return _inheritanceManager;
@@ -3363,7 +3366,7 @@
// Avoid claiming canonicalization for elements outside of this element's
// defining package.
// TODO(jcollins-g): Make the else block unconditional.
- if (!candidateLibraries.isEmpty &&
+ if (candidateLibraries.isNotEmpty &&
!candidateLibraries
.any((l) => l.package == definingLibrary.package)) {
warn(PackageWarning.reexportedPrivateApiAcrossPackages,
@@ -3814,7 +3817,7 @@
}
String linkedParams(
- {bool showMetadata: true, bool showNames: true, String separator: ', '}) {
+ {bool showMetadata = true, bool showNames = true, String separator = ', '}) {
List<Parameter> requiredParams =
parameters.where((Parameter p) => !p.isOptional).toList();
List<Parameter> positionalParams =
@@ -3886,7 +3889,7 @@
String _calculateLinkedName() {
// If we're calling this with an empty name, we probably have the wrong
// element associated with a ModelElement or there's an analysis bug.
- assert(!name.isEmpty ||
+ assert(name.isNotEmpty ||
(this.element is TypeDefiningElement &&
(this.element as TypeDefiningElement).type.name == "dynamic") ||
this is ModelFunction);
@@ -3935,7 +3938,7 @@
var fragmentFile = new File(pathLib.join(dirPath, args['file']));
if (fragmentFile.existsSync()) {
replacement = fragmentFile.readAsStringSync();
- if (!lang.isEmpty) {
+ if (lang.isNotEmpty) {
replacement = replacement.replaceFirst('```', '```$lang');
}
} else {
@@ -4517,7 +4520,7 @@
final fragExtension = '.md';
var file = src + fragExtension;
var region = args['region'] ?? '';
- if (!region.isEmpty) {
+ if (region.isNotEmpty) {
var dir = pathLib.dirname(src);
var basename = pathLib.basenameWithoutExtension(src);
var ext = pathLib.extension(src);
@@ -5241,7 +5244,7 @@
}
}
- if (!c._mixins.isEmpty) {
+ if (c._mixins.isNotEmpty) {
c._mixins.forEach((t) {
_checkAndAddClass(t.element, c);
});
@@ -5249,7 +5252,7 @@
if (c.supertype != null) {
_checkAndAddClass(c.supertype.element, c);
}
- if (!c.interfaces.isEmpty) {
+ if (c.interfaces.isNotEmpty) {
c.interfaces.forEach((t) {
_checkAndAddClass(t.element, c);
});
@@ -6551,7 +6554,7 @@
final UriResolver packageResolver = new PackageMapUriResolver(
PhysicalResourceProvider.INSTANCE, packageMap);
UriResolver sdkResolver;
- if (embedderSdk == null || embedderSdk.urlMappings.length == 0) {
+ if (embedderSdk == null || embedderSdk.urlMappings.isEmpty) {
// The embedder uri resolver has no mappings. Use the default Dart SDK
// uri resolver.
sdkResolver = new DartUriResolver(sdk);
diff --git a/lib/src/special_elements.dart b/lib/src/special_elements.dart
index b2617a0..9da4bcd 100644
--- a/lib/src/special_elements.dart
+++ b/lib/src/special_elements.dart
@@ -87,7 +87,7 @@
class SpecialClasses {
final Map<SpecialClass, Class> _specialClass = {};
- SpecialClasses() {}
+ SpecialClasses();
/// Add a class object that could be special.
void addSpecial(Class aClass) {
diff --git a/pubspec.yaml b/pubspec.yaml
index 673774b..0218ee0 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -39,6 +39,7 @@
io: ^0.3.0
http: ^0.12.0
meta: ^1.0.0
+ pedantic: ^1.5.0
test: ^1.3.0
executables:
diff --git a/test/src/utils.dart b/test/src/utils.dart
index ff6f728..8d7687d 100644
--- a/test/src/utils.dart
+++ b/test/src/utils.dart
@@ -242,7 +242,7 @@
// from flutter:dev/tools/dartdoc.dart, modified
static Future<void> _printStream(Stream<List<int>> stream, Stdout output,
- {String prefix: '', Iterable<String> Function(String line) filter}) {
+ {String prefix = '', Iterable<String> Function(String line) filter}) {
assert(prefix != null);
if (filter == null) filter = (line) => [line];
return stream
@@ -273,7 +273,7 @@
Future<Iterable<Map>> runStreamed(String executable, List<String> arguments,
{String workingDirectory,
Map<String, String> environment,
- bool includeParentEnvironment: true,
+ bool includeParentEnvironment = true,
void Function(String) perLine}) async {
environment ??= {};
environment.addAll(environmentDefaults);
diff --git a/tool/doc_packages.dart b/tool/doc_packages.dart
index ade349f..37e9206 100644
--- a/tool/doc_packages.dart
+++ b/tool/doc_packages.dart
@@ -60,7 +60,7 @@
}
/// Print help if we are passed the help option or invalid arguments.
-void _printUsageAndExit(ArgParser parser, {int exitCode: 0}) {
+void _printUsageAndExit(ArgParser parser, {int exitCode = 0}) {
print('Generate documentation for published pub packages.\n');
print('Usage: _doc_packages [OPTIONS] <package1> <package2>\n');
print(parser.usage);
@@ -194,8 +194,8 @@
Future _exec(String command, List<String> args,
{String cwd,
- bool quiet: false,
- Duration timeout: const Duration(seconds: 60)}) {
+ bool quiet = false,
+ Duration timeout = const Duration(seconds: 60)}) {
return Process.start(command, args, workingDirectory: cwd)
.then((Process process) {
if (!quiet) {
diff --git a/tool/grind.dart b/tool/grind.dart
index 75ab337..dff46a3 100644
--- a/tool/grind.dart
+++ b/tool/grind.dart
@@ -237,7 +237,7 @@
final String branch;
final String pubCachePath;
WarningsCollection(this.tempDir, this.pubCachePath, this.branch)
- : this.warningKeyCounts = new Map() {}
+ : this.warningKeyCounts = new Map();
static const String kPubCachePathReplacement = '_xxxPubDirectoryxxx_';
static const String kTempDirReplacement = '_xxxTempDirectoryxxx_';
@@ -943,7 +943,7 @@
@Task('Verify docs for a package that requires flutter with remote linking')
Future<void> testDartdocFlutterPlugin() async {
WarningsCollection warnings = await _buildDartdocFlutterPluginDocs();
- if (!warnings.warningKeyCounts.isEmpty) {
+ if (warnings.warningKeyCounts.isNotEmpty) {
fail('No warnings should exist in : ${warnings.warningKeyCounts}');
}
// Verify that links to Dart SDK and Flutter SDK go to the flutter site.