Skip to content

Commit

Permalink
Merge pull request #226 from davidmorgan/fix-lints
Browse files Browse the repository at this point in the history
Add ignore_for_files for a few lints to generated files.
  • Loading branch information
davidmorgan authored Sep 8, 2017
2 parents 9aa42e8 + c7601c3 commit 67055d3
Show file tree
Hide file tree
Showing 40 changed files with 155 additions and 173 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 4.1.1 (unreleased)

- Generated code now tells the analyzer to ignore prefer_expression_function_bodies
and sort_constructors_first.


## 4.1.0

- Improved annotation handling for corner cases.
Expand Down
3 changes: 3 additions & 0 deletions benchmark/lib/node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions benchmark/lib/simple_value.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions benchmark/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ environment:
dependencies:
browser: any
built_collection: ^1.0.0
built_value: ^4.1.0
# built_value: ^4.1.0
built_value:
path: ../built_value

dev_dependencies:
build: ^0.10.0
build_runner: ^0.4.0
built_value_generator: ^4.1.0
# built_value_generator: ^4.1.0
built_value_generator:
path: ../built_value_generator
source_gen: ^0.7.0
quiver: '>=0.21.0 <0.26.0'
test: any
11 changes: 10 additions & 1 deletion built_value_generator/lib/built_value_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,16 @@ class BuiltValueGenerator extends Generator {
}
}
}
return '$result';

