Skip to content

Commit fcc0621

Browse files
author
solid-glebvorobey
authored
Fixed LintCode analyzer issues (#178)
* Fixed analyzer issue, fixed linter * Fixed LintCode issue * Fixed LintCode issue * Fixed pubspec * Try to update analyzer version * Try to override analyzer dependency * Add import as instead of hide * Fixed tests fpr custom linter to work correctly
1 parent b93fde7 commit fcc0621

File tree

18 files changed

+513
-42
lines changed

18 files changed

+513
-42
lines changed

example/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ description: A starting point for Dart libraries or applications.
33
publish_to: none
44

55
environment:
6-
sdk: '>=3.0.0 <4.0.0'
6+
sdk: ">=3.0.0 <4.0.0"
77

88
dependencies:
99
flutter:
1010
sdk: flutter
1111

1212
dev_dependencies:
13-
custom_lint: ^0.6.0
13+
custom_lint: ^0.6.7
1414
solid_lints:
1515
path: ../
1616
test: ^1.20.1

lib/src/lints/avoid_unnecessary_type_assertions/avoid_unnecessary_type_assertions_rule.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:analyzer/dart/ast/ast.dart';
22
import 'package:analyzer/dart/element/type.dart';
3-
import 'package:analyzer/error/error.dart';
3+
import 'package:analyzer/error/error.dart' as error;
44
import 'package:analyzer/error/listener.dart';
55
import 'package:analyzer/source/source_range.dart';
66
import 'package:custom_lint_builder/custom_lint_builder.dart';

lib/src/lints/avoid_unnecessary_type_assertions/fixes/avoid_unnecessary_type_assertions_fix.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ class _UnnecessaryTypeAssertionsFix extends DartFix {
88
CustomLintResolver resolver,
99
ChangeReporter reporter,
1010
CustomLintContext context,
11-
AnalysisError analysisError,
12-
List<AnalysisError> others,
11+
error.AnalysisError analysisError,
12+
List<error.AnalysisError> others,
1313
) {
1414
context.registry.addIsExpression((node) {
1515
if (analysisError.sourceRange.intersects(node.sourceRange)) {

lib/src/lints/double_literal_format/double_literal_format_rule.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:analyzer/error/error.dart';
1+
import 'package:analyzer/error/error.dart' as error;
22
import 'package:analyzer/error/listener.dart';
33
import 'package:analyzer/source/source_range.dart';
44
import 'package:custom_lint_builder/custom_lint_builder.dart';

lib/src/lints/double_literal_format/fixes/double_literal_format_fix.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ class _DoubleLiteralFormatFix extends DartFix {
88
CustomLintResolver resolver,
99
ChangeReporter reporter,
1010
CustomLintContext context,
11-
AnalysisError analysisError,
12-
List<AnalysisError> others,
11+
error.AnalysisError analysisError,
12+
List<error.AnalysisError> others,
1313
) {
1414
context.registry.addDoubleLiteral((node) {
1515
// checks that the literal declaration is where our warning is located

lib/src/models/rule_config.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:analyzer/error/error.dart';
1+
import 'package:analyzer/error/error.dart' as error;
22
import 'package:custom_lint_builder/custom_lint_builder.dart';
33

44
/// Type definition of a value factory which allows us to map data from
@@ -38,6 +38,6 @@ class RuleConfig<T extends Object?> {
3838
LintCode get lintCode => LintCode(
3939
name: name,
4040
problemMessage: _problemMessageFactory(parameters),
41-
errorSeverity: ErrorSeverity.WARNING,
41+
errorSeverity: error.ErrorSeverity.WARNING,
4242
);
4343
}

lib/src/utils/parameter_utils.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'package:analyzer/dart/ast/ast.dart';
2-
import 'package:analyzer/error/error.dart';
2+
import 'package:analyzer/error/error.dart' as error;
33
import 'package:custom_lint_builder/custom_lint_builder.dart';
44

55
/// Checks if parameter name consists only of underscores
@@ -12,12 +12,12 @@ bool nameConsistsOfUnderscoresOnly(FormalParameter parameter) {
1212
}
1313

1414
/// Decodes the severity parameter from the string
15-
ErrorSeverity? decodeErrorSeverity(String? severity) {
15+
error.ErrorSeverity? decodeErrorSeverity(String? severity) {
1616
return switch (severity?.toLowerCase()) {
17-
'info' => ErrorSeverity.INFO,
18-
'warning' => ErrorSeverity.WARNING,
19-
'error' => ErrorSeverity.ERROR,
20-
'none' => ErrorSeverity.NONE,
17+
'info' => error.ErrorSeverity.INFO,
18+
'warning' => error.ErrorSeverity.WARNING,
19+
'error' => error.ErrorSeverity.ERROR,
20+
'none' => error.ErrorSeverity.NONE,
2121
_ => null,
2222
};
2323
}
@@ -31,7 +31,7 @@ extension LintCodeCopyWith on LintCode {
3131
String? correctionMessage,
3232
String? uniqueName,
3333
String? url,
34-
ErrorSeverity? errorSeverity,
34+
error.ErrorSeverity? errorSeverity,
3535
}) =>
3636
LintCode(
3737
name: name ?? this.name,

lint_test/alphabetize_by_type_test/alphabetize_by_type_test.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
// ignore_for_file: unused_field
22
// ignore_for_file: unused_element
3+
// ignore_for_file: prefer_match_file_name
34

45
/// Check the `member_ordering` rule
56
/// alphabetical-by-type option enabled
67
78
class CorrectAlphabeticalByTypeClass {
8-
final double e = 1;
99
final int a = 1;
10+
final double e = 1;
1011
}
1112

1213
class WrongAlphabeticalByTypeClass {
13-
final int a = 1;
14+
final int e = 1;
1415

1516
// expect_lint: member_ordering
16-
final double e = 1;
17+
final double a = 1;
1718
}
1819

1920
class PartiallyWrongAlphabeticalByTypeClass {

lint_test/avoid_late_keyword/allow_initialized/avoid_late_keyword_allow_initialized_test.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class ColorTween {}
1414
/// `avoid_late_keyword`
1515
/// allow_initialized option disabled
1616
class AvoidLateKeyword {
17+
/// expect_lint: avoid_late_keyword
1718
late final Animation animation1;
1819

1920
late final animation2 = AnimationController();
@@ -23,27 +24,25 @@ class AvoidLateKeyword {
2324
/// expect_lint: avoid_late_keyword
2425
late final ColorTween colorTween1;
2526

26-
/// expect_lint: avoid_late_keyword
2727
late final colorTween2 = ColorTween();
2828

29-
/// expect_lint: avoid_late_keyword
3029
late final colorTween3 = colorTween2;
3130

31+
/// expect_lint: avoid_late_keyword
3232
late final AnimationController controller1;
3333

34-
/// expect_lint: avoid_late_keyword
3534
late final field1 = 'string';
3635

3736
/// expect_lint: avoid_late_keyword
3837
late final String field2;
3938

40-
/// expect_lint: avoid_late_keyword
4139
late final String field3 = 'string';
4240

4341
/// expect_lint: avoid_late_keyword
4442
late final field4;
4543

4644
void test() {
45+
/// expect_lint: avoid_late_keyword
4746
late final Animation animation1;
4847

4948
late final animation2 = AnimationController();
@@ -53,21 +52,18 @@ class AvoidLateKeyword {
5352
/// expect_lint: avoid_late_keyword
5453
late final ColorTween colorTween1;
5554

56-
/// expect_lint: avoid_late_keyword
5755
late final colorTween2 = ColorTween();
5856

59-
/// expect_lint: avoid_late_keyword
6057
late final colorTween3 = colorTween2;
6158

59+
/// expect_lint: avoid_late_keyword
6260
late final AnimationController controller1;
6361

64-
/// expect_lint: avoid_late_keyword
6562
late final local1 = 'string';
6663

6764
/// expect_lint: avoid_late_keyword
6865
late final String local2;
6966

70-
/// expect_lint: avoid_late_keyword
7167
late final String local4 = 'string';
7268

7369
/// expect_lint: avoid_late_keyword

lint_test/avoid_late_keyword/no_generics/avoid_late_keyword_no_generics_test.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,38 @@ class AvoidLateKeyword {
1515
/// expect_lint: avoid_late_keyword
1616
late final NotAllowed na1;
1717

18+
/// expect_lint: avoid_late_keyword
1819
late final Subscription subscription1;
1920

21+
/// expect_lint: avoid_late_keyword
2022
late final Subscription<ConcreteTypeWithNoGenerics> subscription2;
2123

24+
/// expect_lint: avoid_late_keyword
2225
late final Subscription<List<int>> subscription3;
2326

27+
/// expect_lint: avoid_late_keyword
2428
late final Subscription<List<List<int>>> subscription4;
2529

30+
/// expect_lint: avoid_late_keyword
2631
late final Subscription<Map<dynamic, String>> subscription5;
2732

2833
void test() {
2934
/// expect_lint: avoid_late_keyword
3035
late final NotAllowed na1;
3136

37+
/// expect_lint: avoid_late_keyword
3238
late final Subscription subscription1;
3339

40+
/// expect_lint: avoid_late_keyword
3441
late final Subscription<ConcreteTypeWithNoGenerics> subscription2;
3542

43+
/// expect_lint: avoid_late_keyword
3644
late final Subscription<List<int>> subscription3;
3745

46+
/// expect_lint: avoid_late_keyword
3847
late final Subscription<List<List<int>>> subscription4;
3948

49+
/// expect_lint: avoid_late_keyword
4050
late final Subscription<Map<dynamic, String>> subscription5;
4151
}
4252
}

0 commit comments

Comments
 (0)