Skip to content

Commit

Permalink
Enable and fix new lints
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Feb 14, 2020
1 parent 4596d1a commit 2ffb14b
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 11 deletions.
18 changes: 18 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ analyzer:
linter:
rules:
- avoid_bool_literals_in_conditional_expressions
- avoid_catching_errors
- avoid_classes_with_only_static_members
- avoid_function_literals_in_foreach_calls
- avoid_private_typedef_functions
- avoid_redundant_argument_values
- avoid_renaming_method_parameters
- avoid_returning_null
- avoid_returning_null_for_future
- avoid_returning_null_for_void
- avoid_returning_this
- avoid_single_cascade_in_expression_statements
- avoid_unused_constructor_parameters
- avoid_void_async
- await_only_futures
- camel_case_types
- cancel_subscriptions
Expand All @@ -31,28 +35,42 @@ linter:
- invariant_booleans
- iterable_contains_unrelated_type
- join_return_with_assignment
- lines_longer_than_80_chars
- list_remove_unrelated_type
- literal_only_boolean_expressions
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- no_runtimeType_toString
- non_constant_identifier_names
- only_throw_errors
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_asserts_in_initializer_lists
- prefer_const_constructors
- prefer_const_declarations
- prefer_expression_function_bodies
- prefer_final_locals
- prefer_function_declarations_over_variables
- prefer_initializing_formals
- prefer_inlined_adds
- prefer_interpolation_to_compose_strings
- prefer_is_not_operator
- prefer_null_aware_operators
- prefer_relative_imports
- prefer_typing_uninitialized_variables
- prefer_void_to_null
- sort_pub_dependencies
- test_types_in_equals
- throw_in_finally
- unnecessary_await_in_return
- unnecessary_brace_in_string_interps
- unnecessary_getters_setters
- unnecessary_lambdas
- unnecessary_null_aware_assignments
- unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_statements
- unnecessary_string_interpolations
- void_checks
3 changes: 2 additions & 1 deletion example/example_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class ExampleGenerator extends GeneratorForAnnotation<ExampleAnnotation> {
yield 'const ${element.name}NameLowerCase = ${element.name.toLowerCase()};';

if (annotation.read('includeUpperCase').literalValue as bool) {
yield 'const ${element.name}NameUpperCase = ${element.name.toUpperCase()};';
yield 'const ${element.name}NameUpperCase = '
'${element.name.toUpperCase()};';
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/expectation_element.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:analyzer/dart/constant/value.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:source_gen/source_gen.dart';
import 'package:source_gen_test/source_gen_test.dart';

import '../source_gen_test.dart';
import 'annotations.dart';

List<_ExpectationElement> genAnnotatedElements(
Expand Down
3 changes: 2 additions & 1 deletion lib/src/init_library_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Future<LibraryReader> initializeLibraryReaderForDirectory(

try {
return await initializeLibraryReader(map, targetLibraryFileName);
} on ArgumentError catch (e) {
} on ArgumentError catch (e) // ignore: avoid_catching_errors
{
if (e.message == 'Must exist as a key in `contentMap`.') {
throw ArgumentError.value(targetLibraryFileName, 'targetLibraryFileName',
'Must exist as a file in `sourceDirectory`.');
Expand Down
6 changes: 3 additions & 3 deletions lib/src/test_annotated_classes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import 'dart:async';
import 'package:analyzer/dart/element/element.dart';
import 'package:meta/meta.dart';
import 'package:source_gen/source_gen.dart';
import 'package:source_gen_test/source_gen_test.dart';
import 'package:test/test.dart';

import '../source_gen_test.dart';
import 'annotations.dart';
import 'build_log_tracking.dart';
import 'expectation_element.dart';
Expand Down Expand Up @@ -226,7 +226,7 @@ class _AnnotatedTest<T> {
Future<String> _generate() =>
generateForElement<T>(generator, _libraryReader, _elementName);

Future<Null> _shouldGenerateTest() async {
Future<void> _shouldGenerateTest() async {
final output = await _generate();
final exp = expectation as ShouldGenerate;

Expand All @@ -250,7 +250,7 @@ class _AnnotatedTest<T> {
clearBuildLog();
}

Future<Null> _shouldThrowTest() async {
Future<void> _shouldThrowTest() async {
final exp = expectation as ShouldThrow;

Matcher elementMatcher;
Expand Down
2 changes: 1 addition & 1 deletion test/example_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:io';

import '../example/example.dart' as example_test;

void main() async {
Future<void> main() async {
if (Platform.environment['TRAVIS_DART_VERSION'] == '2.0.0') {
print('Skipping on Dart 2.0.0');
return;
Expand Down
6 changes: 3 additions & 3 deletions test/generate_for_element_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TestAnnotation {
const TestAnnotation();
}''';

void main() async {
Future<void> main() async {
group('Bad annotations', () {
test('duplicate configurations for the same member', () async {
final badReader = await initializeLibraryReader({
Expand Down Expand Up @@ -98,12 +98,12 @@ const TestClass2NameLowerCase = testclass2;
});

group('testAnnotatedElements', () {
final validAdditionalGenerators = const {
const validAdditionalGenerators = {
'no-prefix-required': TestGenerator(requireTestClassPrefix: false),
'vague': TestGenerator(alwaysThrowVagueError: true),
};

final validExpectedAnnotatedTests = const [
const validExpectedAnnotatedTests = [
'BadTestClass',
'BadTestClass',
'BadTestClass',
Expand Down
2 changes: 1 addition & 1 deletion test/src/test_library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ int badTestFunc() => 42;
element: false,
)
@TestAnnotation()
final badTestField = 42;
const badTestField = 42;

0 comments on commit 2ffb14b

Please sign in to comment.