-
Notifications
You must be signed in to change notification settings - Fork 18
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
I167 #171
Conversation
final isIgnored = config.parameters.matchMethod(node) || | ||
config.parameters.matchClass(node); |
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.
The class_name parameter means that the method_name in the class_name should not be processed by this lint. Not the whole class.
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.
It does work this way.
If you only specify the class name, then the entire class will be ignored, but if you specify both class and method name, then only this method in this class will be ignored.
exclude:
# excludes a matching method in a matching class
- method_name: excludeMethod
class_name: ExcludeClass
# excludes a matching method anywhere
- method_name: excludeFunction
# excludes all methods within a matching class
- class_name: ExcludeEntireClass
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.
Then we should make it more clear here since currently it looks confusing. I'd suggest improving the naming.
@@ -48,6 +55,11 @@ class AvoidUnusedParametersVisitor extends RecursiveAstVisitor<void> { | |||
parameters.parameters.isEmpty) { | |||
return; | |||
} | |||
|
|||
if (ignoredEntities.matchClass(node)) { |
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.
I think the idea is to create a mechanism that will allow us to easilly reuse such code between different linter rules instead of just implementing it separately for each rule.
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.
It has to be used slightly differently in different rules. I.e. in this one, the check has to be performed in the visitor, instead of directly in the run
function, and matchClass
and matchMethod
have to be used separately.
Most of the logic (parsing and matching against the list) is still inside the IgnoredEntitiesModel
. Having two methods like that seemed like the minimal amount of code that is still flexible enough to adapt to different rules.
I just checked, and I think this particular rule can be implemented without the visitor. I can try that, but it won't change the way the check is performed here.
/// Threshold cyclomatic complexity level, exceeding it triggers a warning. | ||
final int maxComplexity; | ||
/// `max_complexity` configuration | ||
final MaxCyclomaticComplexityParameters maxCyclomaticComplexity; |
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.
I do not think you need to create a separate class for extra params. Just go ahead and inherit this parameters class from the IgnoredEntitiesModel
.
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.
I think it's easier to implement fromJson
this way. Otherwise:
class CyclomaticComplexityParams extends IgnoredEntitiesModel {
// ...
factory CyclomaticComplexityParams.fromJson(Map<String, Object?> json) {
// With more properties, I'll have to go through all of them:
final entities = IgnoredEntitiesModel.fromJson(json).entities;
return CyclomaticComplexityParams(
entities: entities,
other: 1,
);
}
}
bf44545
to
7cddd57
Compare
…void_returning_widgets
No description provided.