Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Move to new analyzer language settings (#126)
Browse files Browse the repository at this point in the history
Enable and fix a bunch of lints. Require Dart 2.18 or greater
  • Loading branch information
kevmoo authored Jan 9, 2023
1 parent b525d5c commit 34ed68f
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: [2.12.0, dev]
sdk: [2.18.0, dev]
steps:
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 1.1.1-dev

* Add a check that throws if a logger name ends with '.'.
* Require Dart 2.18

## 1.1.0

Expand Down
74 changes: 33 additions & 41 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,63 +1,55 @@
# https://dart.dev/guides/language/analysis-options
include: package:lints/recommended.yaml

analyzer:
strong-mode:
implicit-casts: false
language:
strict-casts: true
strict-raw-types: true

linter:
rules:
- annotate_overrides
- always_declare_return_types
- avoid_bool_literals_in_conditional_expressions
- avoid_catching_errors
- avoid_classes_with_only_static_members
- avoid_dynamic_calls
- avoid_function_literals_in_foreach_calls
- avoid_init_to_null
- avoid_null_checks_in_equality_operators
- avoid_relative_lib_imports
- avoid_private_typedef_functions
- avoid_redundant_argument_values
- avoid_returning_null
- avoid_returning_null_for_future
- avoid_returning_this
- avoid_unused_constructor_parameters
- await_only_futures
- camel_case_types
- avoid_void_async
- cancel_subscriptions
- comment_references
# See https://github.com/dart-lang/logging/issues/43
#- constant_identifier_names
- control_flow_in_finally
- directives_ordering
- empty_catches
- empty_constructor_bodies
- empty_statements
- hash_and_equals
- implementation_imports
- iterable_contains_unrelated_type
- library_names
- library_prefixes
- list_remove_unrelated_type
- join_return_with_assignment
- lines_longer_than_80_chars
- literal_only_boolean_expressions
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- non_constant_identifier_names
- no_runtimeType_toString
- omit_local_variable_types
- only_throw_errors
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_adjacent_string_concatenation
- prefer_collection_literals
- prefer_conditional_assignment
- prefer_asserts_in_initializer_lists
- prefer_const_constructors
- prefer_final_fields
- prefer_generic_function_type_aliases
- prefer_initializing_formals
- prefer_interpolation_to_compose_strings
- prefer_const_declarations
- prefer_expression_function_bodies
- prefer_final_locals
- prefer_relative_imports
- prefer_single_quotes
- prefer_typing_uninitialized_variables
- slash_for_doc_comments
- sort_pub_dependencies
- test_types_in_equals
- throw_in_finally
- type_init_formals
- unnecessary_brace_in_string_interps
- unnecessary_const
- unnecessary_getters_setters
- type_annotate_public_apis
- unawaited_futures
- unnecessary_await_in_return
- unnecessary_lambdas
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_parenthesis
- unnecessary_raw_strings
- unnecessary_statements
- unnecessary_this
- use_if_null_to_convert_nulls_to_bools
- use_raw_strings
- use_string_buffers
- use_super_parameters
6 changes: 3 additions & 3 deletions lib/src/logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Logger {
}

// Split hierarchical names (separated with '.').
var dot = name.lastIndexOf('.');
final dot = name.lastIndexOf('.');
Logger? parent;
String thisName;
if (dot == -1) {
Expand Down Expand Up @@ -161,7 +161,7 @@ class Logger {
}

/// Whether a message for [value]'s level is loggable in this logger.
bool isLoggable(Level value) => (value >= level);
bool isLoggable(Level value) => value >= level;

/// Adds a log record for a [message] at a particular [logLevel] if
/// `isLoggable(logLevel)` is true.
Expand Down Expand Up @@ -202,7 +202,7 @@ class Logger {
}
zone ??= Zone.current;

var record =
final record =
LogRecord(logLevel, msg, fullName, error, stackTrace, zone, object);

if (parent == null) {
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ description: >-
repository: https://github.com/dart-lang/logging

environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ">=2.18.0 <3.0.0"

dev_dependencies:
lints: '>=1.0.0 <3.0.0'
lints: ^2.0.0
test: ^1.16.0
Loading

0 comments on commit 34ed68f

Please sign in to comment.