Skip to content

Commit 2cc9b19

Browse files
author
shaark
committed
issue-167. fixed after comments
1 parent 71c28c0 commit 2cc9b19

File tree

6 files changed

+44
-10
lines changed

6 files changed

+44
-10
lines changed

CHANGELOG.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
## 0.3.4
2-
- Added exclude classes, methods, functions into avoid_returning_widgets,avoid_unused_parameters, cyclomatic_complexity, function_lines_of_code, no_empty_bloc, number_of_parameters
3-
- Changed exclude parameter name into unction lines of code from excludeNames to exclude
4-
5-
## 0.2.4
6-
1+
## 0.3.0
2+
- Added `exclude` parameter for the following lints:
3+
- `avoid_returning_widgets`
4+
- `avoid_unused_parameters`
5+
- `cyclomatic_complexity`
6+
- `function_lines_of_code`
7+
- `no_empty_bloc`
8+
- `number_of_parameters`
9+
- BREAKING CHANGE: Renamed `excludeNames` parameter to `exclude` for `function_lines_of_code` lint.
710
- Fixed an issue with `prefer_early_retrun` for throw expression
811

912
## 0.2.3

lib/src/common/parameters/excluded_identifier_parameter.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ExcludedIdentifierParameter {
99
/// Constructor for [ExcludedIdentifierParameter] model
1010
const ExcludedIdentifierParameter({
1111
required this.methodName,
12-
required this.className,
12+
this.className,
1313
});
1414

1515
///

lib/src/common/parameters/excluded_identifiers_list_parameter.dart

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ class ExcludedIdentifiersListParameter {
2626
for (final item in excludeList) {
2727
if (item is Map) {
2828
exclude.add(ExcludedIdentifierParameter.fromJson(item));
29+
} else if (item is String) {
30+
exclude.add(
31+
ExcludedIdentifierParameter(
32+
methodName: item,
33+
),
34+
);
2935
}
3036
}
3137
return ExcludedIdentifiersListParameter(
@@ -47,6 +53,12 @@ class ExcludedIdentifiersListParameter {
4753
for (final item in excludeList) {
4854
if (item is Map) {
4955
exclude.add(ExcludedIdentifierParameter.fromJson(item));
56+
} else if (item is String) {
57+
exclude.add(
58+
ExcludedIdentifierParameter(
59+
methodName: item,
60+
),
61+
);
5062
}
5163
}
5264
return ExcludedIdentifiersListParameter(
@@ -56,10 +68,10 @@ class ExcludedIdentifiersListParameter {
5668

5769
/// Returns whether the target node should be ignored during analysis.
5870
bool shouldIgnore(Declaration node) {
59-
final methodName = node.declaredElement?.name;
71+
final declaredName = node.declaredElement?.name;
6072

6173
final excludedItem = exclude.firstWhereOrNull(
62-
(e) => e.methodName == methodName || e.className == methodName,
74+
(e) => e.methodName == declaredName || e.className == declaredName,
6375
);
6476

6577
if (excludedItem == null) return false;

lib/src/lints/no_empty_block/models/no_empty_block_parameters.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:solid_lints/src/common/parameters/excluded_identifiers_list_parameter.dart';
22

3-
/// A data model class that represents the "no empty block" input
3+
/// A data model class that represents the "no empty block" lint input
44
/// parameters.
55
class NoEmptyBlockParameters {
66
/// A list of methods that should be excluded from the lint.

lint_test/analysis_options.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ custom_lint:
3737
- class_name: Exclude
3838
method_name: excludeMethod
3939
- method_name: excludeMethod
40+
- simpleMethodName
41+
- SimpleClassName
4042
- newline_before_return
4143
- no_empty_block:
4244
exclude:

lint_test/avoid_unused_parameters_test.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ void excludeMethod(String s) {
213213
return;
214214
}
215215

216+
// no lint
217+
void simpleMethodName(String s) {
218+
return;
219+
}
220+
216221
class Exclude {
217222
// no lint
218223
void excludeMethod(String s) {
@@ -224,3 +229,15 @@ class Exclude {
224229
return;
225230
}
226231
}
232+
233+
class SimpleClassName {
234+
// no lint
235+
void simpleMethodName(String s) {
236+
return;
237+
}
238+
239+
// expect_lint: avoid_unused_parameters
240+
void simpleMethodName2(String s) {
241+
return;
242+
}
243+
}

0 commit comments

Comments
 (0)