Skip to content

Commit d254e72

Browse files
authored
Fix clippy lints and run clippy in CI (#29)
1 parent b1a954e commit d254e72

File tree

6 files changed

+34
-21
lines changed

6 files changed

+34
-21
lines changed

.github/workflows/rust.yml

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ jobs:
1414
- name: Check style
1515
run: cargo fmt -- --check
1616

17+
clippy-lint:
18+
runs-on: ubuntu-18.04
19+
steps:
20+
# actions/checkout@v2
21+
- uses: actions/checkout@28c7f3d2b5162b5ddd3dfd9a45aa55eaf396478b
22+
- name: Run Clippy Lints
23+
run: cargo clippy -- -D warnings
24+
1725
build-and-test:
1826
runs-on: ${{ matrix.os }}
1927
strategy:

README.adoc

+4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ suite runs cleanly and should remain clean.
5959
You can **format the code** using `cargo fmt`. Make sure to run this before
6060
pushing changes. The CI checks that the code is correctly formatted.
6161

62+
The https://github.com/rust-lang/rust-clippy[Clippy Linter] is used to help
63+
keep the codebase efficient and idiomatic, and can be executed with
64+
`cargo clippy`.
65+
6266
To **run the system:** there are two executables: the `oxide_controller` (which
6367
is a real prototype backed by an in-memory store; this component manages an
6468
Oxide fleet), and the `sled_agent` (which is a simulation of the component that

api_identity/src/lib.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,9 @@ fn do_api_identity(item: TokenStream) -> Result<TokenStream, syn::Error> {
2828
let name = &ast.ident;
2929

3030
if !match ast.fields {
31-
Fields::Named(ref fields) => {
32-
fields.named.iter().any(|field| match &field.ident {
33-
Some(ident) if ident.to_string() == "identity" => true,
34-
_ => false,
35-
})
36-
}
31+
Fields::Named(ref fields) => fields.named.iter().any(
32+
|field| matches!(&field.ident, Some(ident) if *ident == "identity"),
33+
),
3734
_ => false,
3835
} {
3936
return Err(syn::Error::new_spanned(

src/datastore.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -628,9 +628,9 @@ impl ControlDataStore {
628628
* TODO-cleanup this is only public because we haven't built Servers into the
629629
* datastore yet so the controller needs this interface.
630630
*/
631-
pub fn collection_page<'a, 'b, KeyType, ValueType>(
632-
search_tree: &'a BTreeMap<KeyType, Arc<ValueType>>,
633-
pagparams: &'b DataPageParams<'_, KeyType>,
631+
pub fn collection_page<KeyType, ValueType>(
632+
search_tree: &BTreeMap<KeyType, Arc<ValueType>>,
633+
pagparams: &DataPageParams<'_, KeyType>,
634634
) -> ListResult<ValueType>
635635
where
636636
KeyType: std::cmp::Ord,

src/http_pagination.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ where
156156
{
157157
ApiPageSelector {
158158
scan: scan_params.clone(),
159-
last_seen: scan_params.marker_for_item(item).clone(),
159+
last_seen: scan_params.marker_for_item(item),
160160
}
161161
}
162162

@@ -184,10 +184,10 @@ where
184184
* test the bulk of the logic without needing to cons up a Dropshot
185185
* `RequestContext` just to get the limit.
186186
*/
187-
fn data_page_params_with_limit<'a, S>(
187+
fn data_page_params_with_limit<S>(
188188
limit: NonZeroUsize,
189-
pag_params: &'a PaginationParams<S, ApiPageSelector<S, S::MarkerValue>>,
190-
) -> Result<DataPageParams<'a, S::MarkerValue>, HttpError>
189+
pag_params: &PaginationParams<S, ApiPageSelector<S, S::MarkerValue>>,
190+
) -> Result<DataPageParams<S::MarkerValue>, HttpError>
191191
where
192192
S: ScanParams,
193193
{
@@ -287,7 +287,7 @@ impl ScanParams for ApiScanById {
287287
PaginationOrder::Ascending
288288
}
289289
fn marker_for_item<T: ApiObjectIdentity>(&self, item: &T) -> Uuid {
290-
item.identity().id.clone()
290+
item.identity().id
291291
}
292292
fn from_query(p: &ApiPaginatedById) -> Result<&Self, HttpError> {
293293
Ok(match p.page {
@@ -384,7 +384,7 @@ impl ScanParams for ApiScanByNameOrId {
384384
let identity = item.identity();
385385
match pagination_field_for_scan_params(self) {
386386
ApiPagField::Name => ApiNameOrIdMarker::Name(identity.name.clone()),
387-
ApiPagField::Id => ApiNameOrIdMarker::Id(identity.id.clone()),
387+
ApiPagField::Id => ApiNameOrIdMarker::Id(identity.id),
388388
}
389389
}
390390

@@ -437,10 +437,10 @@ pub fn data_page_params_nameid_name<'a>(
437437
data_page_params_nameid_name_limit(limit, pag_params)
438438
}
439439

440-
fn data_page_params_nameid_name_limit<'a>(
440+
fn data_page_params_nameid_name_limit(
441441
limit: NonZeroUsize,
442-
pag_params: &'a ApiPaginatedByNameOrId,
443-
) -> Result<DataPageParams<'a, ApiName>, HttpError> {
442+
pag_params: &ApiPaginatedByNameOrId,
443+
) -> Result<DataPageParams<ApiName>, HttpError> {
444444
let data_page = data_page_params_with_limit(limit, pag_params)?;
445445
let direction = data_page.direction;
446446
let marker = match data_page.marker {
@@ -467,10 +467,10 @@ pub fn data_page_params_nameid_id<'a>(
467467
data_page_params_nameid_id_limit(limit, pag_params)
468468
}
469469

470-
fn data_page_params_nameid_id_limit<'a>(
470+
fn data_page_params_nameid_id_limit(
471471
limit: NonZeroUsize,
472-
pag_params: &'a ApiPaginatedByNameOrId,
473-
) -> Result<DataPageParams<'a, Uuid>, HttpError> {
472+
pag_params: &ApiPaginatedByNameOrId,
473+
) -> Result<DataPageParams<Uuid>, HttpError> {
474474
let data_page = data_page_params_with_limit(limit, pag_params)?;
475475
let direction = data_page.direction;
476476
let marker = match data_page.marker {

src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@
5757
* it's expected that we'll have links to private items in the docs.
5858
*/
5959
#![allow(private_intra_doc_links)]
60+
/*
61+
* TODO(#32): Remove this exception once resolved.
62+
*/
63+
#![allow(clippy::field_reassign_with_default)]
6064

6165
mod api_error;
6266
pub mod api_model;

0 commit comments

Comments
 (0)