This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new c4d602abda chore: Make 1.79 clippy happy (#4731)
c4d602abda is described below

commit c4d602abdaae83f24c81c81d89c91dc3142c08c3
Author: Xuanwo <[email protected]>
AuthorDate: Fri Jun 14 14:40:48 2024 +0800

    chore: Make 1.79 clippy happy (#4731)
    
    * chore: Make 1.79 clippy happy
    
    Signed-off-by: Xuanwo <[email protected]>
    
    * Fix clippy
    
    Signed-off-by: Xuanwo <[email protected]>
    
    ---------
    
    Signed-off-by: Xuanwo <[email protected]>
---
 bin/ofs/tests/common/mod.rs            |  2 ++
 core/src/raw/version.rs                | 11 -----------
 core/src/services/aliyun_drive/core.rs | 24 ++----------------------
 core/src/services/b2/core.rs           |  1 -
 core/src/services/chainsafe/core.rs    |  3 ---
 core/src/services/d1/model.rs          | 21 ---------------------
 core/src/services/icloud/core.rs       |  4 ----
 core/src/services/oss/core.rs          | 34 ----------------------------------
 core/src/services/pcloud/core.rs       |  4 ----
 core/src/services/swift/backend.rs     |  5 +----
 core/src/services/yandex_disk/core.rs  |  1 -
 core/tests/behavior/utils.rs           |  1 -
 12 files changed, 5 insertions(+), 106 deletions(-)

diff --git a/bin/ofs/tests/common/mod.rs b/bin/ofs/tests/common/mod.rs
index 394d10622b..6be64c0faa 100644
--- a/bin/ofs/tests/common/mod.rs
+++ b/bin/ofs/tests/common/mod.rs
@@ -32,6 +32,8 @@ static RUNTIME: OnceLock<Runtime> = OnceLock::new();
 
 pub struct OfsTestContext {
     pub mount_point: TempDir,
+    // This is a false positive, the field is used in the test.
+    #[allow(dead_code)]
     pub capability: Capability,
     mount_handle: MountHandle,
 }
diff --git a/core/src/raw/version.rs b/core/src/raw/version.rs
index 05df0d1f0b..d2123fa711 100644
--- a/core/src/raw/version.rs
+++ b/core/src/raw/version.rs
@@ -17,14 +17,3 @@
 
 /// VERSION is the compiled version of OpenDAL.
 pub const VERSION: &str = env!("CARGO_PKG_VERSION");
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-
-    #[test]
-    fn test_version() {
-        println!("opendal version: {VERSION}");
-        assert!(!VERSION.is_empty())
-    }
-}
diff --git a/core/src/services/aliyun_drive/core.rs 
b/core/src/services/aliyun_drive/core.rs
index 1fe56657db..19351d681d 100644
--- a/core/src/services/aliyun_drive/core.rs
+++ b/core/src/services/aliyun_drive/core.rs
@@ -123,7 +123,7 @@ impl AliyunDriveCore {
         let mut tokener = self.signer.lock().await;
         if tokener.expire_at < Utc::now().timestamp() || 
tokener.access_token.is_none() {
             let res = self.get_access_token(&tokener.refresh_token).await?;
-            let output: RefresTokenResponse =
+            let output: RefreshTokenResponse =
                 
serde_json::from_reader(res.reader()).map_err(new_json_deserialize_error)?;
             tokener.access_token = Some(output.access_token);
             tokener.expire_at = output.expires_in + Utc::now().timestamp();
@@ -412,7 +412,7 @@ pub struct RapidUpload {
 }
 
 #[derive(Debug, Deserialize)]
-pub struct RefresTokenResponse {
+pub struct RefreshTokenResponse {
     pub access_token: String,
     pub expires_in: i64,
     pub refresh_token: String,
@@ -420,9 +420,6 @@ pub struct RefresTokenResponse {
 
 #[derive(Debug, Deserialize)]
 pub struct DriveInfoResponse {
-    pub user_id: String,
-    pub name: String,
-    pub avatar: String,
     pub default_drive_id: String,
     pub resource_drive_id: Option<String>,
     pub backup_drive_id: Option<String>,
@@ -444,22 +441,13 @@ pub enum CheckNameMode {
 
 #[derive(Deserialize)]
 pub struct UploadUrlResponse {
-    pub drive_id: String,
-    pub file_id: String,
-    pub upload_id: Option<String>,
     pub part_info_list: Option<Vec<PartInfo>>,
 }
 
 #[derive(Deserialize)]
 pub struct CreateResponse {
-    pub drive_id: String,
     pub file_id: String,
-    pub status: Option<String>,
-    pub parent_file_id: String,
     pub upload_id: Option<String>,
-    pub file_name: String,
-    pub available: Option<bool>,
-    pub exist: Option<bool>,
     pub rapid_upload: Option<bool>,
     pub part_info_list: Option<Vec<PartInfo>>,
 }
@@ -481,32 +469,24 @@ pub struct AliyunDriveFileList {
 
 #[derive(Deserialize)]
 pub struct CopyResponse {
-    pub drive_id: String,
     pub file_id: String,
 }
 
 #[derive(Deserialize)]
 pub struct AliyunDriveFile {
-    pub drive_id: String,
     pub file_id: String,
     pub parent_file_id: String,
     pub name: String,
     pub size: Option<u64>,
-    pub file_extension: Option<String>,
-    pub content_hash: Option<String>,
     pub content_type: Option<String>,
-    pub category: Option<String>,
     #[serde(rename = "type")]
     pub path_type: String,
-    pub created_at: String,
     pub updated_at: String,
 }
 
 #[derive(Deserialize)]
 pub struct GetDownloadUrlResponse {
     pub url: String,
-    pub expiration: String,
-    pub method: String,
 }
 
 #[derive(Serialize)]
diff --git a/core/src/services/b2/core.rs b/core/src/services/b2/core.rs
index 6aea7a6092..227a69e6d5 100644
--- a/core/src/services/b2/core.rs
+++ b/core/src/services/b2/core.rs
@@ -629,7 +629,6 @@ pub struct File {
     pub content_md5: Option<String>,
     pub content_type: Option<String>,
     pub file_name: String,
-    pub action: String,
 }
 
 pub(super) fn parse_file_info(file: &File) -> Metadata {
diff --git a/core/src/services/chainsafe/core.rs 
b/core/src/services/chainsafe/core.rs
index d4e4db179c..c65617abd7 100644
--- a/core/src/services/chainsafe/core.rs
+++ b/core/src/services/chainsafe/core.rs
@@ -247,11 +247,8 @@ impl ChainsafeCore {
 #[derive(Debug, Deserialize)]
 pub struct Info {
     pub name: String,
-    pub cid: String,
     pub content_type: String,
     pub size: u64,
-    pub version: i64,
-    pub created_at: i64,
 }
 
 #[derive(Deserialize)]
diff --git a/core/src/services/d1/model.rs b/core/src/services/d1/model.rs
index b4b0f25c8d..d6bc7d8a81 100644
--- a/core/src/services/d1/model.rs
+++ b/core/src/services/d1/model.rs
@@ -32,7 +32,6 @@ pub struct D1Response {
     pub result: Vec<D1Result>,
     pub success: bool,
     pub errors: Vec<D1Error>,
-    pub messages: Vec<D1Message>,
 }
 
 impl D1Response {
@@ -77,21 +76,7 @@ impl D1Response {
 
 #[derive(Deserialize, Debug)]
 pub struct D1Result {
-    pub meta: Meta,
     pub results: Vec<Map<String, Value>>,
-    pub success: bool,
-}
-
-#[derive(Deserialize, Debug)]
-pub struct Meta {
-    pub served_by: String,
-    pub duration: f64,
-    pub changes: i32,
-    pub last_row_id: i32,
-    pub changed_db: bool,
-    pub size_after: i32,
-    pub rows_read: i32,
-    pub rows_written: i32,
 }
 
 #[derive(Clone, Deserialize, Debug, Serialize)]
@@ -100,12 +85,6 @@ pub struct D1Error {
     pub code: i32,
 }
 
-#[derive(Deserialize, Debug)]
-pub struct D1Message {
-    pub message: String,
-    pub code: i32,
-}
-
 #[cfg(test)]
 mod test {
     use super::*;
diff --git a/core/src/services/icloud/core.rs b/core/src/services/icloud/core.rs
index 5c4e44848f..fa90e653ae 100644
--- a/core/src/services/icloud/core.rs
+++ b/core/src/services/icloud/core.rs
@@ -623,16 +623,12 @@ pub struct Webservices {
 #[derive(Deserialize, Default, Clone, Debug)]
 #[serde(rename_all = "camelCase")]
 pub struct Drivews {
-    pub pcs_required: bool,
-    pub status: String,
     pub url: Option<String>,
 }
 
 #[derive(Deserialize, Default, Clone, Debug)]
 #[serde(rename_all = "camelCase")]
 pub struct Docws {
-    pub pcs_required: bool,
-    pub status: String,
     pub url: Option<String>,
 }
 
diff --git a/core/src/services/oss/core.rs b/core/src/services/oss/core.rs
index 229ef050d0..04b91ad74d 100644
--- a/core/src/services/oss/core.rs
+++ b/core/src/services/oss/core.rs
@@ -649,16 +649,6 @@ pub struct CompleteMultipartUploadRequest {
     pub part: Vec<MultipartUploadPart>,
 }
 
-#[derive(Default, Debug, Deserialize)]
-#[serde(rename_all = "PascalCase")]
-pub struct CompleteMultipartUploadResult {
-    pub location: String,
-    pub bucket: String,
-    pub key: String,
-    #[serde(rename = "ETag")]
-    pub etag: String,
-}
-
 #[derive(Default, Debug, Deserialize)]
 #[serde(default, rename_all = "PascalCase")]
 pub struct ListObjectsOutput {
@@ -822,30 +812,6 @@ mod tests {
         )
     }
 
-    #[test]
-    fn test_deserialize_complete_oss_multipart_result() {
-        let bytes = Bytes::from(
-            r#"<?xml version="1.0" encoding="UTF-8"?>
-<CompleteMultipartUploadResult xmlns="http://doc.oss-cn-hangzhou.aliyuncs.com";>
-    <EncodingType>url</EncodingType>
-    <Location>http://oss-example.oss-cn-hangzhou.aliyuncs.com 
/multipart.data</Location>
-    <Bucket>oss-example</Bucket>
-    <Key>multipart.data</Key>
-    <ETag>"B864DB6A936D376F9F8D3ED3BBE540****"</ETag>
-</CompleteMultipartUploadResult>"#,
-        );
-
-        let result: CompleteMultipartUploadResult =
-            quick_xml::de::from_reader(bytes.reader()).unwrap();
-        assert_eq!("\"B864DB6A936D376F9F8D3ED3BBE540****\"", result.etag);
-        assert_eq!(
-            "http://oss-example.oss-cn-hangzhou.aliyuncs.com /multipart.data",
-            result.location
-        );
-        assert_eq!("oss-example", result.bucket);
-        assert_eq!("multipart.data", result.key);
-    }
-
     #[test]
     fn test_parse_list_output() {
         let bs = bytes::Bytes::from(
diff --git a/core/src/services/pcloud/core.rs b/core/src/services/pcloud/core.rs
index 91c32b09ea..0843626acd 100644
--- a/core/src/services/pcloud/core.rs
+++ b/core/src/services/pcloud/core.rs
@@ -413,11 +413,9 @@ pub struct StatResponse {
 
 #[derive(Debug, Deserialize)]
 pub struct StatMetadata {
-    pub name: String,
     pub modified: String,
     pub isfolder: bool,
     pub size: Option<u64>,
-    pub contenttype: Option<String>,
 }
 
 #[derive(Debug, Deserialize)]
@@ -428,11 +426,9 @@ pub struct ListFolderResponse {
 
 #[derive(Debug, Deserialize)]
 pub struct ListMetadata {
-    pub name: String,
     pub path: String,
     pub modified: String,
     pub isfolder: bool,
     pub size: Option<u64>,
-    pub contenttype: Option<String>,
     pub contents: Option<Vec<ListMetadata>>,
 }
diff --git a/core/src/services/swift/backend.rs 
b/core/src/services/swift/backend.rs
index f5e9d51b66..d784f305fa 100644
--- a/core/src/services/swift/backend.rs
+++ b/core/src/services/swift/backend.rs
@@ -162,10 +162,7 @@ impl Builder for SwiftBuilder {
         };
         debug!("backend use container: {}", &container);
 
-        let token = match self.token.take() {
-            Some(token) => token,
-            None => String::new(),
-        };
+        let token = self.token.take().unwrap_or_default();
 
         let client = HttpClient::new()?;
 
diff --git a/core/src/services/yandex_disk/core.rs 
b/core/src/services/yandex_disk/core.rs
index fb7b47058f..76ad3f9f25 100644
--- a/core/src/services/yandex_disk/core.rs
+++ b/core/src/services/yandex_disk/core.rs
@@ -289,7 +289,6 @@ pub struct GetUploadUrlResponse {
 pub struct MetainformationResponse {
     #[serde(rename = "type")]
     pub ty: String,
-    pub name: String,
     pub path: String,
     pub modified: String,
     pub md5: Option<String>,
diff --git a/core/tests/behavior/utils.rs b/core/tests/behavior/utils.rs
index f877ae612a..17124e2406 100644
--- a/core/tests/behavior/utils.rs
+++ b/core/tests/behavior/utils.rs
@@ -17,7 +17,6 @@
 
 use std::mem;
 use std::sync::Mutex;
-use std::usize;
 
 use futures::Future;
 use libtest_mimic::Failed;

Reply via email to