Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
- `no_empty_bloc`
- `number_of_parameters`
- BREAKING CHANGE: Renamed `excludeNames` parameter to `exclude` for `function_lines_of_code` lint.
- Fixed an issue with `prefer_early_retrun` for throw expression
- Fixed an issue with `prefer_early_retrun` for throw expression
- Added `copyWith` to `exclude` section for `number_of_parameters` lint
Comment thread
yurii-prykhodko-solid marked this conversation as resolved.
Outdated

## 0.2.3

Expand Down
2 changes: 2 additions & 0 deletions lib/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ custom_lint:

- number_of_parameters:
max_parameters: 7
exclude:
- method_name: copyWith

- prefer_conditional_expressions:
ignore_nested: true
Expand Down
2 changes: 1 addition & 1 deletion lint_test/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ custom_lint:
exclude:
- class_name: Exclude
method_name: avoidNumberOfParameters
- method_name: avoidNumberOfParameters
- method_name: avoidNumberOfParameters
Comment thread
yurii-prykhodko-solid marked this conversation as resolved.
Outdated
- function_lines_of_code:
max_lines: 50
- avoid_non_null_assertion
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: ../../lib/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// ignore_for_file: prefer_match_file_name, public_member_api_docs
// Check number of parameters fail
///
/// `number_of_parameters: max_parameters`

class UserDto {
final String a;
final String b;
final String c;
final String d;
final String e;
final String f;
final String g;
final String h;

const UserDto({
required this.a,
required this.b,
required this.c,
required this.d,
required this.e,
required this.f,
required this.g,
required this.h,
});

/// Excluded by method_name
UserDto copyWith({
String? a,
String? b,
String? c,
String? d,
String? e,
String? f,
String? g,
String? h,
}) {
return UserDto(
a: a ?? this.a,
b: b ?? this.b,
c: c ?? this.c,
d: d ?? this.d,
e: e ?? this.e,
f: f ?? this.f,
g: g ?? this.g,
h: h ?? this.h,
);
}

/// expect_lint: number_of_parameters
UserDto noCopyWith({
String? a,
String? b,
String? c,
String? d,
String? e,
String? f,
String? g,
String? h,
}) {
return UserDto(
a: a ?? this.a,
b: b ?? this.b,
c: c ?? this.c,
d: d ?? this.d,
e: e ?? this.e,
f: f ?? this.f,
g: g ?? this.g,
h: h ?? this.h,
);
}

/// Allow
UserDto noLongCopyWith({
String? a,
String? b,
String? c,
}) {
return UserDto(
a: a ?? this.a,
b: b ?? this.b,
c: c ?? this.c,
d: '',
e: '',
f: '',
g: '',
h: '',
);
}
}
15 changes: 15 additions & 0 deletions lint_test/number_of_parameters_copy_with_test/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: solid_lints_number_of_parameters_copy_with_test
description: A starting point for Dart libraries or applications.
publish_to: none

environment:
sdk: '>=3.0.0 <4.0.0'

dependencies:
flutter:
sdk: flutter

dev_dependencies:
solid_lints:
path: ../../
test: ^1.20.1