fix(migrate): fix warnings

This commit is contained in:
Federico Terzi 2021-10-05 22:06:53 +02:00
parent 11fd7ce167
commit 8ecee79aa7
2 changed files with 9 additions and 4 deletions

View File

@ -196,8 +196,9 @@ pub fn convert(input_files: HashMap<String, Hash>) -> HashMap<String, ConvertedF
fn sort_input_files(input_files: &HashMap<String, Hash>) -> Vec<String> { fn sort_input_files(input_files: &HashMap<String, Hash>) -> Vec<String> {
let mut files: Vec<String> = input_files.iter().map(|(key, _)| key.clone()).collect(); let mut files: Vec<String> = input_files.iter().map(|(key, _)| key.clone()).collect();
files.sort_by(|f1, f2| { files.sort_by(|f1, f2| {
let f1_slashes = f1.matches("/").count(); let f1_slashes = f1.matches('/').count();
let f2_slashes = f2.matches("/").count(); let f2_slashes = f2.matches('/').count();
#[allow(clippy::comparison_chain)]
if f1_slashes > f2_slashes { if f1_slashes > f2_slashes {
Ordering::Greater Ordering::Greater
} else if f1_slashes < f2_slashes { } else if f1_slashes < f2_slashes {
@ -254,7 +255,7 @@ fn yaml_get_string<'a>(yaml: &'a Hash, name: &str) -> Option<&'a str> {
.and_then(|v| v.as_str()) .and_then(|v| v.as_str())
} }
fn yaml_get_bool<'a>(yaml: &'a Hash, name: &str) -> Option<bool> { fn yaml_get_bool(yaml: &Hash, name: &str) -> Option<bool> {
yaml yaml
.get(&Yaml::String(name.to_string())) .get(&Yaml::String(name.to_string()))
.and_then(|v| v.as_bool()) .and_then(|v| v.as_bool())

View File

@ -17,13 +17,16 @@
* along with espanso. If not, see <https://www.gnu.org/licenses/>. * along with espanso. If not, see <https://www.gnu.org/licenses/>.
*/ */
#[allow(unused_imports)]
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
#[allow(unused_imports)]
#[macro_use] #[macro_use]
#[cfg(test)] #[cfg(test)]
extern crate include_dir; extern crate include_dir;
#[allow(unused_imports)]
#[macro_use] #[macro_use]
#[cfg(test)] #[cfg(test)]
extern crate test_case; extern crate test_case;
@ -198,6 +201,7 @@ mod tests {
static ALL_PARAMS_CASE: Dir = include_dir!("test/all_params"); static ALL_PARAMS_CASE: Dir = include_dir!("test/all_params");
static OTHER_DIRS_CASE: Dir = include_dir!("test/other_dirs"); static OTHER_DIRS_CASE: Dir = include_dir!("test/other_dirs");
#[allow(clippy::unused_unit)]
#[test_case(&SIMPLE_CASE; "simple case")] #[test_case(&SIMPLE_CASE; "simple case")]
#[test_case(&BASE_CASE; "base case")] #[test_case(&BASE_CASE; "base case")]
#[test_case(&ALL_PARAMS_CASE; "all config parameters case")] #[test_case(&ALL_PARAMS_CASE; "all config parameters case")]
@ -217,7 +221,7 @@ mod tests {
for (file, converted) in to_sorted_list(converted_files) { for (file, converted) in to_sorted_list(converted_files) {
assert_peq!( assert_peq!(
to_sorted_hash(&converted), to_sorted_hash(&converted),
to_sorted_hash(&expected_files.get(&file).unwrap()) to_sorted_hash(expected_files.get(&file).unwrap())
); );
} }