### Redundant/Unnecessary return keyword in castVote public function in GovernorAlpha.sol contract
POC:
Internal _castVote function: Doesn't return anything - void
`function _castVote(address voter, uint proposalId, bool support) internal {
require(state(proposalId) == ProposalState.Active, "GovernorAlpha::_castVote: voting is closed");
Proposal storage proposal = proposals[proposalId];
Receipt storage receipt = proposal.receipts[voter];
require(receipt.hasVoted == false, "GovernorAlpha::_castVote: voter already voted");
uint96 votes = comp.getPriorVotes(voter, proposal.startBlock);
if (support) {
proposal.forVotes = add256(proposal.forVotes, votes);
} else {
proposal.againstVotes = add256(proposal.againstVotes, votes);
}
receipt.hasVoted = true;
receipt.support = support;
receipt.votes = votes;
emit VoteCast(voter, proposalId, support, votes);
}`
Public castVote function: also doesn't return anything void but the implementation here has a return keyword
function castVote(uint proposalId, bool support) public { return _castVote(msg.sender, proposalId, support); }
Recommendation
- remove redundant
return keyword
### Redundant/Unnecessary
returnkeyword incastVotepublic function inGovernorAlpha.solcontractPOC:
Internal
_castVotefunction: Doesn't return anything -void`function _castVote(address voter, uint proposalId, bool support) internal {
require(state(proposalId) == ProposalState.Active, "GovernorAlpha::_castVote: voting is closed");
Proposal storage proposal = proposals[proposalId];
Receipt storage receipt = proposal.receipts[voter];
require(receipt.hasVoted == false, "GovernorAlpha::_castVote: voter already voted");
uint96 votes = comp.getPriorVotes(voter, proposal.startBlock);
Public
castVotefunction: also doesn't return anythingvoidbut the implementation here has areturnkeywordfunction castVote(uint proposalId, bool support) public { return _castVote(msg.sender, proposalId, support); }Recommendation
returnkeyword