Clippy fixes

This commit is contained in:
Javier Feliz 2025-09-11 20:50:07 -04:00
parent d79c95f617
commit 710da7de24
10 changed files with 36 additions and 26 deletions

View File

@ -54,9 +54,9 @@ fmt: ## Format all code
cargo fmt --all
lint: ## Run clippy lints
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo clippy --workspace --all-targets --all-features
fix: ## Auto-fix linting issues
lint-fix: ## Auto-fix linting issues
cargo clippy --workspace --all-targets --all-features --fix --allow-dirty --allow-staged
cargo fmt --all

View File

@ -4,7 +4,7 @@ use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use std::path::Path;
use std::sync::OnceLock;
use std::{env, fs::File, path::PathBuf};
use std::{env, path::PathBuf};
#[derive(Debug, Deserialize, Serialize)]
pub struct WaycastConfig {}
@ -80,7 +80,7 @@ pub fn cache_path<P: AsRef<Path>>(file: P) -> Option<PathBuf> {
}
pub fn config_file() -> &'static Config {
CONFIG_SINGLETON.get_or_init(|| init())
CONFIG_SINGLETON.get_or_init(init)
}
pub fn get<T: DeserializeOwned>(key: &str) -> Result<T, config::ConfigError> {

View File

@ -14,11 +14,11 @@ pub struct CacheTTL {}
impl CacheTTL {
pub fn hours(hours: u64) -> Option<Duration> {
return Some(Duration::from_secs(hours * 60 * 60));
Some(Duration::from_secs(hours * 60 * 60))
}
pub fn minutes(minutes: u64) -> Option<Duration> {
return Some(Duration::from_secs(minutes * 60));
Some(Duration::from_secs(minutes * 60))
}
}

View File

@ -43,6 +43,12 @@ pub struct WaycastLauncher {
current_results_by_id: HashMap<String, usize>,
}
impl Default for WaycastLauncher {
fn default() -> Self {
Self::new()
}
}
impl WaycastLauncher {
pub fn new() -> Self {
WaycastLauncher {

View File

@ -28,7 +28,7 @@ fn main() {
}
if let Some(path) = waycast_config::config_path("waycast.css") {
if let Err(_) = ui.apply_css(path) {
if ui.apply_css(path).is_err() {
println!("No user css found");
}
}

View File

@ -515,7 +515,7 @@ fn search_for_icon(
for cat in &categories {
let path = base
.join(icon_theme.theme_name())
.join(if (size != "scalable") {
.join(if size != "scalable" {
format!("{}x{}", size, size)
} else {
size.to_string()
@ -534,7 +534,7 @@ fn search_for_icon(
for cat in &categories {
let path = base
.join("hicolor")
.join(if (size != "scalable") {
.join(if size != "scalable" {
format!("{}x{}", size, size)
} else {
size.to_string()

View File

@ -1,7 +1,6 @@
use std::{collections::BTreeMap, path::PathBuf};
use tokei::{Config, LanguageType, Languages};
use std::path::PathBuf;
use waycast_plugins::projects::{
framework_detector::{self, FrameworkDetector},
framework_detector::FrameworkDetector,
type_scanner::TypeScanner,
};
@ -16,8 +15,7 @@ pub fn main() {
if let Ok(entries) = std::fs::read_dir(PathBuf::from("/home/javi/projects")) {
for e in entries
.into_iter()
.filter(|e| e.is_ok())
.map(|e| e.unwrap())
.flatten()
.filter(|e| e.path().is_dir())
{
let fw = framework_detector.detect(e.path().to_string_lossy().to_string().as_str());

View File

@ -21,7 +21,7 @@ crate::frameworks! {
files: ["Gemfile"],
json_checks: [("package.json", "dependencies.rails"), ("package.json", "devDependencies.rails")],
custom: |project_path: &str| {
use crate::projects::framework_macro::{has_file, read_json_config};
use crate::projects::framework_macro::has_file;
// Check for Gemfile with rails gem
if let Ok(content) = std::fs::read_to_string(format!("{}/Gemfile", project_path)) {
@ -127,6 +127,12 @@ pub struct FrameworkDetector {
heuristics: &'static [&'static dyn FrameworkHeuristics],
}
impl Default for FrameworkDetector {
fn default() -> Self {
Self::new()
}
}
impl FrameworkDetector {
pub fn new() -> FrameworkDetector {
FrameworkDetector {

View File

@ -12,7 +12,7 @@ use std::{
use std::sync::LazyLock;
use tokio::sync::Mutex;
use waycast_core::{
cache::{Cache, CacheTTL},
cache::CacheTTL,
LaunchError, LauncherListItem, LauncherPlugin,
};
use waycast_macros::{launcher_entry, plugin};
@ -195,15 +195,9 @@ impl LauncherPlugin for ProjectsPlugin {
pub fn new() -> ProjectsPlugin {
let search_paths =
match waycast_config::get::<HashSet<PathBuf>>("plugins.projects.search_paths") {
Ok(paths) => paths,
Err(_) => HashSet::new(),
};
waycast_config::get::<HashSet<PathBuf>>("plugins.projects.search_paths").unwrap_or_default();
let skip_dirs = match waycast_config::get::<HashSet<String>>("plugins.projects.skip_dirs") {
Ok(paths) => paths,
Err(_) => HashSet::new(),
};
let skip_dirs = waycast_config::get::<HashSet<String>>("plugins.projects.skip_dirs").unwrap_or_default();
let open_command = match waycast_config::get::<String>("plugins.projects.open_command") {
Ok(cmd) => cmd,

View File

@ -1,6 +1,6 @@
use std::path::Path;
use tokei::{Config, Language, LanguageType, Languages};
use tokei::{Config, LanguageType, Languages};
pub struct ProjectLanguage {
pub name: String,
@ -12,6 +12,12 @@ pub struct TypeScanner {
ignore_langs: [LanguageType; 5],
}
impl Default for TypeScanner {
fn default() -> Self {
Self::new()
}
}
impl TypeScanner {
pub fn new() -> TypeScanner {
TypeScanner {
@ -32,7 +38,7 @@ impl TypeScanner {
let mut langs = Languages::new();
langs.get_statistics(&[path], &[], &self.tokei_config);
let total_code: usize = langs.iter().map(|(_, l)| l.code).sum();
let total_code: usize = langs.values().map(|l| l.code).sum();
let mut rows: Vec<ProjectLanguage> = langs
.iter()
.map(|(lt, l)| {