Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- Fixed unexpected avoid_unnecessary_type_assertions #143

Closed
wants to merge 4 commits into from
Closed
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
15 changes: 8 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
- Fixed `avoid_unused_parameters` to report positional parameters from typedef if their name are not underscores.
- Improvement for `avoid_returning_widget` lint:
- ignores methods that override ones that return widget (build() for example)
- no longer allows returning widgets from methods/functions named build
- no longer allows returning widgets from methods/functions named build
- Fixed unexpected avoid_unnecessary_type_assertions

## 0.1.4

Expand Down Expand Up @@ -90,12 +91,12 @@
- Update `dart_code_metrics` dependency to 5.7.3
- Rename deprecated `member-ordering-extended` to `member-ordering`
- Add rule for widgets methods order configuration:
- initState
- build
- didChangeDependencies
- didUpdateWidget
- deactivate
- dispose
- initState
- build
- didChangeDependencies
- didUpdateWidget
- deactivate
- dispose

## 0.0.15

Expand Down
2 changes: 1 addition & 1 deletion lib/src/utils/typecast_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class TypeCast {

final objectCastedType = castTypeInHierarchy();
if (objectCastedType == null) {
return isReversed;
return false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

With this fix, it won't lint the following situation:
изображение

}

final objectTypeCast = TypeCast(
Expand Down
13 changes: 12 additions & 1 deletion lint_test/avoid_unnecessary_type_assertions_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore_for_file: prefer_const_declarations
// ignore_for_file: prefer_const_declarations, prefer_match_file_name, unused_element
// ignore_for_file: unnecessary_nullable_for_final_variable_declarations
// ignore_for_file: unnecessary_type_check
// ignore_for_file: unused_local_variable
Expand Down Expand Up @@ -34,3 +34,14 @@ void fun() {
// casting `Type? is Type` is allowed
final castedD = nullableD is double;
}

class _A {}

class _B extends _A {}

class _C extends _A {}

void noLint() {
final _A a = _B();
if (a is! _C) return;
}
Loading