Skip to content

Conversation

@rek
Copy link
Contributor

@rek rek commented Feb 10, 2024

Since my other branch is getting quite big, I thought I would split out some smaller PR's.

Here is one to make the lint go green. (it's mostly just running the auto-linter that CI uses locally)

Also:

  • use the skip-cache suggestion from here
  • Upgrade golangci-lint-action to v4.0.0

// acceptance testing. The factory function will be invoked for every Terraform
// CLI command executed to create a provider server to which the CLI can
// reattach.
var testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i will add all this test stuff back in in my other PR, but since it's unused here, we are getting that lint warning.

@rek rek mentioned this pull request Feb 14, 2024
3 tasks
"github.com/hashicorp/terraform-plugin-framework/types"

// "github.com/hashicorp/terraform-plugin-log/tflog"
// "github.com/hashicorp/terraform-plugin-log/tflog".
Copy link
Owner

Choose a reason for hiding this comment

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

@rek what is the . for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

$ golangci-lint run 

internal/service/folders/data_source.go:10:54: Comment should end in a period (godot)
	// "github.com/hashicorp/terraform-plugin-log/tflog"
	                                                    ^

It fixes this issue. But perhaps I should just remove that line instead.

return []ClickUpTeamMemberDataSourceModel{}
}
result := make([]ClickUpTeamMemberDataSourceModel, len(members), len(members))
result := make([]ClickUpTeamMemberDataSourceModel, 0, len(members))
Copy link
Owner

Choose a reason for hiding this comment

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

@rek I think it makes sense to just use make([]ClickUpTeamMemberDataSourceModel, len(members)) here and leave the capacity off it'll just get set the same automatically by make.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is trying to resolve this issue from golangci-lint run:

internal/service/teams/data_source.go:93:53: S1019: should use make([]ClickUpTeamMemberDataSourceModel, len(members)) instead (gosimple)
	result := make([]ClickUpTeamMemberDataSourceModel, len(members), len(members))

The problem with the gosimple suggestion is that it causes this further down the line:

internal/service/teams/data_source.go:117:12: append to slice `result` with non-zero initialized length (makezero)
		result = append(result, mem)

Here is the generated explanation:

there is a potential issue related to the use of make and append together, which could lead to unexpected results.

The line result := make([]ClickUpTeamMemberDataSourceModel, len(members)) creates a slice of ClickUpTeamMemberDataSourceModel with a length equal to len(members). This means that the slice result initially contains len(members) zero values.

Then, in the loop, you're using append to add elements to result. The append function does not replace the zero values, but adds new elements to the end of the slice. This means that after the loop, result will contain len(members) zero values, followed by the actual data.

I have changed that part now too, have a look and see what you think.

@rek rek requested a review from catdevman March 8, 2024 11:41
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