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

Explore clippy rules and apply quality of life recommendations #122

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
b7e300f
Set clippy rules in root
xla Jan 3, 2020
f4bc257
Remove Error prefix in kind enum
xla Jan 3, 2020
04fec06
Merge branch 'master' into xla/clippy
xla Jan 3, 2020
4d82f36
Remove superfluours Info suffix
xla Jan 3, 2020
ae598b7
Remove superfluours Params suffix
xla Jan 3, 2020
f1f4f9f
Remove superfluours Config suffix
xla Jan 3, 2020
6f423a7
Remove superfluours Id suffix
xla Jan 3, 2020
e2220a1
Remove superfluours Version suffix
xla Jan 3, 2020
2810c89
Remove superfluous BlockId suffix
xla Jan 3, 2020
faf0fe6
Remove superfluous Amino prefix
xla Jan 3, 2020
827285e
Remove superfluous Ping prefix
xla Jan 3, 2020
17c7996
Remove superfluous RemoteError prefix
xla Jan 3, 2020
2d7607d
Remove superfluous RemoteError prefix
xla Jan 3, 2020
5ddb642
Lock down amino module surface
xla Jan 3, 2020
7e3b87f
Remove superfluous Time prefix
xla Jan 3, 2020
d3dc4b9
Remove superfluous Vote suffix
xla Jan 3, 2020
61dce99
Remove superfluous Vote suffix
xla Jan 3, 2020
a0c842f
Use markdown emphasize & link for types
xla Jan 3, 2020
bad770b
Use _ for literal suffix
xla Jan 3, 2020
63c673c
Make clippy rule exception for db names
xla Jan 3, 2020
56d1f48
Remove print statements
xla Jan 3, 2020
7bf1093
Replace similiar names
xla Jan 3, 2020
a01d234
Allow multiple crate versions
xla Jan 3, 2020
41cbd02
Consolidate impl blocks
xla Jan 4, 2020
67f7358
Use Self consistently
xla Jan 4, 2020
0ee13e2
Mark functions as const where possible
xla Jan 5, 2020
37078c4
Unify matches with equal arm bodies
xla Jan 5, 2020
834263c
Remove unecessary closures
xla Jan 5, 2020
9b9e875
Remove possible truncation
xla Jan 5, 2020
85100a3
Remove possible truncation
xla Jan 5, 2020
71f0cd3
Allow fallible from impls for now and leave todos
xla Jan 5, 2020
d3651c4
Replace enum glob use with proper qualified variants
xla Jan 5, 2020
da3a7c9
Allow integer arithmetic
xla Jan 5, 2020
749c679
Use proper division methoods on ints
xla Jan 5, 2020
c4d4c56
Allow index slicing
xla Jan 5, 2020
21b2a8f
Allow index slicing
xla Jan 5, 2020
15e37ca
Alllow default_trait_access mostly for defive
xla Jan 5, 2020
1144a4f
Allow sign loss for cast
xla Jan 7, 2020
d7ef18a
Address wildcard enum matches
xla Jan 7, 2020
85e57aa
Avoid warning for inline attribute
xla Jan 7, 2020
d53540f
Ignore must use lint as it is only a recommendation
xla Jan 7, 2020
ab338d7
Address missing docs
xla Jan 7, 2020
8534547
Remove superfluous unwrap_or_else
xla Jan 7, 2020
bd9b608
Address unwrap used on Options
xla Jan 7, 2020
5cfcb37
Replace result unwrap with expect
xla Jan 18, 2020
255ba11
Rework use of unreachable
xla Jan 18, 2020
3dbd0d8
Remove use of panic
xla Jan 18, 2020
dd405fa
Remove bare panics
xla Jan 20, 2020
e90bc89
Remove needles pass by value
xla Jan 20, 2020
2b9b699
Replace explicit iter calls
xla Jan 20, 2020
99e323c
Remove needless borrows
xla Jan 20, 2020
7750986
Address cast possible wrap
xla Jan 20, 2020
ab1e77a
Merge branch 'master' into xla/clippy
xla Jan 20, 2020
dfb094a
Add documentation for unit enum
xla Jan 20, 2020
3ebb516
Add cargo fields to lite crate
xla Jan 20, 2020
357a791
Address lite merge follow-ups
xla Jan 20, 2020
b2b5db7
Address missing docs
xla Jan 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove superfluous Vote suffix
  • Loading branch information
xla committed Jan 3, 2020
commit d3dc4b9a642ea219a31732d465cd07ff5ff827a1
3 changes: 2 additions & 1 deletion tendermint/src/amino_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub use self::{
validate::ConsensusMessage,
version::Consensus as ConsensusVersion,
vote::{
CanonicalVote, SignVoteRequest, SignedVoteResponse, Vote, AMINO_NAME as VOTE_AMINO_NAME,
Canonical as CanonicalVote, SignVoteRequest, SignedVoteResponse, Vote,
AMINO_NAME as VOTE_AMINO_NAME,
},
};
24 changes: 12 additions & 12 deletions tendermint/src/amino_types/vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub struct SignedVoteResponse {
}

#[derive(Clone, PartialEq, Message)]
pub struct CanonicalVote {
pub struct Canonical {
#[prost(uint32, tag = "1")]
pub vote_type: u32,
#[prost(sfixed64)]
Expand All @@ -108,21 +108,21 @@ pub struct CanonicalVote {
pub chain_id: String,
}

impl chain::ParseId for CanonicalVote {
impl chain::ParseId for Canonical {
fn parse_chain_id(&self) -> Result<chain::Id, Error> {
self.chain_id.parse()
}
}

impl block::ParseHeight for CanonicalVote {
impl block::ParseHeight for Canonical {
fn parse_block_height(&self) -> Result<block::Height, Error> {
block::Height::try_from(self.height)
}
}

impl CanonicalVote {
pub fn new(vote: Vote, chain_id: &str) -> CanonicalVote {
CanonicalVote {
impl Canonical {
pub fn new(vote: Vote, chain_id: &str) -> Canonical {
Canonical {
vote_type: vote.vote_type,
chain_id: chain_id.to_string(),
block_id: match vote.block_id {
Expand Down Expand Up @@ -161,7 +161,7 @@ impl SignableMsg for SignVoteRequest {
vo.signature = vec![];
}
let vote = svr.vote.unwrap();
let cv = CanonicalVote::new(vote, chain_id.as_str());
let cv = Canonical::new(vote, chain_id.as_str());

cv.encode_length_delimited(sign_bytes)?;

Expand Down Expand Up @@ -312,7 +312,7 @@ mod tests {

#[test]
fn test_sign_bytes_compatibility() {
let cv = CanonicalVote::new(Vote::default(), "");
let cv = Canonical::new(Vote::default(), "");
let mut got = vec![];
// SignBytes are encoded using MarshalBinary and not MarshalBinaryBare
cv.encode_length_delimited(&mut got).unwrap();
Expand All @@ -328,7 +328,7 @@ mod tests {
vt_precommit.round = 1;
vt_precommit.vote_type = SignedMsgType::PreCommit.to_u32(); // precommit
println!("{:?}", vt_precommit);
let cv_precommit = CanonicalVote::new(vt_precommit, "");
let cv_precommit = Canonical::new(vt_precommit, "");
let got = AminoMessage::bytes_vec(&cv_precommit);
let want = vec![
0x8, // (field_number << 3) | wire_type
Expand All @@ -350,7 +350,7 @@ mod tests {
vt_prevote.round = 1;
vt_prevote.vote_type = SignedMsgType::PreVote.to_u32();

let cv_prevote = CanonicalVote::new(vt_prevote, "");
let cv_prevote = Canonical::new(vt_prevote, "");

let got = AminoMessage::bytes_vec(&cv_prevote);

Expand All @@ -373,7 +373,7 @@ mod tests {
vt_no_type.height = 1;
vt_no_type.round = 1;

let cv = CanonicalVote::new(vt_no_type, "");
let cv = Canonical::new(vt_no_type, "");
let got = AminoMessage::bytes_vec(&cv);

let want = vec![
Expand All @@ -392,7 +392,7 @@ mod tests {
no_vote_type2.height = 1;
no_vote_type2.round = 1;

let with_chain_id = CanonicalVote::new(no_vote_type2, "test_chain_id");
let with_chain_id = Canonical::new(no_vote_type2, "test_chain_id");
got = AminoMessage::bytes_vec(&with_chain_id);
let want = vec![
0x11, // (field_number << 3) | wire_type
Expand Down