Skip to content

Commit 51c2142

Browse files
authored
Enable and fix unnecessary_ignore lint (#1477)
1 parent 83377d0 commit 51c2142

21 files changed

+37
-55
lines changed

analysis_options.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ linter:
2626
- unnecessary_breaks
2727
- use_full_hex_values_for_flutter_colors
2828
- use_string_buffers
29+
- unnecessary_ignore

json_serializable/lib/src/type_helpers/json_converter_helper.dart

-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ _JsonConvertData? _typeConverterFrom(
214214

215215
final annotationElement = match.elementAnnotation?.element;
216216
if (annotationElement is PropertyAccessorElement) {
217-
// ignore: deprecated_member_use
218217
final enclosing = annotationElement.enclosingElement3;
219218

220219
var accessString = annotationElement.name;

json_serializable/lib/src/utils.dart

-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ ConstructorElement? _constructorByNameOrNull(
131131
) {
132132
try {
133133
return constructorByName(classElement, name);
134-
// ignore: avoid_catching_errors
135134
} on InvalidGenerationSourceError {
136135
return null;
137136
}

json_serializable/test/supported_types/extra_map_test.dart

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: prefer_const_declarations
65
@TestOn('vm')
76
library;
87

json_serializable/test/supported_types/type_test.bigint_test.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: prefer_const_declarations
65
@TestOn('vm')
76
library;
87

@@ -87,8 +86,8 @@ void main() {
8786
}); // end nullable group
8887
}
8988

90-
final _defaultValue = '12345';
91-
final _altValue = '67890';
89+
const _defaultValue = '12345';
90+
const _altValue = '67890';
9291

9392
final _defaultInput = <String, Object?>{
9493
'value': _defaultValue,

json_serializable/test/supported_types/type_test.bool_test.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: prefer_const_declarations
65
@TestOn('vm')
76
library;
87

@@ -87,8 +86,8 @@ void main() {
8786
}); // end nullable group
8887
}
8988

90-
final _defaultValue = true;
91-
final _altValue = false;
89+
const _defaultValue = true;
90+
const _altValue = false;
9291

9392
final _defaultInput = <String, Object?>{
9493
'value': _defaultValue,

json_serializable/test/supported_types/type_test.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: prefer_const_declarations
65
@TestOn('vm')
76
library;
87

@@ -53,8 +52,8 @@ void main() {
5352
}); // end non-nullable group
5453
}
5554

56-
final _defaultValue = 42;
57-
final _altValue = 43;
55+
const _defaultValue = 42;
56+
const _altValue = 43;
5857

5958
final _defaultInput = <String, Object?>{
6059
'value': _defaultValue,

json_serializable/test/supported_types/type_test.datetime_test.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: prefer_const_declarations
65
@TestOn('vm')
76
library;
87

@@ -87,8 +86,8 @@ void main() {
8786
}); // end nullable group
8887
}
8988

90-
final _defaultValue = '2020-01-01T00:00:00.000';
91-
final _altValue = '2018-01-01T00:00:00.000';
89+
const _defaultValue = '2020-01-01T00:00:00.000';
90+
const _altValue = '2018-01-01T00:00:00.000';
9291

9392
final _defaultInput = <String, Object?>{
9493
'value': _defaultValue,

json_serializable/test/supported_types/type_test.double_test.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: prefer_const_declarations
65
@TestOn('vm')
76
library;
87

@@ -87,8 +86,8 @@ void main() {
8786
}); // end nullable group
8887
}
8988

90-
final _defaultValue = 3.14;
91-
final _altValue = 6.28;
89+
const _defaultValue = 3.14;
90+
const _altValue = 6.28;
9291

9392
final _defaultInput = <String, Object?>{
9493
'value': _defaultValue,

json_serializable/test/supported_types/type_test.duration_test.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: prefer_const_declarations
65
@TestOn('vm')
76
library;
87

@@ -87,8 +86,8 @@ void main() {
8786
}); // end nullable group
8887
}
8988

90-
final _defaultValue = 1234;
91-
final _altValue = 2345;
89+
const _defaultValue = 1234;
90+
const _altValue = 2345;
9291

9392
final _defaultInput = <String, Object?>{
9493
'value': _defaultValue,

json_serializable/test/supported_types/type_test.enumtype_test.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: prefer_const_declarations
65
@TestOn('vm')
76
library;
87

@@ -87,8 +86,8 @@ void main() {
8786
}); // end nullable group
8887
}
8988

90-
final _defaultValue = 'alpha';
91-
final _altValue = 'beta';
89+
const _defaultValue = 'alpha';
90+
const _altValue = 'beta';
9291

9392
final _defaultInput = <String, Object?>{
9493
'value': _defaultValue,

json_serializable/test/supported_types/type_test.int_test.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: prefer_const_declarations
65
@TestOn('vm')
76
library;
87

@@ -87,8 +86,8 @@ void main() {
8786
}); // end nullable group
8887
}
8988

