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

=> Dart 3.0! #4267

Merged
merged 3 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ linter:
# - combinators_ordering
# - close_sinks # https://github.com/dart-lang/linter/issues/268
- comment_references
- dangling_library_doc_comments
- directives_ordering
- discarded_futures
- join_return_with_assignment
Expand Down Expand Up @@ -71,6 +72,7 @@ linter:
- throw_in_finally
# - type_annotate_public_apis
- unawaited_futures # pedantic
- unnecessary_breaks
- unnecessary_final
- unnecessary_lambdas
- unnecessary_null_checks
Expand Down
2 changes: 2 additions & 0 deletions lib/src/ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.

/// Common AST helpers.
library;

import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/syntactic_entity.dart';
import 'package:analyzer/dart/ast/token.dart';
Expand Down
27 changes: 8 additions & 19 deletions lib/src/rules/prefer_contains.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,6 @@ class _Visitor extends SimpleAstVisitor<void> {
}
}

TokenType _invertedTokenType(TokenType type) {
switch (type) {
case TokenType.LT_EQ:
return TokenType.GT_EQ;

case TokenType.LT:
return TokenType.GT;

case TokenType.GT:
return TokenType.LT;

case TokenType.GT_EQ:
return TokenType.LT_EQ;

default:
return type;
}
}

/// Returns whether [expression] is an invocation of `Iterable.indexOf` or
/// `String.indexOf`, which is not assigned to a value.
bool _isUnassignedIndexOf(Expression expression) {
Expand Down Expand Up @@ -193,4 +174,12 @@ class _Visitor extends SimpleAstVisitor<void> {

return true;
}

static TokenType _invertedTokenType(TokenType type) => switch (type) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks so nice!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bonus points for being generated by our assist. 🥳

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For points, you could make this an extension on TokenType 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TokenType.LT_EQ => TokenType.GT_EQ,
TokenType.LT => TokenType.GT,
TokenType.GT => TokenType.LT,
TokenType.GT_EQ => TokenType.LT_EQ,
_ => type
};
}
2 changes: 0 additions & 2 deletions lib/src/util/unrelated_types_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ abstract class UnrelatedTypesProcessors extends SimpleAstVisitor<void> {
typeArgument.getDisplayString(withNullability: true),
]);
}
break;

case ExpectedArgumentKind.assignableToCollection:
if (!typeSystem.isAssignableTo(argumentType, collectionType)) {
Expand All @@ -136,7 +135,6 @@ abstract class UnrelatedTypesProcessors extends SimpleAstVisitor<void> {
collectionType.getDisplayString(withNullability: true),
]);
}
break;

case ExpectedArgumentKind.assignableToIterableOfTypeArgument:
var iterableType =
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository: https://github.com/dart-lang/linter
documentation: https://dart-lang.github.io/linter/lints

environment:
sdk: '>=2.17.0 <3.0.0'
sdk: ^3.0.0-0

dependencies:
analyzer: ^5.10.0
Expand Down
5 changes: 0 additions & 5 deletions tool/canonical/scorecard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,25 +197,20 @@ class LintScore {
case Detail.rule:
sb.write(
' [`$name`](https://dart-lang.github.io/linter/lints/$name.html) |');
break;
case Detail.fix:
var status = unfixableLints.contains(name)
? skip
: (hasFix ? checkMark : consider);
sb.write(' $status |');
break;
case Detail.bulk:
var status = unfixableLints.contains(name)
? skip
: (hasBulkFix ? checkMark : consider);
sb.write(' $status |');
break;
case Detail.status:
sb.write('${!state.isStable ? ' **${state.label}** ' : ""} |');
break;
case Detail.bugs:
sb.write(' ${bugReferences.join(", ")} |');
break;
}
}
return sb.toString();
Expand Down
8 changes: 0 additions & 8 deletions tool/scorecard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,29 +151,21 @@ class LintScore {
case Detail.rule:
sb.write(
' [$name](https://dart-lang.github.io/linter/lints/$name.html) |');
break;
case Detail.linter:
sb.write(' ${since!.sinceLinter} |');
break;
case Detail.sdk:
sb.write(' ${since!.sinceDartSdk} |');
break;
case Detail.fix:
sb.write('${hasFix ? " $bulb" : ""} |');
break;
case Detail.flutterUser:
sb.write('${ruleSets.contains('flutter') ? " $checkMark" : ""} |');
break;
case Detail.flutterRepo:
sb.write(
'${ruleSets.contains('flutter_repo') ? " $checkMark" : ""} |');
break;
case Detail.status:
sb.write('${!state.isStable ? ' **${state.label}** ' : ""} |');
break;
case Detail.bugs:
sb.write(' ${bugReferences.join(", ")} |');
break;
}
}
return sb.toString();
Expand Down