Skip to content

Commit

Permalink
Add new lints for flutter 3.3.3 and metrics 4.19.1 (#5)
Browse files Browse the repository at this point in the history
* Add new lints for flutter 3.3.3 and metrics 4.19.1

* exclude commons folder

* disable discarded_futures

* remove overriden-methods
  • Loading branch information
paulkastel authored Oct 10, 2022
1 parent 869c062 commit 9935542
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.3.3

* Lints from dart_metrics version 4.19.1
* Lints for Flutter 3.3.3
* invariant_booleans was deprecated
* avoid_catches_without_on_clauses was disabled

## 0.2.4

* Lints from dart_metrics version 4.16.0
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ For general information about developing packages, see the Dart guide for
and the Flutter guide for
[developing packages and plugins](https://flutter.dev/developing-packages).
-->
# miquido_flutter_lints
# miquido_flutter_lints [![style: miquido lints](https://badgen.net/badge/style/miquido-flutter-lints/blue?icon=terminal)](https://github.com/miquido/miquido_flutter_lints)
##### This is collection of Flutter lints that we use and follow in [Miquido Software development company](https://www.miquido.com).

This is strict, large and robust collection because we strive for high quality code, good practices and we want follow the same coding style in all our mobile apps.
Expand All @@ -23,7 +23,7 @@ We tested current configuration with this environment:
```yaml
environment:
sdk: ">=2.17.0 <3.0.0"
flutter: ^3.0.4
flutter: ^3.3.3
```
so it is required to update your flutter project to meet this conditions.
Expand All @@ -43,7 +43,7 @@ dev_dependencies:

or

you can copy content of [this file](lib/miquido_lints.yaml) to your `analysis_options.yaml`. In this approach remember that you need to depend on `dart_code_metrics: 4.16.0`, and you will need to add that package to your `pubspec.yaml` as well. Also you will need to visit this repository from time to time to check for changes!
you can copy content of [this file](lib/miquido_lints.yaml) to your `analysis_options.yaml`. In this approach remember that you need to depend on `dart_code_metrics: 4.19.1`, and you will need to add that package to your `pubspec.yaml` as well. Also you will need to visit this repository from time to time to check for changes!

Also if you star this repo, that would be nice.

Expand Down Expand Up @@ -119,4 +119,4 @@ This is set of sources from which we are getting our linters and about good prac
#### About Miquido
- [About](https://careers.miquido.com/about-us/)
- [Careers](https://careers.miquido.com/job-offers/)
- [Internship at Miquido](https://careers.miquido.com/students/)
- [Internship at Miquido](https://careers.miquido.com/students/)
31 changes: 25 additions & 6 deletions lib/miquido_lints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ linter:
- annotate_overrides
# - avoid_annotating_with_dynamic - Super problematic to fix with avoid_types_on_closure_parameters enabled
- avoid_bool_literals_in_conditional_expressions
- avoid_catches_without_on_clauses
# - avoid_catches_without_on_clauses - Flutter throws _CastError when parsing json fails, so we need to handle both Error and Exception in all API classes
- avoid_catching_errors
# - avoid_classes_with_only_static_members - We know, but somewhat this doesn't fell right and clean
- avoid_double_and_int_checks
Expand Down Expand Up @@ -91,6 +91,7 @@ linter:
- deprecated_consistency
# - diagnostic_describe_all_properties - Add unnecessary complexity to code and makes it difficult to read
- directives_ordering
# - discarded_futures - do not work well with testing tools and cascade operator
- do_not_use_environment
- empty_catches
- empty_constructor_bodies
Expand All @@ -101,7 +102,6 @@ linter:
- flutter_style_todos
- hash_and_equals
- implementation_imports
- invariant_booleans
- iterable_contains_unrelated_type
- join_return_with_assignment
- leading_newlines_in_multiline_strings
Expand Down Expand Up @@ -199,6 +199,7 @@ linter:
- unnecessary_late
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_aware_operator_on_extension_on_nullable
- unnecessary_null_checks
- unnecessary_null_in_if_null_operators
- unnecessary_nullable_for_final_variable_declarations
Expand All @@ -209,6 +210,7 @@ linter:
- unnecessary_string_escapes
- unnecessary_string_interpolations
- unnecessary_this
- unnecessary_to_list_in_spreads
- unrelated_type_equality_checks
- unsafe_html
# - use_build_context_synchronously - this is mostly useful in some animations, but most of the time it unnecessary makes code more complex
Expand Down Expand Up @@ -238,8 +240,9 @@ linter:
# to execute run `flutter analyze`. It should show "No issues found!" message.
dart_code_metrics:
rules:
# - avoid_restricted_imports - this would be good for modular projects and packages
# - avoid-banned-imports - this would be good for modular projects and packages
- avoid-collection-methods-with-unrelated-types
- avoid-duplicate-exports
# - avoid-dynamic - as much as we would love to have it, sometimes it is necessary
- avoid-global-state
# - avoid-ignoring-return-values - sometimes method return something, but you don't care, and that is ok
Expand All @@ -248,7 +251,15 @@ dart_code_metrics:
- avoid-nested-conditional-expressions
# - avoid-non-ascii-symbols - this warns about emojis, currency symbols (sometimes needed, makes no sense to use or to ignore every time)
# - avoid-non-null-assertion - this is good lint, but sometimes is un-fixable
# - avoid-passing-async-when-sync-expected - doesn't go well with lambda expressions, onPressed or freezed
- avoid-redundant-async:
severity: info
# - avoid-throw-in-catch-block - enabling it only because of provided justification in our opinion is just flexing
- avoid-top-level-members-in-tests:
exclude:
- test/commons/**
- lib/**
- bin/**
- avoid-unnecessary-type-assertions
- avoid-unnecessary-type-casts
- avoid-unrelated-type-assertions
Expand All @@ -266,7 +277,6 @@ dart_code_metrics:
- static-public-fields
- static-private-fields
- fields
- overriden-methods
- methods
# - newline-before-return: - this is just stupid, especially when you have one-line methods
# exclude:
Expand All @@ -286,26 +296,35 @@ dart_code_metrics:
exceptions: ['i', 'x', 'id', 'db']
min-identifier-length: 3
max-identifier-length: 35
- prefer-correct-test-file-name:
severity: error
- prefer-correct-type-name
- prefer-enums-by-name
# - prefer-first - disabled as old-school array[0] is clearer
- prefer-immediate-return
- prefer-iterable-of
- prefer-last # but this one is much better that array[array.length-1]
- prefer-match-file-name:
severity: error
exclude:
- test/**
# - prefer-trailing-comma - this one is pure hardcore and too strict
# - prefer-moving-to-variable - as of usage Theme.of(context) this lights up for every textTheme style used in one widget used
# - prefer-trailing-comma - this one is pure hardcore and too strict
- tag-name:
exclude:
- test/**
- always-remove-listener
# - avoid-border-all - proposed solution is adding extra code complexity for meaningless profit
- avoid-returning-widgets:
severity: error
- avoid-shrink-wrap-in-lists
- avoid-unnecessary-setstate
- avoid-use-expanded-as-spacer
- avoid-wrapping-in-padding
- check-for-equals-in-render-object-setters
- consistent-update-render-object
# - prefer-const-border-radius - proposed solution is adding extra code complexity for meaningless profit
- prefer-correct-edge-insets-constructor
- prefer-extracting-callbacks:
allowed-line-count: 0
ignored-named-arguments:
Expand All @@ -325,9 +344,9 @@ dart_code_metrics:
lines-of-code: 70
maintainability-index: 60
maximum-nesting-level: 4
number-of-methods: 7
number-of-parameters: 4
source-lines-of-code: 40
number-of-methods: 7
weight-of-class: 0.33

technical-debt:
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: miquido_flutter_lints
description: Collection of Flutter lints that we use and follow in Miquido
version: 0.2.4
version: 0.3.3
homepage: https://www.miquido.com

environment:
sdk: ">=2.17.0 <3.0.0"
flutter: ^3.0.4
flutter: ^3.3.3

dependencies:
dart_code_metrics: 4.16.0
dart_code_metrics: ^4.19.1

flutter:
sdk: flutter
Expand Down

0 comments on commit 9935542

Please sign in to comment.