90-
final _defaultValue = 42;
91-
final _altValue = 43;
89+
const _defaultValue = 42;
90+
const _altValue = 43;
9291

9392
final _defaultInput = <String, Object?>{
9493
'value': _defaultValue,

json_serializable/test/supported_types/type_test.iterable_test.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: prefer_const_declarations
65
@TestOn('vm')
76
library;
87

@@ -87,8 +86,8 @@ void main() {
8786
}); // end nullable group
8887
}
8988

90-
final _defaultValue = [42, true, false, null];
91-
final _altValue = [43, false];
89+
const _defaultValue = [42, true, false, null];
90+
const _altValue = [43, false];
9291

9392
final _defaultInput = <String, Object?>{
9493
'value': _defaultValue,

json_serializable/test/supported_types/type_test.list_test.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: prefer_const_declarations
65
@TestOn('vm')
76
library;
87

@@ -87,8 +86,8 @@ void main() {
8786
}); // end nullable group
8887
}
8988

90-
final _defaultValue = [42, true, false, null];
91-
final _altValue = [43, false];
89+
const _defaultValue = [42, true, false, null];
90+
const _altValue = [43, false];
9291

9392
final _defaultInput = <String, Object?>{
9493
'value': _defaultValue,

json_serializable/test/supported_types/type_test.map_test.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: prefer_const_declarations
65
@TestOn('vm')
76
library;
87

@@ -87,8 +86,8 @@ void main() {
8786
}); // end nullable group
8887
}
8988

90-
final _defaultValue = {'a': 1};
91-
final _altValue = {'b': 2};
89+
const _defaultValue = {'a': 1};
90+
const _altValue = {'b': 2};
9291

9392
final _defaultInput = <String, Object?>{
9493
'value': _defaultValue,

json_serializable/test/supported_types/type_test.num_test.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: prefer_const_declarations
65
@TestOn('vm')
76
library;
87

@@ -87,8 +86,8 @@ void main() {
8786
}); // end nullable group
8887
}
8988

90-
final _defaultValue = 88.6;
91-
final _altValue = 29;
89+
const _defaultValue = 88.6;
90+
const _altValue = 29;
9291

9392
final _defaultInput = <String, Object?>{
9493
'value': _defaultValue,

json_serializable/test/supported_types/type_test.object_test.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: prefer_const_declarations
65
@TestOn('vm')
76
library;
87

@@ -87,8 +86,8 @@ void main() {
8786
}); // end nullable group
8887
}
8988

90-
final _defaultValue = 'o1';
91-
final _altValue = 'o2';
89+
const _defaultValue = 'o1';
90+
const _altValue = 'o2';
9291

9392
final _defaultInput = <String, Object?>{
9493
'value': _defaultValue,

json_serializable/test/supported_types/type_test.set_test.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: prefer_const_declarations
65
@TestOn('vm')
76
library;
87

@@ -87,8 +86,8 @@ void main() {
8786
}); // end nullable group
8887
}
8988

90-
final _defaultValue = [42, true, false, null];
91-
final _altValue = [43, false];
89+
const _defaultValue = [42, true, false, null];
90+
const _altValue = [43, false];
9291

9392
final _defaultInput = <String, Object?>{
9493
'value': _defaultValue,

json_serializable/test/supported_types/type_test.string_test.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: prefer_const_declarations
65
@TestOn('vm')
76
library;
87

@@ -87,8 +86,8 @@ void main() {
8786
}); // end nullable group
8887
}
8988

90-
final _defaultValue = 'a string';
91-
final _altValue = 'another string';
89+
const _defaultValue = 'a string';
90+
const _altValue = 'another string';
9291

9392
final _defaultInput = <String, Object?>{
9493
'value': _defaultValue,

json_serializable/test/supported_types/type_test.uri_test.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: prefer_const_declarations
65
@TestOn('vm')
76
library;
87

@@ -87,8 +86,8 @@ void main() {
8786
}); // end nullable group
8887
}
8988

90-
final _defaultValue = 'https://example.com';
91-
final _altValue = 'https://dart.dev';
89+
const _defaultValue = 'https://example.com';
90+
const _altValue = 'https://dart.dev';
9291

9392
final _defaultInput = <String, Object?>{
9493
'value': _defaultValue,

json_serializable/tool/test_type_data.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ class TestTypeData {
242242

243243
yield Replacement(
244244
'''
245-
final _defaultValue = 42;
246-
final _altValue = 43;
245+
const _defaultValue = 42;
246+
const _altValue = 43;
247247
''',
248248
'''
249-
final _defaultValue = $jsonExpression;
250-
final _altValue = $altJsonExpression;
249+
const _defaultValue = $jsonExpression;
250+
const _altValue = $altJsonExpression;
251251
''',
252252
);
253253

0 commit comments

Comments
 (0)