Skip to content

Commit

Permalink
Removed deprecated field
Browse files Browse the repository at this point in the history
  • Loading branch information
nestorsgarzonc committed Sep 25, 2024
1 parent 872e3a3 commit e250e94
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 16 deletions.
2 changes: 0 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ linter:
# - avoid_print
- avoid_private_typedef_functions
# - avoid_redundant_argument_values
- avoid_returning_null
- avoid_returning_null_for_future
- avoid_returning_this
- avoid_setters_without_getters
- avoid_slow_async_io
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'dart:io';

import 'package:collection/collection.dart';
import 'package:path/path.dart';
import 'package:source_span/source_span.dart';
import 'package:yaml/yaml.dart';
Expand Down Expand Up @@ -79,7 +77,7 @@ class LintAnalysisOptionsValidator {

return null;
})
.whereNotNull()
.nonNulls
.toList();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class _Visitor extends RecursiveAstVisitor<void> {
? _TypedClassElement(typeArg, element)
: null;
})
.whereNotNull()
.nonNulls
.toList();
if (typeArgElements.length < type.typeArguments.length) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class _Visitor extends GeneralizingAstVisitor<void> {
.whereNot((field) => field.isStatic)
.map((declaration) =>
declaration.fields.variables.firstOrNull?.name.lexeme)
.whereNotNull()
.nonNulls
.toSet();

if (isMixin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ class _ConfigParser {
? List<String>.from(config[_orderConfig] as Iterable)
: _defaultOrderList;

return order.map(_parseGroup).whereNotNull().toList();
return order.map(_parseGroup).nonNulls.toList();
}

static List<_MemberGroup> parseWidgetsOrder(Map<String, Object> config) {
final widgetsOrder = config[_widgetsOrderConfig] is Iterable
? List<String>.from(config[_widgetsOrderConfig] as Iterable)
: _defaultWidgetsOrderList;

return widgetsOrder.map(_parseGroup).whereNotNull().toList();
return widgetsOrder.map(_parseGroup).nonNulls.toList();
}

static bool parseAlphabetize(Map<String, Object> config) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class _FieldMemberGroup extends _MemberGroup {
factory _FieldMemberGroup.parse(FieldDeclaration declaration) {
final annotation = declaration.metadata
.map((metadata) => _Annotation.parse(metadata.name.name))
.whereNotNull()
.nonNulls
.firstOrNull;
final modifier =
Identifier.isPrivateName(declaration.fields.variables.first.name.lexeme)
Expand Down Expand Up @@ -114,7 +114,7 @@ class _MethodMemberGroup extends _MemberGroup {
final methodName = declaration.name.lexeme;
final annotation = declaration.metadata
.map((metadata) => _Annotation.parse(metadata.name.name))
.whereNotNull()
.nonNulls
.firstOrNull;
final modifier = Identifier.isPrivateName(methodName)
? _Modifier.private
Expand Down Expand Up @@ -164,7 +164,7 @@ class _ConstructorMemberGroup extends _MemberGroup {
factory _ConstructorMemberGroup.parse(ConstructorDeclaration declaration) {
final annotation = declaration.metadata
.map((metadata) => _Annotation.parse(metadata.name.name))
.whereNotNull()
.nonNulls
.firstOrNull;
final name = declaration.name;
final isFactory = declaration.factoryKeyword != null;
Expand Down Expand Up @@ -218,7 +218,7 @@ class _GetSetMemberGroup extends _MemberGroup {
factory _GetSetMemberGroup.parse(MethodDeclaration declaration) {
final annotation = declaration.metadata
.map((metadata) => _Annotation.parse(metadata.name.name))
.whereNotNull()
.nonNulls
.firstOrNull;
final type = declaration.isGetter ? _MemberType.getter : _MemberType.setter;
final modifier = Identifier.isPrivateName(declaration.name.lexeme)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class _Visitor extends IntlBaseVisitor {

addIssues(checkedItems
.where((arg) => !argsNames.contains(arg?.lexeme))
.whereNotNull()
.nonNulls
.map(issueFactory));
}
}
Expand Down
5 changes: 3 additions & 2 deletions lib/src/analyzers/unused_code_analyzer/used_code_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:collection/collection.dart';

import '../../utils/flutter_types_utils.dart';
import 'models/file_elements_usage.dart';
Expand All @@ -22,7 +21,7 @@ class UsedCodeVisitor extends RecursiveAstVisitor<void> {
final uri = config.resolvedUri;

return (uri is DirectiveUriWithSource) ? uri.source.fullName : null;
}).whereNotNull();
}).nonNulls;
final mainImport = node.element?.importedLibrary?.source.fullName;

final allPaths = {if (mainImport != null) mainImport, ...paths};
Expand Down Expand Up @@ -252,9 +251,11 @@ class UsedCodeVisitor extends RecursiveAstVisitor<void> {
final parent = namedType.parent;
if (parent is TypeArgumentList) {
final grandParent = parent.parent;

return grandParent is NamedType &&
isWidgetStateOrSubclass(grandParent.type);
}

return false;
}
}

0 comments on commit e250e94

Please sign in to comment.