Repository navigation
- Added excludeNames param for function_lines_of_code lint
#141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
3d692ac
d3a304f
a5d7936
f9686f2
47da2a2
e5c6d7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,16 +5,22 @@ class FunctionLinesOfCodeParameters { | |||||
| /// exceeding this limit triggers a warning. | ||||||
| final int maxLines; | ||||||
|
|
||||||
| /// Method names to be excluded from the rule check | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Does it make sense to be consistent with all the rest documentation/naming?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||
| final List<String> excludeNames; | ||||||
|
|
||||||
| static const _defaultMaxLines = 200; | ||||||
|
|
||||||
| /// Constructor for [FunctionLinesOfCodeParameters] model | ||||||
| const FunctionLinesOfCodeParameters({ | ||||||
| required this.maxLines, | ||||||
| required this.excludeNames, | ||||||
| }); | ||||||
|
|
||||||
| /// Method for creating from json data | ||||||
| factory FunctionLinesOfCodeParameters.fromJson(Map<String, Object?> json) => | ||||||
| FunctionLinesOfCodeParameters( | ||||||
| maxLines: json['max_lines'] as int? ?? _defaultMaxLines, | ||||||
| excludeNames: | ||||||
| List<String>.from(json['excludeNames'] as Iterable? ?? []), | ||||||
| ); | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| analyzer: | ||
| plugins: | ||
| - ../custom_lint | ||
|
|
||
| custom_lint: | ||
| rules: | ||
| - function_lines_of_code: | ||
| max_lines: 5 | ||
| excludeNames: | ||
| - "longFunctionExcluded" | ||
| - "longMethodExcluded" |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for changing the file name to a proper one! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| class ClassWithLongMethods { | ||
| // expect_lint: function_lines_of_code | ||
| int longMethod() { | ||
| var i = 0; | ||
| i++; | ||
| i++; | ||
| i++; | ||
| i++; | ||
| return i; | ||
| } | ||
|
|
||
| // Excluded by excludeNames | ||
| int longMethodExcluded() { | ||
| var i = 0; | ||
| i++; | ||
| i++; | ||
| i++; | ||
| i++; | ||
| return i; | ||
| } | ||
| } | ||
|
Comment on lines
+27
to
+29
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be great to also test that it does not report false positives for both - methods and functions.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
|
||
| // expect_lint: function_lines_of_code | ||
| int longFunction() { | ||
| var i = 0; | ||
| i++; | ||
| i++; | ||
| i++; | ||
| i++; | ||
| return i; | ||
| } | ||
|
|
||
| // Excluded by excludeNames | ||
| int longFunctionExcluded() { | ||
| var i = 0; | ||
| i++; | ||
| i++; | ||
| i++; | ||
| i++; | ||
| return i; | ||
| } | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, extract this into a separate private method or just inline it into current method. Do not use inline function declaration since it hurts readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done