fix(dpp)!: wrapping overflow issue (#2430) #5058
Annotations
10 warnings and 1 notice
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs#L153
warning: the following explicit lifetimes could be elided: 'a
--> packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs:153:6
|
153 | impl<'a> DocumentTypeV0Getters for DocumentTypeRef<'a> {
| ^^ ^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
= note: `#[warn(clippy::needless_lifetimes)]` on by default
help: elide the lifetimes
|
153 - impl<'a> DocumentTypeV0Getters for DocumentTypeRef<'a> {
153 + impl DocumentTypeV0Getters for DocumentTypeRef<'_> {
|
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs#L287
warning: the following explicit lifetimes could be elided: 'a
--> packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs:287:6
|
287 | impl<'a> DocumentTypeV0Getters for DocumentTypeMutRef<'a> {
| ^^ ^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
help: elide the lifetimes
|
287 - impl<'a> DocumentTypeV0Getters for DocumentTypeMutRef<'a> {
287 + impl DocumentTypeV0Getters for DocumentTypeMutRef<'_> {
|
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/data_contract/document_type/property/array.rs#L73
warning: unneeded `return` statement
--> packages/rs-dpp/src/data_contract/document_type/property/array.rs:73:9
|
73 | / return match self {
74 | | ArrayItemType::String(_, _) => {
75 | | let value_as_text = value.as_text().ok_or_else(get_field_type_matching_error)?;
76 | | let vec = value_as_text.as_bytes().to_vec();
... |
118 | | }
119 | | };
| |_________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
= note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
|
73 ~ match self {
74 + ArrayItemType::String(_, _) => {
75 + let value_as_text = value.as_text().ok_or_else(get_field_type_matching_error)?;
76 + let vec = value_as_text.as_bytes().to_vec();
77 + let mut r_vec = vec.len().encode_var_vec();
78 + r_vec.extend(vec);
79 + Ok(r_vec)
80 + }
81 + ArrayItemType::Date => {
82 + let value_as_f64 = value.to_float().map_err(ProtocolError::ValueError)?;
83 + let value_bytes = value_as_f64.to_be_bytes().to_vec();
84 + Ok(value_bytes)
85 + }
86 + ArrayItemType::Integer => {
87 + let value_as_i64: i64 = value.to_integer().map_err(ProtocolError::ValueError)?;
88 + let value_bytes = value_as_i64.to_be_bytes().to_vec();
89 + Ok(value_bytes)
90 + }
91 + ArrayItemType::Number => {
92 + let value_as_f64 = value.to_float().map_err(ProtocolError::ValueError)?;
93 + let value_bytes = value_as_f64.to_be_bytes().to_vec();
94 + Ok(value_bytes)
95 + }
96 + ArrayItemType::ByteArray(_, _) => {
97 + let mut bytes = value.to_binary_bytes()?;
98 +
99 + let mut r_vec = bytes.len().encode_var_vec();
100 + r_vec.append(&mut bytes);
101 + Ok(r_vec)
102 + }
103 + ArrayItemType::Identifier => {
104 + let mut bytes = value.to_identifier_bytes()?;
105 +
106 + let mut r_vec = bytes.len().encode_var_vec();
107 + r_vec.append(&mut bytes);
108 + Ok(r_vec)
109 + }
110 + ArrayItemType::Boolean => {
111 + let value_as_boolean = value.as_bool().ok_or_else(get_field_type_matching_error)?;
112 + // 0 means does not exist
113 + if value_as_boolean {
114 + Ok(vec![1]) // 1 is true
115 + } else {
116 + Ok(vec![0]) // 2 is false
117 + }
118 + }
119 ~ }
|
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/data_contract/document_type/property/mod.rs#L986
warning: unneeded `return` statement
--> packages/rs-dpp/src/data_contract/document_type/property/mod.rs:986:9
|
986 | / return match self {
987 | | DocumentPropertyType::String(_) => {
988 | | let value_as_text = value
989 | | .as_text()
... |
1128 | | )),
1129 | | };
| |_________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
|
986 ~ match self {
987 + DocumentPropertyType::String(_) => {
988 + let value_as_text = value
989 + .as_text()
990 + .ok_or_else(|| get_field_type_matching_error(value))?;
991 + let vec = value_as_text.as_bytes().to_vec();
992 + let mut r_vec = vec.len().encode_var_vec();
993 + r_vec.extend(vec);
994 + Ok(r_vec)
995 + }
996 + // TODO: Make the same as in https://github.com/dashpay/platform/blob/8d2a9e54d62b77581c44a15a09a2c61864af37d3/packages/rs-dpp/src/document/v0/serialize.rs#L161
997 + // it must be u64 BE. Markers are wrong here as well
998 + DocumentPropertyType::Date => {
999 + let value_as_f64 = value.to_float().map_err(ProtocolError::ValueError)?;
1000 + let mut value_bytes = value_as_f64.to_be_bytes().to_vec();
1001 + if required {
1002 + Ok(value_bytes)
1003 + } else {
1004 + // if the value wasn't required we need to add a byte to prove it existed
1005 + let mut r_vec = vec![255u8];
1006 + r_vec.append(&mut value_bytes);
1007 + Ok(r_vec)
1008 + }
1009 + }
1010 + DocumentPropertyType::U128 => {
1011 + let value_as_u128: u128 = value.to_integer().map_err(ProtocolError::ValueError)?;
1012 + Ok(value_as_u128.to_be_bytes().to_vec())
1013 + }
1014 + DocumentPropertyType::I128 => {
1015 + let value_as_i128: i128 = value.to_integer().map_err(ProtocolError::ValueError)?;
1016 + Ok(value_as_i128.to_be_bytes().to_vec())
1017 + }
1018 + DocumentPropertyType::U64 => {
1019 + let value_as_u64: u64 = value.to_integer().map_err(ProtocolError::ValueError)?;
1020 + Ok(value_as_u64.to_be_bytes().to_vec())
1021 + }
1022 + DocumentPropertyType::I64 => {
1023 + let value_as_i64: i64 = value.to_integer().map_err(ProtocolError::ValueError)?;
1024 + Ok(value_as_i64.to_be_bytes().to_vec())
1025 + }
1026 + DocumentPropertyType::U32 => {
1027 + let value_as_u32: u32 = value.to_integer().map_err(ProtocolError::ValueError)?;
1028 + Ok(value_as_u32.to_be_bytes().to_vec())
1029 + }
1030 + DocumentPropertyType::I32 => {
1031 + let value_as_i32: i32 = value.to_integer().map_err(ProtocolError::ValueError)?;
1032 + Ok(value_as_i32.to_be_bytes().to_vec())
1033 + }
1034 + DocumentPropertyType::U16 => {
1035 + let value_as_u16: u16 = value.to_integer().map_err(ProtocolError::ValueError)?;
1036 + Ok(value_as_u16.to_be_bytes().to_vec())
1037 + }
1038 + DocumentPropertyType::I16 => {
1039 + let value_as_i16: i16 = value.to_integer().map_err(ProtocolError::ValueError)?;
1040 + Ok(value_as_i16.to_be_bytes().to_vec())
1041 + }
1042 + DocumentPropertyType::U8 => {
1043 + let value_as_u8: u8 = value.to_integer().map_err(ProtocolError::ValueError)?;
1044 + Ok(value_as_u8.to_be_bytes().to_vec())
1045 + }
1046 + DocumentPropertyType::I8 => {
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/data_contract/document_type/property/mod.rs#L1234
warning: taken reference of right operand
--> packages/rs-dpp/src/data_contract/document_type/property/mod.rs:1234:20
|
1234 | if value == &vec![0] {
| ^^^^^^^^^--------
| |
| help: use the right value directly: `...`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#op_ref
= note: `#[warn(clippy::op_ref)]` on by default
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/data_contract/document_type/property/mod.rs#L1325
warning: taken reference of right operand
--> packages/rs-dpp/src/data_contract/document_type/property/mod.rs:1325:20
|
1325 | if value == &vec![0] {
| ^^^^^^^^^--------
| |
| help: use the right value directly: `...`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#op_ref
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/data_contract/document_type/property/mod.rs#L1327
warning: taken reference of right operand
--> packages/rs-dpp/src/data_contract/document_type/property/mod.rs:1327:27
|
1327 | } else if value == &vec![1] {
| ^^^^^^^^^--------
| |
| help: use the right value directly: `...`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#op_ref
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/data_contract/document_type/index/mod.rs#L99
warning: the following explicit lifetimes could be elided: 'de
--> packages/rs-dpp/src/data_contract/document_type/index/mod.rs:99:14
|
99 | impl<'de> Visitor<'de> for FieldVisitor {
| ^^^ ^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
help: elide the lifetimes
|
99 - impl<'de> Visitor<'de> for FieldVisitor {
99 + impl Visitor<'_> for FieldVisitor {
|
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/data_contract/document_type/index/mod.rs#L157
warning: non-canonical implementation of `partial_cmp` on an `Ord` type
--> packages/rs-dpp/src/data_contract/document_type/index/mod.rs:157:1
|
157 | / impl PartialOrd for ContestedIndexFieldMatch {
158 | | fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
| | _____________________________________________________________-
159 | || use ContestedIndexFieldMatch::*;
160 | || match (self, other) {
161 | || // Comparing two integers
... ||
170 | || }
171 | || }
| ||_____- help: change this to: `{ Some(self.cmp(other)) }`
172 | | }
| |__^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#non_canonical_partial_ord_impl
= note: `#[warn(clippy::non_canonical_partial_ord_impl)]` on by default
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/data_contract/document_type/index/mod.rs#L503
warning: `to_string` applied to a type that implements `Display` in `format!` args
--> packages/rs-dpp/src/data_contract/document_type/index/mod.rs:503:66
|
503 | ... e.to_string()
| ^^^^^^^^^^^^ help: remove this
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#to_string_in_format_args
= note: `#[warn(clippy::to_string_in_format_args)]` on by default
|
Post Setup sccache
100% - 196 hits, 0 misses, 0 errors
|
Loading