Skip to content

Commit

Permalink
Move to pkg:lints (#18)
Browse files Browse the repository at this point in the history
* Move to pkg:lints
* More helpful output
  • Loading branch information
kevmoo committed Nov 11, 2021
1 parent d7c1d1c commit e54141a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 46 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,5 @@
## 2.0.1-dev

## 2.0.0

- Require Dart `2.12.0`.
Expand Down
36 changes: 5 additions & 31 deletions analysis_options.yaml
@@ -1,77 +1,51 @@
include: package:pedantic/analysis_options.yaml
include: package:lints/recommended.yaml

analyzer:
strong-mode:
implicit-casts: false

linter:
rules:
- always_declare_return_types
- avoid_catching_errors
- avoid_dynamic_calls
- 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_unused_constructor_parameters
- avoid_void_async
- await_only_futures
- camel_case_types
- cancel_subscriptions
- cascade_invocations
- comment_references
- constant_identifier_names
- control_flow_in_finally
- directives_ordering
- empty_statements
- file_names
- hash_and_equals
- implementation_imports
- 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
- omit_local_variable_types
- 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
- provide_deprecation_message
- prefer_single_quotes
- sort_pub_dependencies
- test_types_in_equals
- throw_in_finally
- type_annotate_public_apis
- unawaited_futures
- 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
- use_is_even_rather_than_modulo
- use_string_buffers
- void_checks
19 changes: 7 additions & 12 deletions lib/src/impl.dart
@@ -1,4 +1,3 @@
import 'dart:convert';
import 'dart:io';

import 'package:path/path.dart' as p;
Expand Down Expand Up @@ -26,7 +25,11 @@ void expectBuildCleanImpl(
}

// 1 - get a list of modified files files - should be empty
expect(_changedGeneratedFiles(workingDir), isEmpty);
expect(
_changedGeneratedFiles(workingDir),
isEmpty,
reason: 'The working directory should be clean before running build.',
);

var executable = command.first;
if (executable == pubPlaceHolder) {
Expand All @@ -51,16 +54,8 @@ void expectResultOutputSucceeds(String result) {
contains(RegExp(r'\[INFO\] Succeeded after .+ with \d+ outputs')));
}

final _whitespace = RegExp(r'\s');

Set<String> _changedGeneratedFiles(String workingDir) {
final output = _runProc('git', ['status', '--porcelain'], workingDir);

return LineSplitter.split(output)
.map((line) => line.split(_whitespace).last)
.where((path) => path.endsWith('.dart'))
.toSet();
}
String _changedGeneratedFiles(String workingDir) =>
_runProc('git', ['diff'], workingDir);

String _runProc(String proc, List<String> args, String workingDir) {
final result = Process.runSync(proc, args, workingDirectory: workingDir);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/version.dart

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

4 changes: 2 additions & 2 deletions pubspec.yaml
Expand Up @@ -2,7 +2,7 @@ name: build_verify
description: >-
Test utility to ensure generated Dart code within a package is up-to-date
when using package:build.
version: 2.0.0
version: 2.0.1-dev
repository: https://github.com/kevmoo/build_verify

environment:
Expand All @@ -17,6 +17,6 @@ dev_dependencies:
build_runner: ^2.0.0
build_version: ^2.0.0
git: ^2.0.0
pedantic: ^1.1.0
lints: ^1.0.0
test_descriptor: ^2.0.0
test_process: ^2.0.0

0 comments on commit e54141a

Please sign in to comment.