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/emoji.go #28381

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/emoji.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 for more information.

https://github.com/mattermost/mattermost/pull/28364 and https://github.com/mattermost/mattermost/pull/28376 can be used as examples of how to fix errcheck issues in the api4 package.

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-60748

RS-labhub commented 1 month ago

I want to work on this one! May I??

hanzei commented 1 month ago

Surely @RS-labhub. Thanks!

Please let me know if you have any questions.