Skip to content

Commit

Permalink
Fix clippy lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jackTabsCode committed Jan 12, 2025
1 parent f33d1f1 commit 75e33cf
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 76 deletions.
8 changes: 1 addition & 7 deletions crates/rojo-insta-ext/src/redaction_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@ use serde::Serialize;
/// Enables redacting any value that serializes as a string.
///
/// Used for transforming Rojo instance IDs into something deterministic.
#[derive(Default)]
pub struct RedactionMap {
ids: HashMap<String, usize>,
last_id: usize,
}

impl RedactionMap {
pub fn new() -> Self {
Self {
ids: HashMap::new(),
last_id: 0,
}
}

pub fn get_redacted_value(&self, id: impl ToString) -> Option<String> {
let id = id.to_string();

Expand Down
1 change: 1 addition & 0 deletions src/lua_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ trait FmtLua {
}
}

#[allow(dead_code)]
struct DisplayLua<T>(T);

impl<T> fmt::Display for DisplayLua<T>
Expand Down
4 changes: 2 additions & 2 deletions src/multimap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ impl<K: Hash + Eq, V: Eq> MultiMap<K, V> {
}
}

pub fn get<Q: ?Sized>(&self, k: &Q) -> &[V]
pub fn get<Q>(&self, k: &Q) -> &[V]
where
K: Borrow<Q>,
Q: Hash + Eq,
Q: Hash + Eq + ?Sized,
{
self.inner.get(k).map(Vec::as_slice).unwrap_or(&[])
}
Expand Down
4 changes: 2 additions & 2 deletions src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl Project {
io::ErrorKind::NotFound => Error::NoProjectFound {
path: project_path.to_path_buf(),
},
_ => return e.into(),
_ => e.into(),
})?;

Ok(Some(Self::load_from_slice(&contents, project_path, None)?))
Expand All @@ -250,7 +250,7 @@ impl Project {
io::ErrorKind::NotFound => Error::NoProjectFound {
path: project_path.to_path_buf(),
},
_ => return e.into(),
_ => e.into(),
})?;

