refactor(clippy): apply various lint fixes

This commit is contained in:
LGUG2Z
2022-11-13 15:31:19 -08:00
parent b010215318
commit 37edbcfebc
6 changed files with 45 additions and 51 deletions

View File

@@ -131,7 +131,7 @@ impl ApplicationConfigurationGenerator {
String::from("; Generated by komorebic.exe"),
String::from("; To use this file, add the line below to the top of your komorebi.ahk configuration file"),
String::from("; #Include %A_ScriptDir%\\komorebi.generated.ahk"),
String::from("")
String::new()
];
let mut float_rules = vec![];
@@ -168,7 +168,7 @@ impl ApplicationConfigurationGenerator {
}
}
lines.push(String::from(""));
lines.push(String::new());
}
Ok(lines)

View File

@@ -229,16 +229,13 @@ impl Direction for CustomLayout {
}
let (column_idx, column) = self.column_with_idx(idx);
match column {
None => false,
Some(column) => match column {
Column::Secondary(Some(ColumnSplitWithCapacity::Horizontal(_)))
| Column::Tertiary(ColumnSplit::Horizontal) => {
self.column_for_container_idx(idx - 1) == column_idx
}
_ => false,
},
}
column.map_or(false, |column| match column {
Column::Secondary(Some(ColumnSplitWithCapacity::Horizontal(_)))
| Column::Tertiary(ColumnSplit::Horizontal) => {
self.column_for_container_idx(idx - 1) == column_idx
}
_ => false,
})
}
OperationDirection::Down => {
if idx == count - 1 {
@@ -246,16 +243,13 @@ impl Direction for CustomLayout {
}
let (column_idx, column) = self.column_with_idx(idx);
match column {
None => false,
Some(column) => match column {
Column::Secondary(Some(ColumnSplitWithCapacity::Horizontal(_)))
| Column::Tertiary(ColumnSplit::Horizontal) => {
self.column_for_container_idx(idx + 1) == column_idx
}
_ => false,
},
}
column.map_or(false, |column| match column {
Column::Secondary(Some(ColumnSplitWithCapacity::Horizontal(_)))
| Column::Tertiary(ColumnSplit::Horizontal) => {
self.column_for_container_idx(idx + 1) == column_idx
}
_ => false,
})
}
}
}

View File

