Skip to content

Conversation

KaushikiAnand
Copy link

  • I have added unit test coverage and linting to the ci.yml workflow.
  • The unit test coverage change was done to help understand the defects early in lifecycle and come up with a good solution for it. The linting was done to ensure that the codebase is consistent and maintainable and helps in improving the code quality and reducing errors.

@KaushikiAnand KaushikiAnand requested a review from a team as a code owner March 13, 2025 08:17
.golangci.yml Outdated
- errcheck
disable:
- unused
output_format: colored-line-number No newline at end of file
Copy link

Choose a reason for hiding this comment

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

Suggestion: new lint

Copy link

Choose a reason for hiding this comment

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

Also, why did we need to disable unused ?

request.go Outdated
}
if err := json.NewDecoder(buf).Decode(relationship); err != nil {
return err
}
Copy link

Choose a reason for hiding this comment

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

Question: Can you check if the same pattern is happening for other error scenarios ?

I saw at some places, we are setting the value of er and letting the flow either break or continue

Copy link
Author

Choose a reason for hiding this comment

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

followed the same pattern on suggested areas.

Choose a reason for hiding this comment

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

please add a break for all newly added errors

Copy link
Author

Choose a reason for hiding this comment

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

added break to newly added errors

Copy link

hashicorp-cla-app bot commented Mar 27, 2025

CLA assistant check
All committers have signed the CLA.


func TestHttpErrorWhenMethodDoesNotMatch(t *testing.T) {
r, err := http.NewRequest(http.MethodPatch, "/blogs", nil)
r, err := http.NewRequest(http.MethodOptions, "/blogs", nil)

Choose a reason for hiding this comment

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

This test is currently failing in the main branch. It is failing because previously there wasn't any handling for the method http.MethodPatch but around an year back code was added for this case as well.
I have changed the http method to an unhandled path, so that the test case runs as expected


type OneOfMedia struct {
Image *Image
random int

Choose a reason for hiding this comment

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

unused field


func TestUnmarshalToStructWithPointerAttr_BadType_IntSlice(t *testing.T) {
out := new(WithPointer)
type FooStruct struct{ A, B int }

Choose a reason for hiding this comment

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

unused

}
videoField, ok := result["videos"]
if !ok || videoField.FieldNum != 2 {
if !ok || videoField.FieldNum != 1 {

Choose a reason for hiding this comment

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

An unused field was removed, thus the FieldNum for videoField decreased

@sonamtenzin2 sonamtenzin2 requested a review from abhijeetviswa May 6, 2025 06:25
Comment on lines +456 to 458
json.NewEncoder(buf).Encode(data.Relationships[args[1]]) //nolint:errcheck
json.NewDecoder(buf).Decode(relationship) //nolint:errcheck

Choose a reason for hiding this comment

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

Comment: We are ignoring the lint error to preserve behaviour.

@sonamtenzin2 sonamtenzin2 merged commit 074c4f2 into main Jun 24, 2025
5 checks passed
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.

5 participants