diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index fa88481..b19fbd6 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -47,7 +47,7 @@ jobs: - name: Run cargo clippy env: RUSTFLAGS: "" - run: cargo clippy -Z unstable-options --all + run: cargo clippy -Z unstable-options --all -- -D warnings - name: Install cargo-nextest uses: baptiste0928/cargo-install@v1.3.0 diff --git a/service/clippy.toml b/service/clippy.toml new file mode 100644 index 0000000..a8ed9c2 --- /dev/null +++ b/service/clippy.toml @@ -0,0 +1 @@ +too-many-arguments-threshold = 9 \ No newline at end of file diff --git a/service/src/key.rs b/service/src/key.rs index 703b713..526fff9 100644 --- a/service/src/key.rs +++ b/service/src/key.rs @@ -73,7 +73,7 @@ impl Key { pub fn get_id(label: &str, owner_peer_id: &str) -> String { let mut hasher = Sha256::new(); hasher.update(format!("{}{}", label, owner_peer_id).as_bytes()); - bs58::encode(hasher.finalize().to_vec()).into_string() + bs58::encode(hasher.finalize()).into_string() } pub fn signature_bytes(&self) -> Vec { diff --git a/service/src/main.rs b/service/src/main.rs index 0d15bd0..24972db 100644 --- a/service/src/main.rs +++ b/service/src/main.rs @@ -13,7 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#![allow(dead_code)] +#![allow(clippy::result_large_err)] use marine_rs_sdk::marine; use marine_rs_sdk::module_manifest; diff --git a/service/src/record_api.rs b/service/src/record_api.rs index abdd9ca..e2862ca 100644 --- a/service/src/record_api.rs +++ b/service/src/record_api.rs @@ -166,10 +166,12 @@ pub fn republish_records( for (i, record) in records.into_iter().enumerate() { record.verify(current_timestamp_sec)?; check_weight_tetraplets(&call_parameters, 1, i)?; - let weight_result = weights.get(i).ok_or(MissingRecordWeight( - record.metadata.peer_id.clone(), - record.metadata.issued_by.clone(), - ))?; + let weight_result = weights.get(i).ok_or_else(|| { + MissingRecordWeight( + record.metadata.peer_id.clone(), + record.metadata.issued_by.clone(), + ) + })?; check_weight_result(&record.metadata.issued_by, weight_result)?; if record.metadata.key_id != key_id { return Err(ServiceError::RecordsPublishingError); diff --git a/service/src/record_storage_impl.rs b/service/src/record_storage_impl.rs index fa69468..c2c403f 100644 --- a/service/src/record_storage_impl.rs +++ b/service/src/record_storage_impl.rs @@ -136,7 +136,7 @@ impl Storage { record.record.metadata.key_id.clone(), record.record.metadata.issued_by.clone(), record.record.metadata.peer_id.clone(), - record.record.metadata.timestamp_issued.clone(), + record.record.metadata.timestamp_issued, )?; let mut statement = self.connection.prepare(f!( @@ -378,5 +378,5 @@ pub fn merge_records(records: Vec) -> Result } } - Ok(result.into_iter().map(|(_, rec)| rec).collect()) + Ok(result.into_values().collect()) } diff --git a/service/src/tetraplets_checkers.rs b/service/src/tetraplets_checkers.rs index a49c0da..e471a44 100644 --- a/service/src/tetraplets_checkers.rs +++ b/service/src/tetraplets_checkers.rs @@ -37,7 +37,7 @@ pub(crate) fn check_timestamp_tetraplets( (tetraplet.service_id == TRUSTED_TIMESTAMP_SERVICE_ID && tetraplet.function_name == TRUSTED_TIMESTAMP_FUNCTION_NAME && tetraplet.peer_pk == call_parameters.host_id) - .then(|| ()) + .then_some(()) .ok_or_else(|| InvalidTimestampTetraplet(format!("{:?}", tetraplet))) } @@ -56,6 +56,6 @@ pub(crate) fn check_weight_tetraplets( (tetraplet.service_id == TRUSTED_WEIGHT_SERVICE_ID && tetraplet.function_name == TRUSTED_WEIGHT_FUNCTION_NAME && tetraplet.peer_pk == call_parameters.host_id) - .then(|| ()) + .then_some(()) .ok_or_else(|| InvalidWeightTetraplet(format!("{:?}", tetraplet))) }