-
Notifications
You must be signed in to change notification settings - Fork 37
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: Scaffolding now properly populates templatesge nam… #277
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.
Looks good! Just a minor correction required. I'm also not sure what the newly added .regal
directory is there for?
cmd/new.go
Outdated
} else { | ||
tmplNameTestValue = "." + params.name + "_test" | ||
tmplNameTestValue = "." + params.name + "-test" |
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.
This shouldn't change — the _test
suffix is idiomatic for test packages.
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 ran "regal new rule -t custom -c test -n some_name" a few times, so it might have created it.
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.
But why doesn't it build correctly?
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.
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 ran "regal new rule -t custom -c test -n some_name" a few times, so it might have created it.
What I mean is — even if your linte rule would be called "foo-bar-baz", the idiomatic naming for its test package would be "foo-bar-baz_test". So the code should not rewrite that to be "foo-bar-baz-test".
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.
However, it still doesn't seem to build. I can't figure out why.
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 linter is complaining that we're not using the first assignment, i.e.
// This assignment is never used
tmplNameValue := strings.ReplaceAll(params.name, "_", "-")
And it's correct about that. It was my code, so apologies for that! We should of course us it in the contains check:
tmplNameValue = strings.ReplaceAll(params.name, "_", "-")
if strings.Contains(tmplNameValue, "-") {
Same thing for the test template name.
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.
Should be fixed now. Still doesn't build - a ton of "Cannot open: file exists" errors.
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.
Finally works - had to decuddle assignments (their linter sure is rough to get by) :)
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.
Hehe, sure is! Yeah, those warnings are annoying but nothing to worry about. Some bug in the Go linter as I understood it.
I'd suggest getting golangcilint
yourself so that you can run golangci-lint run ./...
yourself before pushing your commits.
95c125b
to
2af28a0
Compare
…es, imports the correct path 'as rule' and pupulates 'title' correctly in test.
8cd382f
to
53bf024
Compare
Thanks! |
* fix, scaffolding now populates the templates with correct package names, imports the correct path 'as rule' and pupulates 'title' correctly in test.
The scaffolding "regal new rule" was adding incorrectly formatted package names in both the regal policy and the test.
This PR should fix the following: