-
Notifications
You must be signed in to change notification settings - Fork 13
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
Allow non capturing groups #9
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.
thanks so much for the contribution!
flags.go
Outdated
return errors.New("import flag must be of form path:alias") | ||
} | ||
|
||
v[spl[0]] = spl[1] | ||
v[strings.Join(spl[:len(spl)-1], ":")] = spl[len(spl)-1] |
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.
would it work to use strings.LastIndex here to avoid the join? something like:
i := strings.LastIndex(val, ":")
if i < 1 {
return errors.New("import flag must be of form path:alias")
}
v[val[:i]] = val[i+1:]
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.
good idea
38c63a0
to
81f7cac
Compare
81f7cac
to
643145a
Compare
@julz anything I can do for this PR to be merged? |
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.
oops! huge apologies @tomfeigin - this got completely lost in my GitHub notifications 😬
analyzer_test.go
Outdated
|
||
a := makeAnalyzer() | ||
flg := a.Flags.Lookup("alias") | ||
assert.EqualError(t, flg.Value.Set(""), errWrongAlias.Error()) |
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.
could we avoid adding a dependency on testify here? I think just asserting that we get an error might be fine for this test
analyzer_test.go
Outdated
} | ||
|
||
t.Run("wrong usage", func(t *testing.T) { |
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'd either move this test to its own top-level function (e.g. TestIncorrectFlags
), or add it to the existing table in this test (e.g. by adding an expectAliasFlagErr
field to the rows). I'd also personally be fine if we exported the stringMap
type and relied on a unit test (without constructing an analyser) for that to test this case.
643145a
to
ad1d901
Compare
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 to me, thanks! Just a couple tiny nits 🙏
analyzer_test.go
Outdated
} | ||
|
||
func TestIncorrectFlags(t *testing.T) { | ||
t.Run("wrong usage", func(t *testing.T) { |
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.
don't need the t.Run since there's only one test here :)
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.
your'e right
analyzer_test.go
Outdated
t.Run("wrong usage", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
assertWrongAliseErr := func(msg string, err error) { |
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.
assertWrongAliseErr := func(msg string, err error) { | |
assertWrongAliasErr := func(msg string, err error) { |
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.
oops
Fix the flags parsing to accept regexes with non capturing groups Signed-off-by: Tom <[email protected]>
ad1d901
to
c3e0594
Compare
Thanks @tomfeigin! |
hi, would you please be so kind as to make a new release including this. thx |
Fix the flags parsing to accept regexes with non capturing groups
Changes
/kind bug
Fixes #8
Regexs with non-capturing groups didn't work
Release Note
Docs