Clippy fixes
This commit is contained in:
parent
d79c95f617
commit
710da7de24
4
Makefile
4
Makefile
@ -54,9 +54,9 @@ fmt: ## Format all code
|
|||||||
cargo fmt --all
|
cargo fmt --all
|
||||||
|
|
||||||
lint: ## Run clippy lints
|
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 clippy --workspace --all-targets --all-features --fix --allow-dirty --allow-staged
|
||||||
cargo fmt --all
|
cargo fmt --all
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ use serde::de::DeserializeOwned;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
use std::{env, fs::File, path::PathBuf};
|
use std::{env, path::PathBuf};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct WaycastConfig {}
|
pub struct WaycastConfig {}
|
||||||
@ -80,7 +80,7 @@ pub fn cache_path<P: AsRef<Path>>(file: P) -> Option<PathBuf> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn config_file() -> &'static Config {
|
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> {
|
pub fn get<T: DeserializeOwned>(key: &str) -> Result<T, config::ConfigError> {
|
||||||
|
4
waycast-core/src/cache/mod.rs
vendored
4
waycast-core/src/cache/mod.rs
vendored
@ -14,11 +14,11 @@ pub struct CacheTTL {}
|
|||||||
|
|
||||||
impl CacheTTL {
|
impl CacheTTL {
|
||||||
pub fn hours(hours: u64) -> Option<Duration> {
|
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> {
|
pub fn minutes(minutes: u64) -> Option<Duration> {
|
||||||
return Some(Duration::from_secs(minutes * 60));
|
Some(Duration::from_secs(minutes * 60))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,12 @@ pub struct WaycastLauncher {
|
|||||||
current_results_by_id: HashMap<String, usize>,
|
current_results_by_id: HashMap<String, usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for WaycastLauncher {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl WaycastLauncher {
|
impl WaycastLauncher {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
WaycastLauncher {
|
WaycastLauncher {
|
||||||
|
@ -28,7 +28,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(path) = waycast_config::config_path("waycast.css") {
|
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");
|
println!("No user css found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,7 +515,7 @@ fn search_for_icon(
|
|||||||
for cat in &categories {
|
for cat in &categories {
|
||||||
let path = base
|
let path = base
|
||||||
.join(icon_theme.theme_name())
|
.join(icon_theme.theme_name())
|
||||||
.join(if (size != "scalable") {
|
.join(if size != "scalable" {
|
||||||
format!("{}x{}", size, size)
|
format!("{}x{}", size, size)
|
||||||
} else {
|
} else {
|
||||||
size.to_string()
|
size.to_string()
|
||||||
@ -534,7 +534,7 @@ fn search_for_icon(
|
|||||||
for cat in &categories {
|
for cat in &categories {
|
||||||
let path = base
|
let path = base
|
||||||
.join("hicolor")
|
.join("hicolor")
|
||||||
.join(if (size != "scalable") {
|
.join(if size != "scalable" {
|
||||||
format!("{}x{}", size, size)
|
format!("{}x{}", size, size)
|
||||||
} else {
|
} else {
|
||||||
size.to_string()
|
size.to_string()
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use std::{collections::BTreeMap, path::PathBuf};
|
use std::path::PathBuf;
|
||||||
use tokei::{Config, LanguageType, Languages};
|
|
||||||
use waycast_plugins::projects::{
|
use waycast_plugins::projects::{
|
||||||
framework_detector::{self, FrameworkDetector},
|
framework_detector::FrameworkDetector,
|
||||||
type_scanner::TypeScanner,
|
type_scanner::TypeScanner,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -16,8 +15,7 @@ pub fn main() {
|
|||||||
if let Ok(entries) = std::fs::read_dir(PathBuf::from("/home/javi/projects")) {
|
if let Ok(entries) = std::fs::read_dir(PathBuf::from("/home/javi/projects")) {
|
||||||
for e in entries
|
for e in entries
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|e| e.is_ok())
|
.flatten()
|
||||||
.map(|e| e.unwrap())
|
|
||||||
.filter(|e| e.path().is_dir())
|
.filter(|e| e.path().is_dir())
|
||||||
{
|
{
|
||||||
let fw = framework_detector.detect(e.path().to_string_lossy().to_string().as_str());
|
let fw = framework_detector.detect(e.path().to_string_lossy().to_string().as_str());
|
||||||
|
@ -21,7 +21,7 @@ crate::frameworks! {
|
|||||||
files: ["Gemfile"],
|
files: ["Gemfile"],
|
||||||
json_checks: [("package.json", "dependencies.rails"), ("package.json", "devDependencies.rails")],
|
json_checks: [("package.json", "dependencies.rails"), ("package.json", "devDependencies.rails")],
|
||||||
custom: |project_path: &str| {
|
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
|
// Check for Gemfile with rails gem
|
||||||
if let Ok(content) = std::fs::read_to_string(format!("{}/Gemfile", project_path)) {
|
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],
|
heuristics: &'static [&'static dyn FrameworkHeuristics],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for FrameworkDetector {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FrameworkDetector {
|
impl FrameworkDetector {
|
||||||
pub fn new() -> FrameworkDetector {
|
pub fn new() -> FrameworkDetector {
|
||||||
FrameworkDetector {
|
FrameworkDetector {
|
||||||
|
@ -12,7 +12,7 @@ use std::{
|
|||||||
use std::sync::LazyLock;
|
use std::sync::LazyLock;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use waycast_core::{
|
use waycast_core::{
|
||||||
cache::{Cache, CacheTTL},
|
cache::CacheTTL,
|
||||||
LaunchError, LauncherListItem, LauncherPlugin,
|
LaunchError, LauncherListItem, LauncherPlugin,
|
||||||
};
|
};
|
||||||
use waycast_macros::{launcher_entry, plugin};
|
use waycast_macros::{launcher_entry, plugin};
|
||||||
@ -195,15 +195,9 @@ impl LauncherPlugin for ProjectsPlugin {
|
|||||||
|
|
||||||
pub fn new() -> ProjectsPlugin {
|
pub fn new() -> ProjectsPlugin {
|
||||||
let search_paths =
|
let search_paths =
|
||||||
match waycast_config::get::<HashSet<PathBuf>>("plugins.projects.search_paths") {
|
waycast_config::get::<HashSet<PathBuf>>("plugins.projects.search_paths").unwrap_or_default();
|
||||||
Ok(paths) => paths,
|
|
||||||
Err(_) => HashSet::new(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let skip_dirs = match waycast_config::get::<HashSet<String>>("plugins.projects.skip_dirs") {
|
let skip_dirs = waycast_config::get::<HashSet<String>>("plugins.projects.skip_dirs").unwrap_or_default();
|
||||||
Ok(paths) => paths,
|
|
||||||
Err(_) => HashSet::new(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let open_command = match waycast_config::get::<String>("plugins.projects.open_command") {
|
let open_command = match waycast_config::get::<String>("plugins.projects.open_command") {
|
||||||
Ok(cmd) => cmd,
|
Ok(cmd) => cmd,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use tokei::{Config, Language, LanguageType, Languages};
|
use tokei::{Config, LanguageType, Languages};
|
||||||
|
|
||||||
pub struct ProjectLanguage {
|
pub struct ProjectLanguage {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
@ -12,6 +12,12 @@ pub struct TypeScanner {
|
|||||||
ignore_langs: [LanguageType; 5],
|
ignore_langs: [LanguageType; 5],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for TypeScanner {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl TypeScanner {
|
impl TypeScanner {
|
||||||
pub fn new() -> TypeScanner {
|
pub fn new() -> TypeScanner {
|
||||||
TypeScanner {
|
TypeScanner {
|
||||||
@ -32,7 +38,7 @@ impl TypeScanner {
|
|||||||
let mut langs = Languages::new();
|
let mut langs = Languages::new();
|
||||||
langs.get_statistics(&[path], &[], &self.tokei_config);
|
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
|
let mut rows: Vec<ProjectLanguage> = langs
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(lt, l)| {
|
.map(|(lt, l)| {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user