Skip to content

chore: Remove unneeded Go linter exceptions #3247

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

Merged
merged 11 commits into from
Apr 9, 2025
Merged

Conversation

lantoli
Copy link
Member

@lantoli lantoli commented Apr 4, 2025

Description

Remove unneeded Go linter exceptions. Only do exceptions when strictly needed so the codebase follows linter rules.

  • PR tests failing in encryption group with error CANNOT_DISABLE_ENCRYPTION_AT_REST_REQUIRE_PRIVATE_NETWORKING_WHILE_PRIVATE_ENDPOINTS_EXIST
  • adv_cluster test group: pass
  • adv_cluster_tpf group: pass

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals I have added appropriate changelog entries.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

@@ -161,7 +161,7 @@ func TestAccMockableAdvancedCluster_tenantUpgrade(t *testing.T) {
projectID, clusterName = acc.ProjectIDExecutionWithCluster(t, 1)
defaultZoneName = "Zone 1" // Uses backend default to avoid non-empty plan, see CLOUDP-294339
)
unit.CaptureOrMockTestCaseAndRun(t, mockConfig, &resource.TestCase{
unit.CaptureOrMockTestCaseAndRun(t, &mockConfig, &resource.TestCase{
Copy link
Member Author

Choose a reason for hiding this comment

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

fixes: hugeParam: config is heavy (112 bytes); consider passing it by pointer (gocritic)

customOpensslCipherConfigTLS12Str = fmt.Sprintf(
`custom_openssl_cipher_config_tls12 = ["%s"]`,
Copy link
Member Author

Choose a reason for hiding this comment

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

fixes: sprintfQuotedString: use %q instead of "%s" for quoted strings (gocritic)

@@ -1,4 +1,3 @@
//nolint:gocritic
Copy link
Member Author

Choose a reason for hiding this comment

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

leftover, no needed anymore

@@ -1,4 +1,3 @@
//nolint:gocritic
Copy link
Member Author

Choose a reason for hiding this comment

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

leftover, no needed anymore

@@ -30,12 +30,6 @@ type MockHTTPDataConfig struct {
IsDiffMustSubstrings []string // Only include diff request for specific substrings, for example /clusters (avoids project create requests)
QueryVars []string // Substitute this query vars. Useful when differentiating responses based on query args, for example ?providerName=AWS/AZURE returns different responses
AllowMissingRequests bool // When false will require all API calls to be made.
AllowOutOfOrder bool // When true will allow a GET request returned after a POST to be returned before the POST.
Copy link
Member Author

Choose a reason for hiding this comment

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

I think AllowOutOfOrder is not being used anymore, can @EspenAlbert you please confirm?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Although not used anywhere in the code, it can be helpful while debugging. I would prefer to keep it

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, keeping, adding comment

@@ -53,7 +47,7 @@ func IsDataUpdate() bool {
return val
}

func CaptureOrMockTestCaseAndRun(t *testing.T, config MockHTTPDataConfig, testCase *resource.TestCase) { //nolint: gocritic // Want each test run to have its own config (hugeParam: config is heavy (112 bytes); consider passing it by pointer)
Copy link
Member Author

Choose a reason for hiding this comment

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

fixes: hugeParam: config is heavy (112 bytes); consider passing it by pointer (gocritic)

Copy link
Collaborator

@EspenAlbert EspenAlbert Apr 8, 2025

Choose a reason for hiding this comment

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

Want each test run to have its own config

I prefer keeping this as is

@@ -56,7 +56,7 @@ type RequestInfo struct {
}

// Custom marshaling is necessary to use `flow` style only on response fields (text and responses.*.text)
func (i RequestInfo) MarshalYAML() (any, error) { //nolint:gocritic // Using a pointer method leads to inconsistent dump results
func (i *RequestInfo) MarshalYAML() (any, error) {
Copy link
Member Author

@lantoli lantoli Apr 4, 2025

Choose a reason for hiding this comment

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

fixes: hugeParam: i is heavy (88 bytes); consider passing it by pointer (gocritic)

al other RequestInfo funcs are using pointers

Version string `yaml:"version"`
Text string `yaml:"text"`
Responses []StatusText `yaml:"responses"`
Responses *[]StatusText `yaml:"responses"`
Copy link
Member Author

Choose a reason for hiding this comment

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

fixes: hugeParam: i is heavy (88 bytes); consider passing it by pointer (gocritic)

lantoli added 2 commits April 4, 2025 17:27
* master:
  feat: Support configuring BYOK encryption on search nodes (#3199)
  chore: Updates Atlas Go SDK (#3235)

# Conflicts:
#	internal/testutil/acc/advanced_cluster.go
@lantoli lantoli marked this pull request as ready for review April 4, 2025 15:33
@lantoli lantoli requested a review from a team as a code owner April 4, 2025 15:33
@@ -53,7 +47,7 @@ func IsDataUpdate() bool {
return val
}

func CaptureOrMockTestCaseAndRun(t *testing.T, config MockHTTPDataConfig, testCase *resource.TestCase) { //nolint: gocritic // Want each test run to have its own config (hugeParam: config is heavy (112 bytes); consider passing it by pointer)
Copy link
Member

Choose a reason for hiding this comment

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

we should double check with @EspenAlbert but it seems the pass by value is intentional and needed here?

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks, I'll wait

This reverts commit a2be534.
@lantoli lantoli added the not_stale Not stale issue or PR label Apr 8, 2025
lantoli added 4 commits April 8, 2025 15:27
* master:
  chore: Updates org_clean_test.go to delete stream instances & private endpoint services (#3252)
  chore: Updates organization.md `skip_default_alerts_settings` note format (#3246)
  doc: Update guidelines for external contributors to squash commits (#3243)
  chore: Updates CHANGELOG.md for #3199
Copy link
Collaborator

@EspenAlbert EspenAlbert left a comment

Choose a reason for hiding this comment

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

Thank you!

@lantoli
Copy link
Member Author

lantoli commented Apr 9, 2025

encryption test group is also failing in master, e.g. here

@lantoli lantoli merged commit b88f2a9 into master Apr 9, 2025
39 of 40 checks passed
@lantoli lantoli deleted the remove_lint_exceptions branch April 9, 2025 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not_stale Not stale issue or PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants