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

Fix Anko converter #218

Merged
merged 8 commits into from
Aug 24, 2018
Merged

Fix Anko converter #218

merged 8 commits into from
Aug 24, 2018

Conversation

stanislas-m
Copy link
Member

Fixes #217

@stanislas-m stanislas-m requested a review from a team as a code owner August 23, 2018 12:30
fix/anko.go Outdated
// skip already converted create_table
if strings.Contains(line, ", func(t) {") {
// fix create_table
line = strings.Replace(line, ", func(t) {", ") {", -1)
Copy link
Member

Choose a reason for hiding this comment

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

Since you are re-doing this, it would be nice to use regex.ReplaceAllString() so that it'll not care about any whitespace. (We didn't have , func, but ,func and it wouldn't work.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. :)

@stanislas-m stanislas-m added this to the v4.6.8 milestone Aug 24, 2018
fix/anko.go Outdated
i++
line = lines[i]
tl = strings.TrimSpace(line)
if l == i {
Copy link
Member

Choose a reason for hiding this comment

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

you are checking for overflow after trying to access an item past the length of the array on 38.

t.Column("id","uuid",{"primary":true})
}
)
Copy link
Member

Choose a reason for hiding this comment

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

I'm clearly just missing it since the tests are passing, but at some point you are going to have to explain to me how it's catching this straggler seeing as it looks to me as though it would have moved out of the create_table logic the line before.

@mclark4386
Copy link
Member

Thanks for changing that to a RegEx btw^^

@stanislas-m
Copy link
Member Author

@mclark4386 I've fixed the overflow check and added more details. :)

Copy link
Member

@mclark4386 mclark4386 left a comment

Choose a reason for hiding this comment

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

Perfect! Thanks!

fix/anko.go Outdated
// Now, we have to make sure to match the missing ")"
waitParen = true
} else if waitParen && strings.HasPrefix(tl, ")") {
break
Copy link
Member

Choose a reason for hiding this comment

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

Need to clear line before breaking and then we are good!

fix/anko.go Outdated
@@ -30,12 +30,13 @@ func Anko(content string) (string, error) {
waitParen := false
for {
if strings.HasPrefix(tl, "})") {
line = "}"
line = tl[2:]
Copy link
Member

Choose a reason for hiding this comment

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

in the case that tl is "})" then tl[2:] will be "". I think you were going for "}" + tl[2:]

@stanislas-m stanislas-m merged commit 9e0aa45 into development Aug 24, 2018
@stanislas-m stanislas-m deleted the task/fix-anko-converter branch August 24, 2018 21:08
stanislas-m added a commit that referenced this pull request Aug 24, 2018
* Fix Anko converter

Fixes #217

* Ensure Anko fixer handle whitespaces

* Fix possible overflow & improve "})" matching on multiple line

* Fix tests

* Revert "Fix tests"

This reverts commit 6f1e667.

* Clear the line after waiting for a parenthesis

* Fix a typo
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.

2 participants