Skip to content
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

Improve or Remove Redundant Comments #494

Open
EmilGeorgiev opened this issue May 19, 2024 · 0 comments
Open

Improve or Remove Redundant Comments #494

EmilGeorgiev opened this issue May 19, 2024 · 0 comments

Comments

@EmilGeorgiev
Copy link

The project is very well-documented. The structs, struct fields, methods, functions, and constants are documented thoroughly, which is crucial for the project's maintainability.

However, there are comments that don't add any additional value to the code. These comments should either be removed or improved to provide meaningful information that isn't immediately obvious. For example:

// remove the tx
if err := m.mempl.Remove(tx); err != nil {
   ...
}   

or

// decode tx
tx, err := m.txDecoder(req.Tx) {
   ...
}

In both examples, the comments are stating what the code is already clearly doing. Removing these comments would make the code cleaner. Alternatively, if there is additional context that is not immediately obvious, such as why a transaction is being removed or decoded at this point, that information should be included in the comment.

For example:

// Decode the transaction from the request.
// This step is crucial to validate and process the transaction correctly.
tx, err := m.txDecoder(req.Tx) {
   ...
}
// Attempt to remove the transaction from the mempool.
// This is necessary to ensure that invalid transactions are purged and do not get processed further.
if err := m.mempl.Remove(tx); err != nil {
  ...
}

By focusing comments on providing meaningful context rather than stating the obvious, we can help future developers understand the code better and reduce the risk of misinterpretation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant