Skip to content

Conversation

@mwbrooks
Copy link
Member

@mwbrooks mwbrooks commented May 9, 2025

Summary

This pull request enables the linter staticcheck rule ST1016: 'Use consistent method receiver names'.

For each, I choose the receiver name that was used the majority of the time.

Requirements

@mwbrooks mwbrooks added this to the Next Release milestone May 9, 2025
@mwbrooks mwbrooks self-assigned this May 9, 2025
@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 9, 2025
@codecov
Copy link

codecov bot commented May 9, 2025

Codecov Report

Attention: Patch coverage is 64.28571% with 5 lines in your changes missing coverage. Please review.

Project coverage is 63.19%. Comparing base (53f1124) to head (8212d45).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/prompts/app_select.go 75.00% 3 Missing ⚠️
internal/slackdeps/os.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #86      +/-   ##
==========================================
+ Coverage   63.17%   63.19%   +0.01%     
==========================================
  Files         210      210              
  Lines       22186    22186              
==========================================
+ Hits        14017    14020       +3     
+ Misses       7082     7081       -1     
+ Partials     1087     1085       -2     

☔ 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.

// auth or an app that corresponds. E.g. when you are comparing to --team flags
func (t *TeamApps) authOrAppTeamDomain() string {
if t.Auth.TeamDomain != "" && (t.Auth.TeamID == t.Hosted.App.TeamID || t.Auth.TeamID == t.Local.App.TeamID) {
func (apps *TeamApps) authOrAppTeamDomain() string {
Copy link
Member Author

Choose a reason for hiding this comment

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

note: The apps receiver name is used the majority of the time. However, I noticed that Golang encourages short, 1-or-2 letter receiver names. In this case a, t, or ta would be more appropriate. However, this file is quite long and apps reads well. So I leaned toward less changes.

Copy link
Member

Choose a reason for hiding this comment

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

In implementations having a more complete variable name seems better to me. Thanks for linking these docs though. It makes for interesting considerations... 🎁

The name need not be as descriptive as that of a method argument, as its role is obvious and serves no documentary purpose.

Sometimes I find it a hassle to search for single letter variables FWIW but this is the most interesting consideration. Perhaps I am needing to read more go 🙏 ✨

Copy link
Member

Choose a reason for hiding this comment

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

Edit: Wow I find the change that follows this in os.go makes sense as a single letter. So much to consider.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, I'm with you. Sometimes the single letter just doesn't feel right. For TeamApps, maybe rethinking the struct's name (or purpose) will help? But, overall I'm cool with apps :)

@mwbrooks mwbrooks marked this pull request as ready for review May 9, 2025 16:33
@mwbrooks mwbrooks requested a review from a team as a code owner May 9, 2025 16:33
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 Once more a wonderful PR to improve the health of code 🏥 ✨

These are appreciated and it's motivating to find a few of these landing so often - I'm feeling better and better about the code and hadn't even realized these linting rules were broken before the latest golangci-lint updates 🔍

- '-QF1004' # disable rule 'Use strings.ReplaceAll instead of strings.Replace'
- '-QF1008' # disable rule 'Omit embedded fields from selector'
- '-QF1011' # disable rule 'Omit redundant type from variable declaration'
- '-ST1016' # disable rule 'Use consistent method receiver names'
Copy link
Member

Choose a reason for hiding this comment

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

🪓 ✨

// SetExitCode sets the desired exit code in a thread-safe way
func (io *IOStreamsMock) SetExitCode(code ExitCode) {
atomic.StoreInt32((*int32)(&io.exitCode), int32(code))
func (m *IOStreamsMock) SetExitCode(code ExitCode) {
Copy link
Member

Choose a reason for hiding this comment

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

🧪 Nice! I like mock being m if this is what's found elsewhere!

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, m seems to be a common receiver name for mocks. Makes sense to me and keeps it consistent.

// auth or an app that corresponds. E.g. when you are comparing to --team flags
func (t *TeamApps) authOrAppTeamDomain() string {
if t.Auth.TeamDomain != "" && (t.Auth.TeamID == t.Hosted.App.TeamID || t.Auth.TeamID == t.Local.App.TeamID) {
func (apps *TeamApps) authOrAppTeamDomain() string {
Copy link
Member

Choose a reason for hiding this comment

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

In implementations having a more complete variable name seems better to me. Thanks for linking these docs though. It makes for interesting considerations... 🎁

The name need not be as descriptive as that of a method argument, as its role is obvious and serves no documentary purpose.

Sometimes I find it a hassle to search for single letter variables FWIW but this is the most interesting consideration. Perhaps I am needing to read more go 🙏 ✨

// auth or an app that corresponds. E.g. when you are comparing to --team flags
func (t *TeamApps) authOrAppTeamDomain() string {
if t.Auth.TeamDomain != "" && (t.Auth.TeamID == t.Hosted.App.TeamID || t.Auth.TeamID == t.Local.App.TeamID) {
func (apps *TeamApps) authOrAppTeamDomain() string {
Copy link
Member

Choose a reason for hiding this comment

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

Edit: Wow I find the change that follows this in os.go makes sense as a single letter. So much to consider.

@mwbrooks
Copy link
Member Author

Thanks for the review @zimeg! While we don't have to take every linting rule to heart, it definitely helps to keep the code more consistent and readable. For the most part, I think we're already following the short receiver names, so I don't think we'll have trouble keeping with it! 🚀

@mwbrooks mwbrooks merged commit dede31d into main May 13, 2025
6 checks passed
@mwbrooks mwbrooks deleted the mwbrooks-lint-st1016 branch May 13, 2025 17:01
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