Skip to content

Commit 6a3043a

Browse files
bmc-msftBrian Caswell
and
Brian Caswell
authored
check clippy as part of the build (#485)
* check clippy as part of the build * fix path to manifest Co-authored-by: Brian Caswell <[email protected]>
1 parent 6f34487 commit 6a3043a

File tree

11 files changed

+32
-20
lines changed

11 files changed

+32
-20
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@ jobs:
1919
toolchain: stable
2020
profile: minimal
2121
override: true
22-
components: rustfmt
22+
components: rustfmt, clippy
2323

2424
- uses: Swatinem/rust-cache@v1
2525

2626
- name: cargo fmt sdk
2727
run: cargo fmt --all -- --check
2828

29+
- name: cargo clippy sdk
30+
run: cargo clippy --all
31+
2932
- name: cargo fmt services
3033
run: |
3134
./eng/scripts/check_json_format.sh
@@ -80,13 +83,19 @@ jobs:
8083
toolchain: stable
8184
profile: minimal
8285
override: true
83-
components: rustfmt
86+
components: rustfmt, clippy
8487

8588
- uses: Swatinem/rust-cache@v1
8689

8790
- name: services check
8891
run: cargo check --manifest-path services/Cargo.toml --all
8992

93+
- name: services clippy
94+
run: cargo clippy --manifest-path services/Cargo.toml --all
95+
96+
- name: services fmt
97+
run: cargo fmt --manifest-path services/Cargo.toml --all -- --check
98+
9099
- name: display free disk space
91100
run: df -h /
92101
if: ${{ always() }}
@@ -156,15 +165,13 @@ jobs:
156165
toolchain: stable
157166
profile: minimal
158167
override: true
159-
components: rustfmt
168+
components: rustfmt, clippy
160169
- name: fmt check
161-
run: |
162-
cd azure-sdk-for-rust/services/autorust
163-
cargo fmt --all -- --check
170+
run: cargo fmt --all --manifest-path azure-sdk-for-rust/services/autorust/Cargo.toml -- --check
171+
- name: clippy check
172+
run: cargo clippy --all --manifest-path azure-sdk-for-rust/services/autorust/Cargo.toml
164173
- name: unit tests
165-
run: |
166-
cd azure-sdk-for-rust/services/autorust
167-
cargo test --lib
174+
run: cargo test --lib --manifest-path azure-sdk-for-rust/services/autorust/Cargo.toml
168175
- name: git clone Azure/azure-rest-api-specs
169176
uses: actions/checkout@v2
170177
with:

sdk/core/src/policies/retry_policies/exponential_retry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl super::RetryPolicy for ExponentialRetryPolicy {
3131
return true;
3232
}
3333

34-
let first_retry_time = first_retry_time.get_or_insert_with(|| Local::now());
34+
let first_retry_time = first_retry_time.get_or_insert_with(Local::now);
3535
let max_delay = chrono::Duration::from_std(self.max_delay)
3636
.unwrap_or_else(|_| chrono::Duration::max_value());
3737

sdk/cosmos/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#![allow(clippy::enum_variant_names)]
2+
#![allow(clippy::new_without_default)]
3+
#![allow(clippy::module_inception)]
4+
15
/*!
26
# The Cosmos DB crate.
37

sdk/iot_hub/src/service/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,7 @@ impl ServiceClient {
233233
}
234234
}
235235

236-
let iot_hub_name =
237-
iot_hub_name.ok_or_else(|| FromConnectionStringError::FailedToGetHostname)?;
236+
let iot_hub_name = iot_hub_name.ok_or(FromConnectionStringError::FailedToGetHostname)?;
238237

239238
let key_name = key_name.ok_or(FromConnectionStringError::FailedToGetSharedAccessKey)?;
240239

sdk/storage/src/core/shared_access_signature/service_sas.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ impl BlobSharedAccessSignature {
128128
"".to_string(), // rsct
129129
];
130130

131-
let signed = sign(&self.key, &content.join("\n"));
132-
signed
131+
sign(&self.key, &content.join("\n"))
133132
}
134133
}
135134

sdk/storage/src/data_lake/clients/data_lake_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl DataLakeClient {
112112

113113
let per_call_policies = Vec::new();
114114
let auth_policy: Arc<dyn azure_core::Policy<DataLakeContext>> =
115-
Arc::new(AuthorizationPolicy::new(bearer_token.clone()));
115+
Arc::new(AuthorizationPolicy::new(bearer_token));
116116

117117
// take care of adding the AuthorizationPolicy as **last** retry policy.
118118
// Policies can change the url and/or the headers and the AuthorizationPolicy

sdk/storage/src/data_lake/clients/file_system_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl FileSystemClient {
6969
path_name: &str,
7070
options: CreatePathOptions<'_>,
7171
) -> Result<CreatePathResponse, crate::Error> {
72-
let mut request = self.prepare_request_pipeline(&path_name, http::Method::PUT);
72+
let mut request = self.prepare_request_pipeline(path_name, http::Method::PUT);
7373
let contents = DataLakeContext {};
7474
let mut pipeline_context = PipelineContext::new(ctx, contents);
7575

@@ -117,6 +117,6 @@ impl FileSystemClient {
117117
}
118118

119119
pub(crate) fn pipeline(&self) -> &Pipeline<DataLakeContext> {
120-
&self.data_lake_client.pipeline()
120+
self.data_lake_client.pipeline()
121121
}
122122
}

sdk/storage/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Azure storage crate for the unofficial Microsoft Azure SDK for Rust. This crate is part of a collection of crates: for more information please refer to [https://github.com/azure/azure-sdk-for-rust](https://github.com/azure/azure-sdk-for-rust).
22
#![recursion_limit = "256"]
33
#![allow(clippy::needless_lifetimes)]
4+
#![allow(clippy::enum_variant_names)]
5+
#![allow(clippy::new_without_default)]
46

57
#[macro_use]
68
extern crate log;

services/autorust/codegen/src/codegen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl CodeGen {
5454
.into_iter()
5555
.filter(|x| x.starts_with("application/json"))
5656
.map(|x| x.to_string())
57-
.nth(0)
57+
.next()
5858
.unwrap_or_else(|| "application/json".to_string())
5959
}
6060
}

services/autorust/codegen/src/spec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ impl Spec {
9595
}
9696

9797
pub fn consumes(&self) -> Vec<&String> {
98-
let versions: Vec<_> = self
98+
let mut versions: Vec<_> = self
9999
.docs()
100100
.values()
101101
.filter(|doc| !doc.paths().is_empty())
102102
.map(|api| &api.consumes)
103+
.flatten()
103104
.collect();
104105

105-
let mut versions: Vec<_> = versions.into_iter().flatten().collect();
106106
versions.sort_unstable();
107107
versions
108108
}

services/autorust/openapi/src/schema.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub struct Response {
5353
pub x_ms_error_response: Option<bool>,
5454
}
5555

56+
#[allow(clippy::large_enum_variant)]
5657
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
5758
#[serde(untagged)]
5859
pub enum AdditionalProperties {

0 commit comments

Comments
 (0)