-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: Improve prefer_sliver_prefix to prefer_to_include_sliver_in_name #58
feat: Improve prefer_sliver_prefix to prefer_to_include_sliver_in_name #58
Conversation
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.
|
||
final className = node.name.lexeme; | ||
final constructorNames = node.members | ||
.whereType<ConstructorDeclaration>() | ||
.map((constructor) => constructor.name?.lexeme) | ||
.whereType<String>(); | ||
final hasSliverInClassOrConstructor = className.contains('Sliver') || | ||
constructorNames.any( | ||
(constructorName) => | ||
constructorName.toLowerCase().contains('sliver'), | ||
); | ||
|
||
if (returnsSliverWidget && !hasSliverInClassOrConstructor) { | ||
reporter.atNode(node, _code); | ||
} |
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 evaluation of returnSliverWidget
could be done earlier, allowing for an early return if necessary!
Similarly, the checks for className
and constructorNames
could also be implemented as early returns, potentially reducing unnecessary member access.
final className = node.name.lexeme; | |
final constructorNames = node.members | |
.whereType<ConstructorDeclaration>() | |
.map((constructor) => constructor.name?.lexeme) | |
.whereType<String>(); | |
final hasSliverInClassOrConstructor = className.contains('Sliver') || | |
constructorNames.any( | |
(constructorName) => | |
constructorName.toLowerCase().contains('sliver'), | |
); | |
if (returnsSliverWidget && !hasSliverInClassOrConstructor) { | |
reporter.atNode(node, _code); | |
} | |
if (!returnsSliverWidget) { | |
return; | |
} | |
final className = node.name.lexeme; | |
if (className.contains('Sliver')) { | |
return; | |
} | |
final constructorNames = node.members | |
.whereType<ConstructorDeclaration>() | |
.map((constructor) => constructor.name?.lexeme) | |
.nonNulls; | |
final hasSliverConstructor = constructorNames.any( | |
(name) => name.toLowerCase().contains('sliver'), | |
); | |
if (hasSliverConstructor) { | |
return; | |
} | |
reporter.atNode(node, _code); |
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.
🔗 Related Issues
prefer_sliver_prefix
toprefer_to_include_sliver_in_name
#36🙌 What's Done
✍️ What's Not Done
🖼️ Image Differences
🤼 Desired Review Method
Note
It is possible that a reviewer's will may cause a method to be implemented that is not selected.
📝 Additional Notes
Pre-launch Checklist