mattermost / mattermost

Mattermost is an open source platform for secure collaboration across the entire software development lifecycle..
https://mattermost.com
Other
30.73k stars 7.38k forks source link

Fix errcheck issues in server/channels/api4/channel.go #28352

Closed hanzei closed 1 month ago

hanzei commented 1 month ago

At Mattermost, we are committed to maintaining a high standard of code quality, reliability, and security. To further enhance this, we are launching a community campaign to integrate the errcheck linter across the Mattermost codebase.

This Help Wanted ticket is about fixing the linter issues reported by errcheck in channels/api4/channel.go.

What is errcheck?

errcheck is a tool that automatically identifies places in Go code where errors are returned but not checked. In Go, error handling is a critical part of writing robust applications, and ignoring returned errors can lead to bugs, crashes, or unintended behaviour. By integrating errcheck into the codebase, we can ensure that error handling is consistently and properly managed across the project.

Tasks

Okay, but what does "properly handling" mean?

In general, errors should be returned to the caller. Non critical errors should be loggged and function execution should continue. There are some exceptions to this rule, such as when the error is expected and should be ignored or when the error is handled in a different way. In such cases, a comment should be added to explain why the error is ignored.

In tests, errors should be checked using require.NoError(t, err) for errors of type error or require.Nil(t, err) for errors of type **model.AppError. If an error is expected, it should be checked using require.Error(t, err) for errors of type error or require.NotNil(t, err) for errors of type **model.AppError.

Use err as the variable name for errors and appErr for *model.AppError. Avoid using variable names like err1, err2, etc. See [the Mattermost style guide>(https://developers.mattermost.com/contribute/more-info/server/style-guide/#error-variable-names) for more information.

If you're interested, please comment here and come join our "Contributors" community channel on the Mattermost Community server, where you can discuss questions with community members and the Mattermost core team. For technical advice or questions, please join our "Developers Server" community channel. You can also reach out to @hanzei either on this ticket or on the Mattermost Community server.

For new contributors, please see our Developer's Guide.

JIRA: MM-60709

pradeepmurugesan commented 1 month ago

Hi.. Can you assign this to me ? Can give it a shot.

hanzei commented 1 month ago

Sure! Thanks for working on the issue @pradeepmurugesan :+1:

Great to see you again :wink:

pradeepmurugesan commented 1 month ago

Great to see you again 😉

Thanks.. Looking forward to make some contributions.. 🤞