@@ -113,7 +113,7 @@ lazy_static! {
static ref HIDING_BEHAVIOUR: Arc<Mutex<HidingBehaviour>> =
Arc::new(Mutex::new(HidingBehaviour::Minimize));
static ref HOME_DIR: PathBuf = {
if let Ok(home_path) = std::env::var("KOMOREBI_CONFIG_HOME") {
std::env::var("KOMOREBI_CONFIG_HOME").map_or_else(|_| dirs::home_dir().expect("there is no home directory"), |home_path| {
let home = PathBuf::from(&home_path);
if home.as_path().is_dir() {
@@ -124,9 +124,7 @@ lazy_static! {
home_path
);
}
} else {
dirs::home_dir().expect("there is no home directory")
}
})
};
static ref DATA_DIR: PathBuf = dirs::data_local_dir().expect("there is no local data directory").join("komorebi");
static ref AHK_V1_EXE: String = {

View File

@@ -127,6 +127,7 @@ impl Monitor {
let workspaces = self.workspaces_mut();
#[allow(clippy::option_if_let_else)]
let target_workspace = match workspaces.get_mut(target_workspace_idx) {
None => {
workspaces.resize(target_workspace_idx + 1, Workspace::default());

View File

@@ -435,7 +435,7 @@ impl WindowManager {
socket.push("komorebic.sock");
let socket = socket.as_path();
let mut stream = UnixStream::connect(&socket)?;
let mut stream = UnixStream::connect(socket)?;
stream.write_all(state.as_bytes())?;
}
SocketMessage::Query(query) => {
@@ -458,7 +458,7 @@ impl WindowManager {
socket.push("komorebic.sock");
let socket = socket.as_path();
let mut stream = UnixStream::connect(&socket)?;
let mut stream = UnixStream::connect(socket)?;
stream.write_all(response.as_bytes())?;
}
SocketMessage::ResizeWindowEdge(direction, sizing) => {
@@ -856,7 +856,7 @@ impl WindowManager {
socket.push("komorebic.sock");
let socket = socket.as_path();
let mut stream = UnixStream::connect(&socket)?;
let mut stream = UnixStream::connect(socket)?;
stream.write_all(schema.as_bytes())?;
}
SocketMessage::SocketSchema => {
@@ -866,7 +866,7 @@ impl WindowManager {
socket.push("komorebic.sock");
let socket = socket.as_path();
let mut stream = UnixStream::connect(&socket)?;
let mut stream = UnixStream::connect(socket)?;
stream.write_all(schema.as_bytes())?;
}
};

View File

@@ -48,20 +48,21 @@ use komorebi_core::WindowKind;
lazy_static! {
static ref HOME_DIR: PathBuf = {
if let Ok(home_path) = std::env::var("KOMOREBI_CONFIG_HOME") {
let home = PathBuf::from(&home_path);
std::env::var("KOMOREBI_CONFIG_HOME").map_or_else(
|_| dirs::home_dir().expect("there is no home directory"),
|home_path| {
let home = PathBuf::from(&home_path);
if home.as_path().is_dir() {
home
} else {
panic!(
"$Env:KOMOREBI_CONFIG_HOME is set to '{}', which is not a valid directory",
home_path
);
}
} else {
dirs::home_dir().expect("there is no home directory")
}
if home.as_path().is_dir() {
home
} else {
panic!(
"$Env:KOMOREBI_CONFIG_HOME is set to '{}', which is not a valid directory",
home_path
);
}
},
)
};
static ref DATA_DIR: PathBuf = dirs::data_local_dir()
.expect("there is no local data directory")
@@ -1181,7 +1182,7 @@ fn main() -> Result<()> {
socket.push("komorebic.sock");
let socket = socket.as_path();
match std::fs::remove_file(&socket) {
match std::fs::remove_file(socket) {
Ok(_) => {}
Err(error) => match error.kind() {
// Doing this because ::exists() doesn't work reliably on Windows via IntelliJ
@@ -1192,7 +1193,7 @@ fn main() -> Result<()> {
},
};
let listener = UnixListener::bind(&socket)?;
let listener = UnixListener::bind(socket)?;
send_message(&SocketMessage::State.as_bytes()?)?;
@@ -1216,7 +1217,7 @@ fn main() -> Result<()> {
socket.push("komorebic.sock");
let socket = socket.as_path();
match std::fs::remove_file(&socket) {
match std::fs::remove_file(socket) {
Ok(_) => {}
Err(error) => match error.kind() {
// Doing this because ::exists() doesn't work reliably on Windows via IntelliJ
@@ -1227,7 +1228,7 @@ fn main() -> Result<()> {
},
};
let listener = UnixListener::bind(&socket)?;
let listener = UnixListener::bind(socket)?;
send_message(&SocketMessage::Query(arg.state_query).as_bytes()?)?;
@@ -1419,7 +1420,7 @@ fn main() -> Result<()> {
socket.push("komorebic.sock");
let socket = socket.as_path();
match std::fs::remove_file(&socket) {
match std::fs::remove_file(socket) {
Ok(_) => {}
Err(error) => match error.kind() {
// Doing this because ::exists() doesn't work reliably on Windows via IntelliJ
@@ -1432,7 +1433,7 @@ fn main() -> Result<()> {
send_message(&SocketMessage::NotificationSchema.as_bytes()?)?;
let listener = UnixListener::bind(&socket)?;
let listener = UnixListener::bind(socket)?;
match listener.accept() {
Ok(incoming) => {
let stream = BufReader::new(incoming.0);
@@ -1453,7 +1454,7 @@ fn main() -> Result<()> {
socket.push("komorebic.sock");
let socket = socket.as_path();
match std::fs::remove_file(&socket) {
match std::fs::remove_file(socket) {
Ok(_) => {}
Err(error) => match error.kind() {
// Doing this because ::exists() doesn't work reliably on Windows via IntelliJ
@@ -1466,7 +1467,7 @@ fn main() -> Result<()> {
send_message(&SocketMessage::SocketSchema.as_bytes()?)?;
let listener = UnixListener::bind(&socket)?;
let listener = UnixListener::bind(socket)?;
match listener.accept() {
Ok(incoming) => {
let stream = BufReader::new(incoming.0);