From 264f9a379f6d3021efbbb42aa3feaf8bf7ccccf3 Mon Sep 17 00:00:00 2001 From: Honza Bittner Date: Wed, 27 Mar 2024 08:22:22 +0100 Subject: [PATCH 1/2] Adhere to DCM 1.15.0 --- .fvm/fvm_config.json | 3 +- .fvmrc | 3 ++ .gitignore | 2 +- .vscode/settings.json | 57 ++++++++++++------------- packages/netglade_analysis/CHANGELOG.md | 16 +++++++ packages/netglade_analysis/README.md | 2 +- packages/netglade_analysis/lib/dcm.yaml | 15 ++++++- packages/netglade_analysis/pubspec.yaml | 2 +- 8 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 .fvmrc diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json index ccdae4d..6be174a 100644 --- a/.fvm/fvm_config.json +++ b/.fvm/fvm_config.json @@ -1,4 +1,3 @@ { - "flutterSdkVersion": "3.19.0", - "flavors": {} + "flutterSdkVersion": "3.19.4" } \ No newline at end of file diff --git a/.fvmrc b/.fvmrc new file mode 100644 index 0000000..764b061 --- /dev/null +++ b/.fvmrc @@ -0,0 +1,3 @@ +{ + "flutter": "3.19.4" +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9619790..fe9866c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ melos_my_project.iml .vscode/* !.vscode/tasks.json !.vscode/settings.json -.fvm/flutter_sdk +.fvm/ .packages .pub/ diff --git a/.vscode/settings.json b/.vscode/settings.json index 2369e24..2e1f166 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,31 +1,30 @@ { - "dart.flutterSdkPath": ".fvm/flutter_sdk", - "search.exclude": { - "**/.fvm": true, - "**/*.g.dart": true, - }, - "files.exclude": { - "**/.git": true, - "**/.DS_Store": true, - ".idea/**": true, - ".run/**": true, - }, - // Remove from file watching - "files.watcherExclude": { - "**/.fvm": true - }, - "dart.lineLength": 120, - "editor.rulers": [ - 120 - ], - "yaml.schemas": { - "https://json.schemastore.org/dart-build.json": [ - "build.yaml" - ] - }, - "explorer.fileNesting.enabled": true, - "explorer.fileNesting.patterns": { - "*.dart": "${capture}.g.dart,${capture}.freezed.dart,${capture}.auto_mappr.dart" - }, - "yaml.schemaStore.enable": false + "dart.flutterSdkPath": ".fvm/versions/3.19.4", + "search.exclude": { + "**/.fvm": true, + "**/*.g.dart": true + }, + "files.exclude": { + "**/.git": true, + "**/.DS_Store": true, + ".idea/**": true, + ".run/**": true + }, + "files.watcherExclude": { + "**/.fvm": true + }, + "dart.lineLength": 120, + "editor.rulers": [ + 120 + ], + "yaml.schemas": { + "https://json.schemastore.org/dart-build.json": [ + "build.yaml" + ] + }, + "explorer.fileNesting.enabled": true, + "explorer.fileNesting.patterns": { + "*.dart": "${capture}.g.dart,${capture}.freezed.dart,${capture}.auto_mappr.dart" + }, + "yaml.schemaStore.enable": false } \ No newline at end of file diff --git a/packages/netglade_analysis/CHANGELOG.md b/packages/netglade_analysis/CHANGELOG.md index 48800d9..803feda 100644 --- a/packages/netglade_analysis/CHANGELOG.md +++ b/packages/netglade_analysis/CHANGELOG.md @@ -1,3 +1,19 @@ +## 9.0.0 +- Adhere to DCM 1.15.0: + - Add avoid-casting-to-extension-type + - Add avoid-empty-spread + - Add avoid-missing-completer-stack-trace + - Add avoid-nested-extension-types + - Add avoid-renaming-representation-getters + - Add avoid-returning-void + - Add avoid-slow-collection-methods + - Add avoid-unknown-pragma + - Add avoid-unnecessary-collections + - Add prefer-overriding-parent-equality + - Add prefer-private-extension-type-field + - Add avoid-missing-controller + - Add avoid-unnecessary-gesture-detector + ## 8.0.0 - Adhere to DCM 1.14.0: - Add avoid-empty-test-groups diff --git a/packages/netglade_analysis/README.md b/packages/netglade_analysis/README.md index 159241a..8692cea 100644 --- a/packages/netglade_analysis/README.md +++ b/packages/netglade_analysis/README.md @@ -23,7 +23,7 @@ To use the lints, add as a dev dependency in your `pubspec.yaml`: ```yaml dev_dependencies: - netglade_analysis: ^8.0.0 + netglade_analysis: ^9.0.0 ``` Then, add an include in `analysis_options.yaml`: diff --git a/packages/netglade_analysis/lib/dcm.yaml b/packages/netglade_analysis/lib/dcm.yaml index db0a3bb..2c65242 100644 --- a/packages/netglade_analysis/lib/dcm.yaml +++ b/packages/netglade_analysis/lib/dcm.yaml @@ -1,4 +1,4 @@ -# version 1.14.0 - https://dcm.dev/changelog/ +# version 1.15.0 - https://dcm.dev/changelog dart_code_metrics: rules: ### Common @@ -14,6 +14,7 @@ dart_code_metrics: - avoid-bottom-type-in-patterns - avoid-bottom-type-in-records - avoid-cascade-after-if-null + - avoid-casting-to-extension-type - avoid-collapsible-if - avoid-collection-methods-with-unrelated-types # - avoid-collection-mutating-methods # sometimes it's ok @@ -31,6 +32,7 @@ dart_code_metrics: - avoid-duplicate-switch-case-conditions - avoid-duplicate-test-assertions - avoid-dynamic + - avoid-empty-spread - avoid-empty-test-groups: include-methods: - blocTest @@ -63,6 +65,7 @@ dart_code_metrics: - avoid-long-records - avoid-map-keys-contains - avoid-missed-calls + - avoid-missing-completer-stack-trace - avoid-missing-enum-constant-in-map - avoid-misused-wildcard-pattern - avoid-mixing-named-and-positional-fields @@ -70,6 +73,7 @@ dart_code_metrics: # - avoid-negated-conditions # sometimes it might be better - avoid-nested-conditional-expressions: acceptable-level: 2 + - avoid-nested-extension-types - avoid-nested-futures - avoid-nested-records - avoid-nested-streams-and-futures @@ -99,6 +103,8 @@ dart_code_metrics: - avoid-redundant-positional-field-name - avoid-redundant-pragma-inline - avoid-referencing-discarded-variables + - avoid-renaming-representation-getters + - avoid-returning-void - avoid-self-assignment - avoid-self-compare - avoid-shadowed-extension-methods @@ -107,6 +113,7 @@ dart_code_metrics: ignored-names: - context # - avoid-similar-names # way too pedantic + - avoid-slow-collection-methods - avoid-substring - avoid-throw-in-catch-block - avoid-throw-objects-without-tostring @@ -115,7 +122,9 @@ dart_code_metrics: - avoid-unassigned-stream-subscriptions - avoid-uncaught-future-errors - avoid-unconditional-break + - avoid-unknown-pragma - avoid-unnecessary-call + - avoid-unnecessary-collections - avoid-unnecessary-conditionals - avoid-unnecessary-futures # - avoid-unnecessary-getter # it's ok to have getter for private field @@ -251,8 +260,10 @@ dart_code_metrics: - prefer-named-boolean-parameters # - prefer-named-imports # * OK, we just don't have global config - prefer-null-aware-spread + - prefer-overriding-parent-equality - prefer-parentheses-with-if-null # - prefer-prefixed-global-constants # * OK, we just don't have global config + - prefer-private-extension-type-field - prefer-public-exception-classes - prefer-return-await # - prefer-returning-conditional-expressions # annoying sometimes @@ -291,6 +302,7 @@ dart_code_metrics: - avoid-incomplete-copy-with - avoid-inherited-widget-in-initstate - avoid-late-context + - avoid-missing-controller - avoid-missing-image-alt - avoid-recursive-widget-calls - avoid-returning-widgets @@ -299,6 +311,7 @@ dart_code_metrics: - avoid-state-constructors - avoid-stateless-widget-initialized-fields - avoid-undisposed-instances + - avoid-unnecessary-gesture-detector - avoid-unnecessary-overrides-in-state - avoid-unnecessary-setstate - avoid-unnecessary-stateful-widgets diff --git a/packages/netglade_analysis/pubspec.yaml b/packages/netglade_analysis/pubspec.yaml index 60417b7..cbcf1ca 100644 --- a/packages/netglade_analysis/pubspec.yaml +++ b/packages/netglade_analysis/pubspec.yaml @@ -1,5 +1,5 @@ name: netglade_analysis -version: 8.0.0 +version: 9.0.0 description: Lint rules for Dart and Flutter used internally at netglade. repository: https://github.com/netglade/flutter_core/tree/main/packages/netglade_analysis issue_tracker: https://github.com/netglade/flutter_core/issues From 181a318aef05e4d262fd432d4c646b6befbb723a Mon Sep 17 00:00:00 2001 From: Honza Bittner Date: Wed, 27 Mar 2024 15:16:22 +0100 Subject: [PATCH 2/2] Update prefer-correct-switch-length max length to 20 --- packages/netglade_analysis/CHANGELOG.md | 1 + packages/netglade_analysis/lib/dcm.yaml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/netglade_analysis/CHANGELOG.md b/packages/netglade_analysis/CHANGELOG.md index 803feda..0630e7a 100644 --- a/packages/netglade_analysis/CHANGELOG.md +++ b/packages/netglade_analysis/CHANGELOG.md @@ -13,6 +13,7 @@ - Add prefer-private-extension-type-field - Add avoid-missing-controller - Add avoid-unnecessary-gesture-detector +- Update prefer-correct-switch-length max-length to 20 ## 8.0.0 - Adhere to DCM 1.14.0: diff --git a/packages/netglade_analysis/lib/dcm.yaml b/packages/netglade_analysis/lib/dcm.yaml index 2c65242..a4ebd01 100644 --- a/packages/netglade_analysis/lib/dcm.yaml +++ b/packages/netglade_analysis/lib/dcm.yaml @@ -236,7 +236,8 @@ dart_code_metrics: # - prefer-correct-json-casts # overkill - prefer-correct-setter-parameter-name - prefer-correct-stream-return-type - - prefer-correct-switch-length + - prefer-correct-switch-length: + max-length: 20 # default value 10 is sometimes way too much - prefer-correct-test-file-name - prefer-correct-type-name - prefer-declaring-const-constructor