if (result.isNotEmpty) {
return '// ignore_for_file: annotate_overrides\n'
'// ignore_for_file: prefer_expression_function_bodies\n'
'// ignore_for_file: sort_constructors_first\n'
'\n'
'$result';
} else {
return null;
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions built_value_generator/lib/src/enum_source_class.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions built_value_generator/lib/src/enum_source_field.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions built_value_generator/lib/src/enum_source_library.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions built_value_generator/lib/src/memoized_getter.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions built_value_generator/lib/src/serializer_source_class.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions built_value_generator/lib/src/serializer_source_field.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion built_value_generator/lib/src/value_source_class.dart
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ abstract class ValueSourceClass
// Working out which fields are overrides is complex; interfaces,
// superclasses and mixins could all trigger the warning. Suppress the
// warning instead.
result.writeln('// ignore_for_file: annotate_overrides');
if (settings.instantiable) result.write(_generateImpl());
if (settings.instantiable) {
result.write(_generateBuilder());
Expand Down
3 changes: 3 additions & 0 deletions built_value_generator/lib/src/value_source_class.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions built_value_generator/lib/src/value_source_field.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion built_value_generator/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ dependencies:
analyzer: '>=0.29.0 <0.31.0'
build: ^0.10.0
built_collection: ^1.0.0
built_value: ^4.1.0
# built_value: ^4.1.0
built_value:
path: ../built_value
source_gen: ^0.7.0
quiver: '>=0.21.0 <0.26.0'

Expand Down
102 changes: 0 additions & 102 deletions built_value_generator/test/enum_class_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ abstract class TestEnumMixin = Object with _$TestEnumMixin;
''';

final String correctOutput = r'''
part of test_enum;
// **************************************************************************
// Generator: BuiltValueGenerator
// **************************************************************************
const TestEnum _$yes = const TestEnum._('yes');
const TestEnum _$no = const TestEnum._('no');
const TestEnum _$maybe = const TestEnum._('maybe');
Expand Down Expand Up @@ -112,12 +106,6 @@ void main() {
'class TestEnum extends EnumClass {\n'
' static const anInt = 3;')),
endsWith(r'''
part of test_enum;
// **************************************************************************
// Generator: BuiltValueGenerator
// **************************************************************************
// Error: Please make the following changes to use EnumClass:
//
// 1. Specify a type for field "anInt".
Expand All @@ -141,12 +129,6 @@ class TestEnum extends EnumClass {
static TestEnum valueOf(String name) => _$valueOf(name);
}
'''), endsWith(r'''
part of test_enum;
// **************************************************************************
// Generator: BuiltValueGenerator
// **************************************************************************
// Error: Please make the following changes to use EnumClass:
//
// 1. Import EnumClass: import 'package:built_value/built_value.dart';
Expand All @@ -172,12 +154,6 @@ class TestEnum extends EnumClass {
static TestEnum valueOf(String name) => _$valueOf(name);
}
'''), contains(r'''
part of test_enum;
// **************************************************************************
// Generator: BuiltValueGenerator
// **************************************************************************
// Error: Please make the following changes to use EnumClass:
//
// 1. Import generated part: part 'test_enum.g.dart';
Expand All @@ -203,12 +179,6 @@ class TestEnum extends EnumClass {
static TestEnum valueOf(String name) => _$valueOf(name);
}
'''), endsWith(r'''
part of test_enum;
// **************************************************************************
// Generator: BuiltValueGenerator
// **************************************************************************
// Error: Please make the following changes to use EnumClass:
//
// 1. Make field "yes" const.
Expand Down Expand Up @@ -236,12 +206,6 @@ class TestEnum extends EnumClass {
static TestEnum valueOf(String name) => _$valueOf(name);
}
'''), endsWith(r'''
part of test_enum;
// **************************************************************************
// Generator: BuiltValueGenerator
// **************************************************************************
// Error: Please make the following changes to use EnumClass:
//
// 1. Make field "yes" static const.
Expand Down Expand Up @@ -293,12 +257,6 @@ class TestEnum extends EnumClass {
static TestEnum valueOf(String name) => _$valueOf(name);
}
'''), endsWith(r'''
part of test_enum;
// **************************************************************************
// Generator: BuiltValueGenerator
// **************************************************************************
const TestEnum _$no = const TestEnum._('yes');
const TestEnum _$maybe = const TestEnum._('no');
const TestEnum _$yes = const TestEnum._('maybe');
Expand Down Expand Up @@ -343,12 +301,6 @@ class TestEnum extends EnumClass {
static TestEnum valueOf(String name) => _$vlOf(name);
}
'''), endsWith(r'''
part of test_enum;
// **************************************************************************
// Generator: BuiltValueGenerator
// **************************************************************************
const TestEnum _$yes = const TestEnum._('yes');
const TestEnum _$no = const TestEnum._('no');
const TestEnum _$maybe = const TestEnum._('maybe');
Expand Down Expand Up @@ -393,12 +345,6 @@ class TestEnum extends EnumClass {
static TestEnum valueOf(String name) => _$valueOf(name);
}
'''), endsWith(r'''
part of test_enum;
// **************************************************************************
// Generator: BuiltValueGenerator
// **************************************************************************
// Error: Please make the following changes to use EnumClass:
//
// 1. Generated identifier "_$no" is used multiple times in test_enum, change to something else.
Expand All @@ -424,12 +370,6 @@ class TestEnum extends EnumClass {
static TestEnum valueOf(String name) => _$valueOf(name);
}
'''), endsWith(r'''
part of test_enum;
// **************************************************************************
// Generator: BuiltValueGenerator
// **************************************************************************
// Error: Please make the following changes to use EnumClass:
//
// 1. Generated identifier "_$no" is used multiple times in test_enum, change to something else.
Expand Down Expand Up @@ -460,12 +400,6 @@ class TestEnum extends EnumClass {
static TestEnum valueOf(String name) => _$valueOf(name);
}
'''), endsWith(r'''
part of test_enum;
// **************************************************************************
// Generator: BuiltValueGenerator
// **************************************************************************
// Error: Please make the following changes to use EnumClass:
//
// 1. Have exactly one constructor: const TestEnum._(String name) : super(name);
Expand All @@ -491,12 +425,6 @@ class TestEnum extends EnumClass {
static TestEnum valueOf(String name) => _$valueOf(name);
}
'''), endsWith(r'''
part of test_enum;
// **************************************************************************
// Generator: BuiltValueGenerator
// **************************************************************************
// Error: Please make the following changes to use EnumClass:
//
// 1. Have exactly one constructor: const TestEnum._(String name) : super(name);
Expand Down Expand Up @@ -526,12 +454,6 @@ class TestEnum extends EnumClass {
abstract class BuiltSet<T> {
}
'''), endsWith(r'''
part of test_enum;
// **************************************************************************
// Generator: BuiltValueGenerator
// **************************************************************************
// Error: Please make the following changes to use EnumClass:
//
// 1. Have exactly one constructor: const TestEnum._(String name) : super(name);
Expand All @@ -556,12 +478,6 @@ class TestEnum extends EnumClass {
static TestEnum valueOf(String name) => _$valueOf(name);
}
'''), endsWith(r'''
part of test_enum;
// **************************************************************************
// Generator: BuiltValueGenerator
// **************************************************************************
// Error: Please make the following changes to use EnumClass:
//
// 1. Add getter: static BuiltSet<TestEnum> get values => _$values
Expand All @@ -586,12 +502,6 @@ class TestEnum extends EnumClass {
static BuiltSet<TestEnum> get values => _$values;
}
'''), endsWith(r'''
part of test_enum;
// **************************************************************************
// Generator: BuiltValueGenerator
// **************************************************************************
// Error: Please make the following changes to use EnumClass:
//
// 1. Add method: static TestEnum valueOf(String name) => _$valueOf(name)
Expand All @@ -617,12 +527,6 @@ class TestEnum extends EnumClass {
class TestEnumMixin = Object with _$TestEnumMixin;
'''), endsWith(r'''
part of test_enum;
// **************************************************************************
// Generator: BuiltValueGenerator
// **************************************************************************
// Error: Please make the following changes to use EnumClass:
//
// 1. Remove mixin or declare using exactly: abstract class TestEnumMixin = Object with _$TestEnumMixin;
Expand All @@ -646,12 +550,6 @@ abstract class TestEnum extends EnumClass {
static TestEnum valueOf(String name) => _$valueOf(name);
}
'''), endsWith(r'''
part of test_enum;
// **************************************************************************
// Generator: BuiltValueGenerator
// **************************************************************************
// Error: Please make the following changes to use EnumClass:
//
// 1. Make TestEnum concrete; remove "abstract".
Expand Down
Loading

0 comments on commit 67055d3

Please sign in to comment.