Skip to content

Conversation

@mwbrooks
Copy link
Member

Summary

This pull request enables the linter staticcheck rule QF1004: 'Use strings.ReplaceAll instead of strings.Replace with n == -1'.

Requirements

@mwbrooks mwbrooks added this to the Next Release milestone May 19, 2025
@mwbrooks mwbrooks self-assigned this May 19, 2025
@mwbrooks mwbrooks requested a review from a team as a code owner May 19, 2025 14:53
@mwbrooks mwbrooks added code health M-T: Test improvements and anything that improves code health semver:patch Use on pull requests to describe the release version increment labels May 19, 2025
@codecov
Copy link

codecov bot commented May 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.28%. Comparing base (7552617) to head (b967a87).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #99      +/-   ##
==========================================
- Coverage   63.31%   63.28%   -0.03%     
==========================================
  Files         211      211              
  Lines       22282    22282              
==========================================
- Hits        14108    14102       -6     
- Misses       7087     7089       +2     
- Partials     1087     1091       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

@mwbrooks Thanks so much for finding the time to continue these cleanups 💌

I'm approving these changes now but noticed a possible bug that these changes uncovered that might be nice to address in this PR?

Having a number of static checks that can now be counted is exciting for me 🤖

// TODO, @cchensh, we should get prepared for other non-Git hosts and refactor the create pkg
func generateGitZipFileURL(templateURL string, gitBranch string) string {
zipURL := strings.Replace(templateURL, ".git", "", -1) + "/archive/refs/heads/"
zipURL := strings.ReplaceAll(templateURL, ".git", "") + "/archive/refs/heads/"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
zipURL := strings.ReplaceAll(templateURL, ".git", "") + "/archive/refs/heads/"
zipURL := strings.TrimSuffix(templateURL, ".git") + "/archive/refs/heads/"

🤔 This might've been an existing bug, but we might want to just trim the suffix here?

In this example the template URL for the project is changed in an unexpected fashion:

- https://github.com/slack-samples/example.git-project.git
+ https://github.com/slack-samples/example-project

I don't think we have a test that covers these cases, but it might be nice to cover this case with these changes 🙏 ✨

Copy link
Member Author

Choose a reason for hiding this comment

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

Wow, this is a great find! I doubt we have a test for this, so I'm leaning toward merging this PR (linter enablement) and follow-up with a new PR that fixes this issue w/ tests (fix: creating projects from a template url that contains .git).

@mwbrooks
Copy link
Member Author

Thanks for the quick review @zimeg. Slowly, we're enabling all of the linters 📝

I'm going to merge this PR and follow-up with a 2nd that fixes the issue that you noticed. I'm doing this so that we have CHANGELOG entries for each (enabling a new linter and fixing an issue). Plus, we can take time to ensure that there are proper tests. ✌🏻

@mwbrooks mwbrooks merged commit 7235111 into main May 20, 2025
6 checks passed
@mwbrooks mwbrooks deleted the mwbrooks-lint-qf1004 branch May 20, 2025 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code health M-T: Test improvements and anything that improves code health semver:patch Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants