-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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/validate-args-length #2823 #3974
base: master
Are you sure you want to change the base?
fix/validate-args-length #2823 #3974
Conversation
Signed-off-by: arjitGopher <agarwalarjit.agarwal@gmail.com>
js/modules/k6/http/http.go
Outdated
validateArgCount := func(methodName string,args ...sobek.Value){ | ||
if len(args)>2 { | ||
vu.State().Logger.Warningf("%s method has more than two arguments",methodName) | ||
} | ||
} |
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.
validateArgCount := func(methodName string,args ...sobek.Value){ | |
if len(args)>2 { | |
vu.State().Logger.Warningf("%s method has more than two arguments",methodName) | |
} | |
} | |
validateArgCount := func(methodName string,args ...sobek.Value){ | |
if len(args)>2 { | |
vu.State().Logger.Warnf("http.%s method has more than two arguments",methodName) | |
} | |
} |
Small suggestion
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 do agree with @joanlopez that it's better to add http
prefix.
Also, how about changing the message to something more actionable, like http.%s requires two arguments, but %d were provided. Please adjust the input.
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 like the new code is not correctly formatted, @ArjitGopher could you run the linter and fix the related issues, please?
Beyond that, I only have a small suggestion because I think these functions are usually called like http.get(...)
, as suggested in the official docs, and in any case, it's always good idea to disambiguate.
Other than that, it looks good! 👍🏻
cc/ @olegbespalov
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 for the contribution!
I do agree with what @joanlopez said, also have a minor suggestion for the actual message
js/modules/k6/http/http.go
Outdated
validateArgCount := func(methodName string,args ...sobek.Value){ | ||
if len(args)>2 { | ||
vu.State().Logger.Warningf("%s method has more than two arguments",methodName) | ||
} | ||
} |
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 do agree with @joanlopez that it's better to add http
prefix.
Also, how about changing the message to something more actionable, like http.%s requires two arguments, but %d were provided. Please adjust the input.
Hi @ArjitGopher. Out of curiosity, are you going to apply feedback, or you have no capacity of doing that? |
Hi @olegbespalov I agree with the suggestions and will add them today, Thanks |
What?
This PR aims to solve the issue #2823
Why?