Skip to content

Commit 7f3c514

Browse files
authored
Merge pull request #149 from academician/lint-fixes
Fix various lints
2 parents 43aa50d + c9e4149 commit 7f3c514

File tree

22 files changed

+93
-105
lines changed

22 files changed

+93
-105
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ thiserror = "^1"
2626
regex = { version = "^1", optional = true }
2727
crossbeam-channel = "^0.5"
2828
parking_lot = "0.12.1"
29-
once_cell = { version = "^1.18", features = ["parking_lot"] }
3029

3130
[features]
3231
search = [ "regex" ]

Justfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
_prechecks:
22
-cargo hack 2> /dev/null
3-
4-
if [ $? == 101 ]; then \
3+
4+
if [ $? -eq 101 ]; then \
55
cargo install cargo-hack; \
66
fi
77

@@ -25,7 +25,7 @@ examples:
2525
cargo check --example=less-rs --features=dynamic_output,search
2626

2727
lint: _prechecks
28-
cargo hack --feature-powerset clippy
28+
cargo hack --feature-powerset clippy --all-targets
2929

3030
verify-all: check-fmt build tests examples lint
3131
@echo "Ready to go"

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ And the help from these projects:-
125125
- [regex](https://crates.io/crates/regex): Regex support when searching.
126126
- [crossbeam-channel](https://crates.io/crates/crossbeam-channel): MPMC channel
127127
- [parking_lot](https://crates.io/crates/parking_lot): Improved atomic storage types
128-
- [once_cell](https://crates.io/crates/once_cell): Provides one-time initialization types.
129128
- [tokio](https://crates.io/crates/tokio): Provides runtime for async examples.
130129

131130
## Get in touch

examples/large_lines.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fn main() -> Result<(), MinusError> {
55

66
for i in 0..30 {
77
for _ in 0..=10 {
8-
output.push_str(&format!("{}. Hello ", i))?;
8+
output.push_str(format!("{}. Hello ", i))?;
99
}
1010
output.push_str("\n")?;
1111
}

examples/msg-tokio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ async fn main() -> Result<(), MinusError> {
88

99
let increment = async {
1010
for i in 0..=10_u32 {
11-
output.push_str(&format!("{}\n", i))?;
11+
output.push_str(format!("{}\n", i))?;
1212
sleep(Duration::from_millis(100)).await;
1313
}
1414
output.send_message("No more output to come")?;

examples/static.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ fn main() -> Result<(), MinusError> {
44
let output = minus::Pager::new();
55

66
for i in 0..=100 {
7-
output.push_str(&format!("{}\n", i))?;
7+
output.push_str(format!("{}\n", i))?;
88
}
99

1010
minus::page_all(output)?;

src/core/commands.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ impl PartialEq for Command {
7272
impl Debug for Command {
7373
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7474
match self {
75-
Self::SetData(text) => write!(f, "SetData({:?})", text),
76-
Self::AppendData(text) => write!(f, "AppendData({:?})", text),
77-
Self::SetPrompt(text) => write!(f, "SetPrompt({:?})", text),
78-
Self::SendMessage(text) => write!(f, "SendMessage({:?})", text),
79-
Self::SetLineNumbers(ln) => write!(f, "SetLineNumbers({:?})", ln),
80-
Self::LineWrapping(lw) => write!(f, "LineWrapping({:?})", lw),
81-
Self::SetExitStrategy(es) => write!(f, "SetExitStrategy({:?})", es),
75+
Self::SetData(text) => write!(f, "SetData({text:?})"),
76+
Self::AppendData(text) => write!(f, "AppendData({text:?})"),
77+
Self::SetPrompt(text) => write!(f, "SetPrompt({text:?})"),
78+
Self::SendMessage(text) => write!(f, "SendMessage({text:?})"),
79+
Self::SetLineNumbers(ln) => write!(f, "SetLineNumbers({ln:?})"),
80+
Self::LineWrapping(lw) => write!(f, "LineWrapping({lw:?})"),
81+
Self::SetExitStrategy(es) => write!(f, "SetExitStrategy({es:?})"),
8282
Self::SetInputClassifier(_) => write!(f, "SetInputClassifier"),
8383
Self::ShowPrompt(show) => write!(f, "ShowPrompt({show:?})"),
8484
Self::FormatRedrawPrompt => write!(f, "FormatRedrawPrompt"),

src/core/ev_handler.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ pub fn handle_event(
287287

288288
Command::SetPrompt(ref text) | Command::SendMessage(ref text) => {
289289
if let Command::SetPrompt(_) = ev {
290-
p.prompt = text.to_string();
290+
p.prompt = text.clone();
291291
} else {
292-
p.message = Some(text.to_string());
292+
p.message = Some(text.clone());
293293
}
294294
p.format_prompt();
295295
if !p.running.lock().is_uninitialized() {
@@ -337,17 +337,16 @@ mod tests {
337337
use super::super::commands::Command;
338338
use super::handle_event;
339339
use crate::{minus_core::CommandQueue, ExitStrategy, PagerState, RunMode};
340-
use std::sync::{atomic::AtomicBool, Arc};
341340
#[cfg(feature = "search")]
342-
use {
343-
once_cell::sync::Lazy,
344-
parking_lot::{Condvar, Mutex},
345-
};
341+
use parking_lot::{Condvar, Mutex};
342+
#[cfg(feature = "search")]
343+
use std::sync::LazyLock;
344+
use std::sync::{atomic::AtomicBool, Arc};
346345

347346
// Tests constants
348347
#[cfg(feature = "search")]
349-
static UIA: Lazy<Arc<(Mutex<bool>, Condvar)>> =
350-
Lazy::new(|| Arc::new((Mutex::new(true), Condvar::new())));
348+
static UIA: LazyLock<Arc<(Mutex<bool>, Condvar)>> =
349+
LazyLock::new(|| Arc::new((Mutex::new(true), Condvar::new())));
351350
const TEST_STR: &str = "This is some sample text";
352351

353352
// Tests for event emitting functions of Pager

src/core/init.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
//!
33
//! This module provides two main functions:-
44
//! * The [`init_core`] function which is responsible for setting the initial state of the
5-
//! Pager, do environment checks and initializing various core functions on either async
6-
//! tasks or native threads depending on the feature set
5+
//! Pager, do environment checks and initializing various core functions on either async
6+
//! tasks or native threads depending on the feature set
77
//!
88
//! * The [`start_reactor`] function displays the displays the output and also polls
9-
//! the [`Receiver`] held inside the [`Pager`] for events. Whenever a event is
10-
//! detected, it reacts to it accordingly.
9+
//! the [`Receiver`] held inside the [`Pager`] for events. Whenever a event is
10+
//! detected, it reacts to it accordingly.
1111
#[cfg(feature = "static_output")]
1212
use crate::minus_core::utils::display;
1313
use crate::{
@@ -52,21 +52,21 @@ use super::{utils::display::draw_for_change, CommandQueue, RUNMODE};
5252
///
5353
/// Then it checks if the minus is running in static mode and does some checks:-
5454
/// * If standard output is not a terminal screen, that is if it is a file or block
55-
/// device, minus will write all the data at once to the stdout and quit
55+
/// device, minus will write all the data at once to the stdout and quit
5656
///
5757
/// * If the size of the data is less than the available number of rows in the terminal
58-
/// then it displays everything on the main stdout screen at once and quits. This
59-
/// behaviour can be turned off if [`Pager::set_run_no_overflow(true)`] is called
60-
/// by the main application
58+
/// then it displays everything on the main stdout screen at once and quits. This
59+
/// behaviour can be turned off if [`Pager::set_run_no_overflow(true)`] is called
60+
/// by the main application
6161
// Sorry... this behaviour would have been cool to have in async mode, just think about it!!! Many
6262
// implementations were proposed but none were perfect
6363
// It is because implementing this especially with line wrapping and terminal scrolling
6464
// is a a nightmare because terminals are really naughty and more when you have to fight with it
6565
// using your library... your only weapon
6666
// So we just don't take any more proposals about this. It is really frustating to
6767
// to thoroughly test each implementation and fix out all rough edges around it
68-
/// Next it initializes the runtime and calls [`start_reactor`] and a [`event reader`]` which is
69-
/// selected based on the enabled feature set:-
68+
/// Next it initializes the runtime and calls [`start_reactor`] and a [`event reader`]` which is
69+
/// selected based on the enabled feature set:-
7070
///
7171
/// # Errors
7272
///

src/core/utils/display/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ pub fn draw_append_text(
207207
crossterm::execute!(out, crossterm::terminal::Clear(ClearType::CurrentLine))?;
208208
}
209209
for line in &fmt_text[0..num_appendable] {
210-
write!(out, "{}\n\r", line)?;
210+
write!(out, "{line}\n\r")?;
211211
}
212212
out.flush()?;
213213
}

0 commit comments

Comments
 (0)