Skip to content

Commit

Permalink
Merge pull request #3814 from rrousselGit/fix-quickfix
Browse files Browse the repository at this point in the history
Fix-quickfix
  • Loading branch information
rrousselGit authored Oct 27, 2024
2 parents 0b29318 + 026c975 commit 6dab733
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 22 deletions.
2 changes: 1 addition & 1 deletion examples/counter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:

dev_dependencies:
build_runner: ^2.3.3
custom_lint: ^0.6.0
custom_lint: ^0.7.0
flutter_test:
sdk: flutter
freezed: ^2.3.2
Expand Down
2 changes: 1 addition & 1 deletion examples/marvel/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies:

dev_dependencies:
build_runner: ^2.0.0
custom_lint: ^0.6.0
custom_lint: ^0.7.0
flutter_test:
sdk: flutter
freezed: ^2.1.0
Expand Down
2 changes: 1 addition & 1 deletion examples/pub/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies:

dev_dependencies:
build_runner: ^2.0.0
custom_lint: ^0.6.0
custom_lint: ^0.7.0
flutter_test:
sdk: flutter
freezed: ^2.1.0
Expand Down
2 changes: 1 addition & 1 deletion examples/random_number/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
mockito: ^5.0.13

dev_dependencies:
custom_lint: ^0.6.0
custom_lint: ^0.7.0
flutter_lints: ^1.0.0
flutter_test:
sdk: flutter
Expand Down
2 changes: 1 addition & 1 deletion examples/stackoverflow/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies:

dev_dependencies:
build_runner: ^2.0.0
custom_lint: ^0.6.0
custom_lint: ^0.7.0
flutter_test:
sdk: flutter
freezed: ^2.1.0
Expand Down
4 changes: 2 additions & 2 deletions examples/todos/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ dependencies:
path: ../../packages/hooks_riverpod
riverpod:
path: ../../packages/riverpod
uuid: ^3.0.4
uuid: ^4.0.4

dev_dependencies:
build_runner: ^2.0.0
custom_lint: ^0.6.0
custom_lint: ^0.7.0
flutter_test:
sdk: flutter
riverpod_lint:
Expand Down
4 changes: 4 additions & 0 deletions packages/riverpod_analyzer_utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased patch

- Support latest custom_lint

## 0.5.6 - 2024-10-22

- Support analyzer >=6.7.0 <7.0.0
Expand Down
2 changes: 1 addition & 1 deletion packages/riverpod_analyzer_utils/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
analyzer: ^6.7.0
collection: ^1.16.0
crypto: ^3.0.2
custom_lint_core: ^0.6.0
custom_lint_core: ^0.7.0
freezed_annotation: ^2.2.0
meta: ^1.7.0
path: ^1.8.0
Expand Down
4 changes: 4 additions & 0 deletions packages/riverpod_lint/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased patch

- Support latest custom_lint

## 2.6.1 - 2024-10-22

- Support analyzer >=6.7.0 <7.0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart' hide LintCode;
import 'package:analyzer/error/error.dart'
hide
// ignore: undefined_hidden_name, necessary to support lower analyzer version
LintCode;
import 'package:analyzer/error/listener.dart';
import 'package:custom_lint_builder/custom_lint_builder.dart';
import 'package:riverpod_analyzer_utils/riverpod_analyzer_utils.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/error/error.dart' hide LintCode;
import 'package:analyzer/error/error.dart'
hide
// ignore: undefined_hidden_name, necessary to support lower analyzer version
LintCode;
import 'package:analyzer/error/listener.dart';
import 'package:custom_lint_builder/custom_lint_builder.dart';

