Skip to content
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

Skip methods that just pass depndencies along #379

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rudro
Copy link
Collaborator

@rudro rudro commented Nov 13, 2020

  • These methods are one-liners of the form "return dependency.propertyName"

- These methods are one-liners of the form "return dependency.propertyName"
Copy link
Contributor

@tianskylan tianskylan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a unit test for this? Should be pretty straightforward

if let block = pattern.children.first(where: { $0.is(CodeBlockSyntax.self) }), let fullBody = block.as(CodeBlockSyntax.self) {
// Make sure that the code block is a one-liner
if let statement = fullBody.statements.first, fullBody.statements.count == 1 {
let trimmed = statement.description.trimmingCharacters(in: .whitespacesAndNewlines)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a trimmed convenience method for this. You can do .description.trimmed directly

// Make sure that the code block is a one-liner
if let statement = fullBody.statements.first, fullBody.statements.count == 1 {
let trimmed = statement.description.trimmingCharacters(in: .whitespacesAndNewlines)
let lookFor1 = "return dependency.\(propertyName)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trimmed will never be equal to lookFor1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants