Skip to content

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"
@rudro rudro requested a review from tianskylan November 13, 2020 07:14
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.

4 participants