Expand Down
15 changes: 12 additions & 3 deletions packages/riverpod_lint/lib/src/lints/functional_ref.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/error/error.dart' hide LintCode;
import 'package:analyzer/error/error.dart'
hide
// ignore: undefined_hidden_name, necessary to support lower analyzer version
LintCode;
import 'package:analyzer/error/listener.dart';
import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dart';
import 'package:collection/collection.dart';
Expand Down Expand Up @@ -80,7 +83,7 @@ class FunctionalRefFix extends RiverpodFix {

final refNode = declaration
.node.functionExpression.parameters!.parameters.firstOrNull;
if (refNode == null) {
if (refNode == null || refNode.isNamed) {
// No ref parameter, adding one
final changeBuilder = reporter.createChangeBuilder(
message: 'Add ref parameter',
Expand All @@ -90,9 +93,14 @@ class FunctionalRefFix extends RiverpodFix {
changeBuilder.addDartFileEdit((builder) {
final ref = builder.importRef();

var toInsert = '$ref ref';
if (refNode != null) {
toInsert = '$toInsert, ';
}

builder.addSimpleInsertion(
declaration.node.functionExpression.parameters!.leftParenthesis.end,
'$ref ref',
toInsert,
);
});
return;
Expand Down Expand Up @@ -135,6 +143,7 @@ extension ImportFix on DartFileEditBuilder {
return _importWithPrefix('Ref');
}

@useResult
String _importWithPrefix(String name) {
final hooksRiverpodUri =
Uri(scheme: 'package', path: 'hooks_riverpod/hooks_riverpod.dart');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/error/error.dart' hide LintCode;
import 'package:analyzer/error/error.dart'
hide
// ignore: undefined_hidden_name, necessary to support lower analyzer version
LintCode;
import 'package:analyzer/error/listener.dart';
import 'package:collection/collection.dart';
import 'package:custom_lint_builder/custom_lint_builder.dart';
Expand Down
5 changes: 4 additions & 1 deletion packages/riverpod_lint/lib/src/lints/notifier_build.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/error/error.dart' hide LintCode;
import 'package:analyzer/error/error.dart'
hide
// ignore: undefined_hidden_name, necessary to support lower analyzer version
LintCode;
import 'package:analyzer/error/listener.dart';
import 'package:custom_lint_builder/custom_lint_builder.dart';
import 'package:riverpod_analyzer_utils/riverpod_analyzer_utils.dart';
Expand Down
5 changes: 4 additions & 1 deletion packages/riverpod_lint/lib/src/lints/notifier_extends.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import 'package:analyzer/error/error.dart' hide LintCode;
import 'package:analyzer/error/error.dart'
hide
// ignore: undefined_hidden_name, necessary to support lower analyzer version
LintCode;
import 'package:analyzer/error/listener.dart';
import 'package:custom_lint_builder/custom_lint_builder.dart';
import 'package:riverpod_analyzer_utils/riverpod_analyzer_utils.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'dart:math';

import 'package:analyzer/error/error.dart' hide LintCode;
import 'package:analyzer/error/error.dart'
hide
// ignore: undefined_hidden_name, necessary to support lower analyzer version
LintCode;
import 'package:analyzer/error/listener.dart';
import 'package:collection/collection.dart';
import 'package:custom_lint_builder/custom_lint_builder.dart';
Expand Down
2 changes: 1 addition & 1 deletion packages/riverpod_lint/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
analyzer: ^6.7.0
analyzer_plugin: ^0.11.2
collection: ^1.16.0
custom_lint_builder: ^0.6.0
custom_lint_builder: ^0.7.0
meta: ^1.7.0
path: ^1.8.1
riverpod: 2.6.1
Expand Down
4 changes: 2 additions & 2 deletions packages/riverpod_lint_flutter_test/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ dependencies:

dev_dependencies:
build_runner: ^2.4.6
custom_lint: ^0.6.0
custom_lint_core: ^0.6.0
custom_lint: ^0.7.0
custom_lint_core: ^0.7.0
freezed: ^2.3.2
json_serializable: ^6.6.1
riverpod_lint:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ int incorrectlyTyped(
return 0;
```
---
Message: `Type as Ref`
Message: `Add ref parameter`
Priority: 90
Diff for file `test/lints/functional_ref/functional_ref.dart:34`:
```
@riverpod
// expect_lint: functional_ref
- int noRefButArgs({int a = 42}) {
+ int noRefButArgs({Ref a = 42}) {
+ int noRefButArgs(Ref ref, {int a = 42}) {
return 0;
}
```
Expand Down

0 comments on commit 6dab733

Please sign in to comment.