mirror of
https://github.com/ClementTsang/bottom
synced 2024-11-26 06:00:21 +00:00
other: enforce unused_imports lint again (#1189)
* other: enforce unused_imports lint again I think there shouldn't be any issues with enforcing this now... * set up cfg block so the logging feature doesn't break clippy * some cleanup + comments
This commit is contained in:
parent
086b622c66
commit
f0121e6af4
2 changed files with 26 additions and 19 deletions
|
@ -1,13 +1,16 @@
|
|||
#![warn(rust_2018_idioms)]
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![deny(clippy::todo)]
|
||||
#![deny(clippy::unimplemented)]
|
||||
#![deny(clippy::missing_safety_doc)]
|
||||
#[allow(unused_imports)] // TODO: Deny unused imports.
|
||||
|
||||
// Primarily used for debug purposes.
|
||||
#[cfg(feature = "log")]
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "log")] {
|
||||
#[allow(unused_imports)]
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
}
|
||||
}
|
||||
|
||||
use std::{
|
||||
boxed::Box,
|
||||
|
|
32
src/lib.rs
32
src/lib.rs
|
@ -5,15 +5,19 @@
|
|||
//! than the actual usage of the application. If you are instead looking for documentation regarding the *usage* of
|
||||
//! bottom, refer to [here](https://clementtsang.github.io/bottom/stable/).
|
||||
|
||||
#![warn(rust_2018_idioms)]
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![deny(clippy::todo)]
|
||||
#![deny(clippy::unimplemented)]
|
||||
#![deny(clippy::missing_safety_doc)]
|
||||
#[allow(unused_imports)] // TODO: Deny unused imports.
|
||||
// Only used for builds not intended for release.
|
||||
#[cfg(feature = "log")]
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
// Primarily used for debug purposes.
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "log")] {
|
||||
#[allow(unused_imports)]
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
}
|
||||
}
|
||||
|
||||
use std::{
|
||||
boxed::Box,
|
||||
|
@ -71,6 +75,7 @@ pub type Pid = usize;
|
|||
#[cfg(target_family = "unix")]
|
||||
pub type Pid = libc::pid_t;
|
||||
|
||||
/// Events sent to the main thread.
|
||||
#[derive(Debug)]
|
||||
pub enum BottomEvent {
|
||||
Resize,
|
||||
|
@ -82,6 +87,7 @@ pub enum BottomEvent {
|
|||
Terminate,
|
||||
}
|
||||
|
||||
/// Events sent to the collection thread.
|
||||
#[derive(Debug)]
|
||||
pub enum ThreadEvent {
|
||||
Reset,
|
||||
|
@ -241,19 +247,17 @@ pub fn read_config(config_location: Option<&String>) -> error::Result<Option<Pat
|
|||
pub fn create_or_get_config(config_path: &Option<PathBuf>) -> error::Result<Config> {
|
||||
if let Some(path) = config_path {
|
||||
if let Ok(config_string) = fs::read_to_string(path) {
|
||||
// We found a config file!
|
||||
Ok(toml_edit::de::from_str(config_string.as_str())?)
|
||||
} else {
|
||||
// Config file DNE...
|
||||
if let Some(parent_path) = path.parent() {
|
||||
fs::create_dir_all(parent_path)?;
|
||||
}
|
||||
// fs::File::create(path)?.write_all(CONFIG_TOP_HEAD.as_bytes())?;
|
||||
|
||||
fs::File::create(path)?.write_all(CONFIG_TEXT.as_bytes())?;
|
||||
Ok(Config::default())
|
||||
}
|
||||
} else {
|
||||
// Don't write, the config path was somehow None...
|
||||
// Don't write...
|
||||
Ok(Config::default())
|
||||
}
|
||||
}
|
||||
|
@ -264,10 +268,10 @@ pub fn try_drawing(
|
|||
) -> error::Result<()> {
|
||||
if let Err(err) = painter.draw_data(terminal, app) {
|
||||
cleanup_terminal(terminal)?;
|
||||
return Err(err);
|
||||
Err(err)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn cleanup_terminal(
|
||||
|
@ -323,7 +327,7 @@ pub fn panic_hook(panic_info: &PanicInfo<'_>) {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
// Print stack trace. Must be done after!
|
||||
// Print stack trace. Must be done after!
|
||||
execute!(
|
||||
stdout,
|
||||
Print(format!(
|
||||
|
|
Loading…
Reference in a new issue