Skip to content

Commit

Permalink
Fix prefer_equal_for_default_values in analyzer.
Browse files Browse the repository at this point in the history
Change-Id: Ia72a2ac31d6cf6329c78baad6954ac9595a6c45a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127448
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
scheglov authored and commit-bot@chromium.org committed Dec 6, 2019
1 parent f772b57 commit eee20b4
Show file tree
Hide file tree
Showing 75 changed files with 305 additions and 304 deletions.
3 changes: 0 additions & 3 deletions pkg/analyzer/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ analyzer:
avoid_return_types_on_setters: ignore
empty_catches: ignore
prefer_iterable_wheretype: ignore
# TODO(srawlins): At the time of writing, 230 violations in lib/. The fix
# is mechanical, via `dartfmt --fix-named-default-separator`.
prefer_equal_for_default_values: ignore
# TODO(srawlins): At the time of writing, 2600 violations in lib/. The fix
# is mechanical, via `dartfmt --fix-doc-comments`, but not worth the churn
# today.
Expand Down
12 changes: 6 additions & 6 deletions pkg/analyzer/lib/analyzer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export 'package:analyzer/src/generated/utilities_dart.dart';
@Deprecated('Please use parseString instead')
CompilationUnit parseCompilationUnit(String contents,
{String name,
bool suppressErrors: false,
bool parseFunctionBodies: true,
bool suppressErrors = false,
bool parseFunctionBodies = true,
FeatureSet featureSet}) {
// TODO(paulberry): make featureSet a required parameter
featureSet ??= FeatureSet.fromEnableFlags([]);
Expand All @@ -74,8 +74,8 @@ CompilationUnit parseCompilationUnit(String contents,
/// callers that don't require function bodies should simply ignore them.
@Deprecated('Please use parseFile2 instead')
CompilationUnit parseDartFile(String path,
{bool suppressErrors: false,
bool parseFunctionBodies: true,
{bool suppressErrors = false,
bool parseFunctionBodies = true,
FeatureSet featureSet}) {
// TODO(paulberry): Make featureSet a required parameter
featureSet ??= FeatureSet.fromEnableFlags([]);
Expand Down Expand Up @@ -115,7 +115,7 @@ CompilationUnit parseDartFile(String path,
/// directives should simply ignore the rest of the parse result.
@Deprecated('Please use parseString instead')
CompilationUnit parseDirectives(String contents,
{String name, bool suppressErrors: false, FeatureSet featureSet}) {
{String name, bool suppressErrors = false, FeatureSet featureSet}) {
// TODO(paulberry): make featureSet a required parameter.
featureSet ??= FeatureSet.fromEnableFlags([]);
var source = new StringSource(contents, name);
Expand All @@ -141,7 +141,7 @@ String stringLiteralToString(StringLiteral literal) {

CompilationUnit _parseSource(
String contents, Source source, FeatureSet featureSet,
{bool suppressErrors: false, bool parseFunctionBodies: true}) {
{bool suppressErrors = false, bool parseFunctionBodies = true}) {
var reader = new CharSequenceReader(contents);
var errorCollector = new _ErrorCollector();
var scanner = new Scanner(source, reader, errorCollector)
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/dart/analysis/context_locator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ abstract class ContextLocator {
@deprecated
List<AnalysisContext> locateContexts(
{@required List<String> includedPaths,
List<String> excludedPaths: const <String>[],
List<String> excludedPaths = const <String>[],
String optionsFile,
String packagesFile,
String sdkPath});
Expand Down
6 changes: 3 additions & 3 deletions pkg/analyzer/lib/dart/analysis/utilities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ParseStringResult parseFile(
{@required String path,
ResourceProvider resourceProvider,
@required FeatureSet featureSet,
bool throwIfDiagnostics: true}) {
bool throwIfDiagnostics = true}) {
if (featureSet == null) {
throw ArgumentError('A non-null feature set must be provided.');
}
Expand Down Expand Up @@ -81,7 +81,7 @@ ParseStringResult parseFile2(
{@required String path,
ResourceProvider resourceProvider,
@required FeatureSet featureSet,
bool throwIfDiagnostics: true}) {
bool throwIfDiagnostics = true}) {
return parseFile(
path: path,
resourceProvider: resourceProvider,
Expand Down Expand Up @@ -110,7 +110,7 @@ ParseStringResult parseString(
{@required String content,
FeatureSet featureSet,
String path,
bool throwIfDiagnostics: true}) {
bool throwIfDiagnostics = true}) {
featureSet ??= FeatureSet.fromEnableFlags([]);
var source = StringSource(content, path);
var reader = CharSequenceReader(content);
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/dart/ast/ast_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ abstract class AstFactory {
@required SimpleIdentifier identifier});

/// Returns a newly created identifier.
SimpleIdentifier simpleIdentifier(Token token, {bool isDeclaration: false});
SimpleIdentifier simpleIdentifier(Token token, {bool isDeclaration = false});

/// Returns a newly created simple string literal.
SimpleStringLiteral simpleStringLiteral(Token literal, String value);
Expand Down
6 changes: 3 additions & 3 deletions pkg/analyzer/lib/dart/element/type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ abstract class InterfaceType implements ParameterizedType {
/// The [library] determines if a private member name is visible, and does not
/// need to be supplied for public names.
PropertyAccessorElement lookUpInheritedGetter(String name,
{LibraryElement library, bool thisType: true});
{LibraryElement library, bool thisType = true});

/// Look up the member with the given [name] in this type and all extended
/// and mixed in classes, starting from this type. If the search fails,
Expand All @@ -377,7 +377,7 @@ abstract class InterfaceType implements ParameterizedType {
/// The [library] determines if a private member name is visible, and does not
/// need to be supplied for public names.
MethodElement lookUpInheritedMethod(String name,
{LibraryElement library, bool thisType: true});
{LibraryElement library, bool thisType = true});

/// Look up the member with the given [name] in this type and all extended
/// and mixed in classes, and by default including [thisType]. If the search
Expand All @@ -389,7 +389,7 @@ abstract class InterfaceType implements ParameterizedType {
/// The [library] determines if a private member name is visible, and does not
/// need to be supplied for public names.
PropertyAccessorElement lookUpInheritedSetter(String name,
{LibraryElement library, bool thisType: true});
{LibraryElement library, bool thisType = true});

/// Return the element representing the method that results from looking up
/// the method with the given [name] in this class with respect to the given
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/file_system/memory_file_system.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MemoryResourceProvider implements ResourceProvider {
final pathos.Context _pathContext;

MemoryResourceProvider(
{pathos.Context context, @deprecated bool isWindows: false})
{pathos.Context context, @deprecated bool isWindows = false})
: _pathContext = (context ??= pathos.style == pathos.Style.windows
// On Windows, ensure that the current drive matches
// the drive inserted by MemoryResourceProvider.convertPath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AnalysisOptionsProvider {
/// Recursively merge options referenced by an include directive
/// and remove the include directive from the resulting options map.
/// Return an empty options map if the file does not exist.
YamlMap getOptions(Folder root, {bool crawlUp: false}) {
YamlMap getOptions(Folder root, {bool crawlUp = false}) {
File optionsFile = getOptionsFile(root, crawlUp: crawlUp);
if (optionsFile == null) {
return new YamlMap();
Expand All @@ -40,7 +40,7 @@ class AnalysisOptionsProvider {
///
/// The given [root] directory will be searched first. If no file is found and
/// if [crawlUp] is `true`, then enclosing directories will be searched.
File getOptionsFile(Folder root, {bool crawlUp: false}) {
File getOptionsFile(Folder root, {bool crawlUp = false}) {
Resource resource;
for (Folder folder = root; folder != null; folder = folder.parent) {
resource = folder.getChild(AnalysisEngine.ANALYSIS_OPTIONS_FILE);
Expand Down
4 changes: 2 additions & 2 deletions pkg/analyzer/lib/src/analysis_options/error/option_codes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class AnalysisOptionsHintCode extends ErrorCode {
const AnalysisOptionsHintCode(
'DEPRECATED_ANALYSIS_OPTIONS_FILE_NAME',
"The name of the analysis options file {0} is deprecated;"
" consider renaming it to analysis_options.yaml.");
" consider renaming it to analysis_options.yaml.");

/**
* An error code indicating that the enablePreviewDart2 setting is deprecated.
Expand Down Expand Up @@ -192,7 +192,7 @@ class AnalysisOptionsWarningCode extends ErrorCode {
const AnalysisOptionsWarningCode(
'UNSUPPORTED_OPTION_WITH_LEGAL_VALUE',
"The option '{1}' isn't supported by '{0}'. "
"Try using the only supported option: '{2}'.");
"Try using the only supported option: '{2}'.");

/**
* An error code indicating that a plugin is being configured with an
Expand Down
3 changes: 2 additions & 1 deletion pkg/analyzer/lib/src/command_line/arguments.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ DartSdkManager createDartSdkManager(
* TODO(danrubel) Update DDC to support all the options defined in this method
* then remove the [ddc] named argument from this method.
*/
void defineAnalysisArguments(ArgParser parser, {bool hide: true, ddc: false}) {
void defineAnalysisArguments(ArgParser parser,
{bool hide = true, ddc = false}) {
parser.addOption(sdkPathOption,
help: 'The path to the Dart SDK.', hide: ddc && hide);
parser.addOption(analysisOptionsFileOption,
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/context/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ class ContextBuilder {
* path. This allows cli to locate what *would* have been the analysis options
* file path, and super-impose the defaults over it in-place.
*/
File getOptionsFile(String path, {bool forceSearch: false}) {
File getOptionsFile(String path, {bool forceSearch = false}) {
if (!forceSearch) {
String filePath = builderOptions.defaultAnalysisOptionsFilePath;
if (filePath != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AnalysisContextCollectionImpl implements AnalysisContextCollection {

/// Initialize a newly created analysis context manager.
AnalysisContextCollectionImpl(
{bool enableIndex: false,
{bool enableIndex = false,
@required List<String> includedPaths,
List<String> excludedPaths,
ResourceProvider resourceProvider,
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/dart/analysis/context_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ContextBuilderImpl implements ContextBuilder {
AnalysisContext createContext(
{@required ContextRoot contextRoot,
DeclaredVariables declaredVariables,
bool enableIndex: false,
bool enableIndex = false,
List<String> librarySummaryPaths,
@deprecated PerformanceLog performanceLog,
@deprecated AnalysisDriverScheduler scheduler,
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/dart/analysis/context_locator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ContextLocatorImpl implements ContextLocator {
@override
List<AnalysisContext> locateContexts(
{@required List<String> includedPaths,
List<String> excludedPaths: const <String>[],
List<String> excludedPaths = const <String>[],
String optionsFile,
String packagesFile,
String sdkPath}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class ReferenceCollector {
_visitConstructor(node.type, node.name);
}

void _visitExpression(Expression node, {bool get: true, bool set: false}) {
void _visitExpression(Expression node, {bool get = true, bool set = false}) {
if (node == null) return;

if (node is AdjacentStrings) {
Expand Down
18 changes: 9 additions & 9 deletions pkg/analyzer/lib/src/dart/analysis/driver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,10 @@ class AnalysisDriver implements AnalysisDriverGeneric {
this.contextRoot,
SourceFactory sourceFactory,
this._analysisOptions,
{this.disableChangesAndCacheAllResults: false,
this.enableIndex: false,
{this.disableChangesAndCacheAllResults = false,
this.enableIndex = false,
SummaryDataStore externalSummaries,
bool retainDataForTesting: false})
bool retainDataForTesting = false})
: _logger = logger,
_sourceFactory = sourceFactory,
_externalSummaries = externalSummaries,
Expand Down Expand Up @@ -783,7 +783,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
/// of the files previously reported using [changeFile]), prior to the next
/// time the analysis state transitions to "idle".
Future<ResolvedUnitResult> getResult(String path,
{bool sendCachedToStream: false}) {
{bool sendCachedToStream = false}) {
_throwIfNotAbsolutePath(path);
if (!_fsState.hasUri(path)) {
return new Future.value();
Expand Down Expand Up @@ -1212,9 +1212,9 @@ class AnalysisDriver implements AnalysisDriverGeneric {
/// the resolved signature of the file in its library is the same as the one
/// that was the most recently produced to the client.
AnalysisResult _computeAnalysisResult(String path,
{bool withUnit: false,
bool asIsIfPartWithoutLibrary: false,
bool skipIfSameSignature: false}) {
{bool withUnit = false,
bool asIsIfPartWithoutLibrary = false,
bool skipIfSameSignature = false}) {
FileState file = _fsState.getFileForPath(path);

// Prepare the library - the file itself, or the known library.
Expand Down Expand Up @@ -1392,7 +1392,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
}

UnitElementResult _computeUnitElement(String path,
{bool asIsIfPartWithoutLibrary: false}) {
{bool asIsIfPartWithoutLibrary = false}) {
FileState file = _fsState.getFileForPath(path);

// Prepare the library - the file itself, or the known library.
Expand Down Expand Up @@ -1420,7 +1420,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
}

String _computeUnitElementSignature(String path,
{bool asIsIfPartWithoutLibrary: false}) {
{bool asIsIfPartWithoutLibrary = false}) {
FileState file = _fsState.getFileForPath(path);

// Prepare the library - the file itself, or the known library.
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/dart/analysis/experiments.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ExperimentStatus with _CurrentState implements FeatureSet {
/// enabled features is used as the starting point.
@visibleForTesting
ExperimentStatus.forTesting(
{String sdkVersion, List<Feature> additionalFeatures: const []})
{String sdkVersion, List<Feature> additionalFeatures = const []})
: this._(enableFlagsForTesting(
sdkVersion: sdkVersion, additionalFeatures: additionalFeatures));

Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/dart/analysis/experiments_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ List<bool> decodeFlags(List<String> flags) {
/// If [sdkVersion] is not supplied (or is `null`), then the current set of
/// enabled features is used as the starting point.
List<bool> enableFlagsForTesting(
{String sdkVersion, List<Feature> additionalFeatures: const []}) {
{String sdkVersion, List<Feature> additionalFeatures = const []}) {
var flags = decodeFlags([]);
if (sdkVersion != null) {
flags = restrictEnableFlagsToVersion(flags, Version.parse(sdkVersion));
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/dart/analysis/file_byte_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class FileByteStore implements ByteStore {
* If the same cache path is used from more than one isolate of the same
* process, then a unique [tempNameSuffix] must be provided for each isolate.
*/
FileByteStore(this._cachePath, {String tempNameSuffix: ''})
FileByteStore(this._cachePath, {String tempNameSuffix = ''})
: _tempSuffix =
'-temp-$pid${tempNameSuffix.isEmpty ? '' : '-$tempNameSuffix'}';

Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/dart/analysis/file_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class FileState {
*
* Return `true` if the API signature changed since the last refresh.
*/
bool refresh({bool allowCached: false}) {
bool refresh({bool allowCached = false}) {
counterFileStateRefresh++;

var timerWasRunning = timerFileStateRefresh.isRunning;
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/dart/ast/ast_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ class AstFactoryImpl extends AstFactory {
requiredKeyword, keyword, type, identifier);

@override
SimpleIdentifier simpleIdentifier(Token token, {bool isDeclaration: false}) {
SimpleIdentifier simpleIdentifier(Token token, {bool isDeclaration = false}) {
if (isDeclaration) {
return new DeclaredSimpleIdentifier(token);
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/analyzer/lib/src/dart/element/inheritance_manager3.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ class InheritanceManager3 {
ExecutableElement getMember(
InterfaceType type,
Name name, {
bool concrete: false,
int forMixinIndex: -1,
bool forSuper: false,
bool concrete = false,
int forMixinIndex = -1,
bool forSuper = false,
}) {
var interface = getInterface(type);
if (forSuper) {
Expand Down
Loading

0 comments on commit eee20b4

Please sign in to comment.