Ok(Self::load_from_slice(
Expand Down
4 changes: 2 additions & 2 deletions src/snapshot/patch_compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ mod test {
// addition of a prop named Self, which is a self-referential Ref.
let snapshot_id = Ref::new();
let snapshot = InstanceSnapshot {
snapshot_id: snapshot_id,
snapshot_id,
properties: [("Self".to_owned(), Variant::Ref(snapshot_id))].into(),

metadata: Default::default(),
Expand Down Expand Up @@ -351,7 +351,7 @@ mod test {
// This patch describes the existing instance with a new child added.
let snapshot_id = Ref::new();
let snapshot = InstanceSnapshot {
snapshot_id: snapshot_id,
snapshot_id,
children: vec![InstanceSnapshot {
properties: [("Self".to_owned(), Variant::Ref(snapshot_id))].into(),

Expand Down
8 changes: 4 additions & 4 deletions src/snapshot/tests/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{

#[test]
fn set_name_and_class_name() {
let mut redactions = RedactionMap::new();
let mut redactions = RedactionMap::default();

let mut tree = empty_tree();
intern_tree(&tree, &mut redactions);
Expand All @@ -36,7 +36,7 @@ fn set_name_and_class_name() {

#[test]
fn add_property() {
let mut redactions = RedactionMap::new();
let mut redactions = RedactionMap::default();

let mut tree = empty_tree();
intern_tree(&tree, &mut redactions);
Expand All @@ -63,7 +63,7 @@ fn add_property() {

#[test]
fn remove_property() {
let mut redactions = RedactionMap::new();
let mut redactions = RedactionMap::default();

let mut tree = empty_tree();
intern_tree(&tree, &mut redactions);
Expand All @@ -85,7 +85,7 @@ fn remove_property() {
id: tree.get_root_id(),
changed_name: None,
changed_class_name: None,
changed_properties: [("Foo".to_owned(), None).into()].into(),
changed_properties: [("Foo".to_owned(), None)].into(),
changed_metadata: None,
}],
..Default::default()
Expand Down
10 changes: 5 additions & 5 deletions src/snapshot/tests/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::snapshot::{compute_patch_set, InstanceSnapshot, RojoTree};

#[test]
fn set_name_and_class_name() {
let mut redactions = RedactionMap::new();
let mut redactions = RedactionMap::default();

let tree = empty_tree();
redactions.intern(tree.get_root_id());
Expand All @@ -31,7 +31,7 @@ fn set_name_and_class_name() {

#[test]
fn set_property() {
let mut redactions = RedactionMap::new();
let mut redactions = RedactionMap::default();

let tree = empty_tree();
redactions.intern(tree.get_root_id());
Expand All @@ -53,7 +53,7 @@ fn set_property() {

#[test]
fn remove_property() {
let mut redactions = RedactionMap::new();
let mut redactions = RedactionMap::default();

let mut tree = empty_tree();
redactions.intern(tree.get_root_id());
Expand Down Expand Up @@ -84,7 +84,7 @@ fn remove_property() {

#[test]
fn add_child() {
let mut redactions = RedactionMap::new();
let mut redactions = RedactionMap::default();

let tree = empty_tree();
redactions.intern(tree.get_root_id());
Expand Down Expand Up @@ -113,7 +113,7 @@ fn add_child() {

#[test]
fn remove_child() {
let mut redactions = RedactionMap::new();
let mut redactions = RedactionMap::default();

let mut tree = empty_tree();
redactions.intern(tree.get_root_id());
Expand Down
4 changes: 2 additions & 2 deletions src/snapshot/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl RojoTree {
// We need to uphold the invariant that each ID can only map
// to one referent.
if let Some(new) = &metadata.specified_id {
if self.specified_id_to_refs.get(new).len() > 0 {
if !self.specified_id_to_refs.get(new).is_empty() {
log::error!("Duplicate user-specified referent '{new}'");
}

Expand Down Expand Up @@ -206,7 +206,7 @@ impl RojoTree {
}

if let Some(specified_id) = &metadata.specified_id {
if self.specified_id_to_refs.get(specified_id).len() > 0 {
if !self.specified_id_to_refs.get(specified_id).is_empty() {
log::error!("Duplicate user-specified referent '{specified_id}'");
}

Expand Down
8 changes: 4 additions & 4 deletions src/snapshot_middleware/csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ Ack,Ack!,,An exclamation of despair,¡Ay!"#,
)
.unwrap();

let mut vfs = Vfs::new(imfs);
let vfs = Vfs::new(imfs);

let instance_snapshot = snapshot_csv(
&InstanceContext::default(),
&mut vfs,
&vfs,
Path::new("/foo.csv"),
"foo",
)
Expand Down Expand Up @@ -209,11 +209,11 @@ Ack,Ack!,,An exclamation of despair,¡Ay!"#,
)
.unwrap();

let mut vfs = Vfs::new(imfs);
let vfs = Vfs::new(imfs);

let instance_snapshot = snapshot_csv(
&InstanceContext::default(),
&mut vfs,
&vfs,
Path::new("/foo.csv"),
"foo",
)
Expand Down
18 changes: 8 additions & 10 deletions src/snapshot_middleware/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,11 @@ mod test {
imfs.load_snapshot("/foo", VfsSnapshot::empty_dir())
.unwrap();

let mut vfs = Vfs::new(imfs);
let vfs = Vfs::new(imfs);

let instance_snapshot =
snapshot_dir(&InstanceContext::default(), &mut vfs, Path::new("/foo"))
.unwrap()
.unwrap();
let instance_snapshot = snapshot_dir(&InstanceContext::default(), &vfs, Path::new("/foo"))
.unwrap()
.unwrap();

insta::assert_yaml_snapshot!(instance_snapshot);
}
Expand All @@ -135,12 +134,11 @@ mod test {
)
.unwrap();

let mut vfs = Vfs::new(imfs);
let vfs = Vfs::new(imfs);

let instance_snapshot =
snapshot_dir(&InstanceContext::default(), &mut vfs, Path::new("/foo"))
.unwrap()
.unwrap();
let instance_snapshot = snapshot_dir(&InstanceContext::default(), &vfs, Path::new("/foo"))
.unwrap()
.unwrap();

insta::assert_yaml_snapshot!(instance_snapshot);
}
Expand Down
4 changes: 2 additions & 2 deletions src/snapshot_middleware/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ mod test {
)
.unwrap();

let mut vfs = Vfs::new(imfs.clone());
let vfs = Vfs::new(imfs.clone());

let instance_snapshot = snapshot_json(
&InstanceContext::default(),
&mut vfs,
&vfs,
Path::new("/foo.json"),
"foo",
)
Expand Down
Loading

0 comments on commit 75e33cf

Please sign in to comment.