Fix all clippy warnings across workspace
collapsible_if, let-chains, derivable_impls, clone_on_copy, useless_vec, approx_constant, io_other_error, single_match, collapsible_match, unnecessary_map_or, manual_is_multiple_of, result_large_err, too_many_arguments, upper_case_acronyms Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -51,6 +51,7 @@ pub enum SendMode {
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub enum LineEnding {
|
||||
None,
|
||||
LF,
|
||||
@@ -76,7 +77,7 @@ pub struct DisplayOptions {
|
||||
pub show_pipeline: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Default)]
|
||||
pub struct SearchState {
|
||||
pub query: String,
|
||||
pub matches: Vec<usize>,
|
||||
@@ -86,19 +87,6 @@ pub struct SearchState {
|
||||
pub just_opened: bool,
|
||||
}
|
||||
|
||||
impl Default for SearchState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
query: String::new(),
|
||||
matches: Vec::new(),
|
||||
current_match: 0,
|
||||
case_sensitive: false,
|
||||
active: false,
|
||||
just_opened: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl SearchState {
|
||||
pub fn clear(&mut self) {
|
||||
self.query.clear();
|
||||
@@ -357,17 +345,17 @@ impl XserialApp {
|
||||
}
|
||||
}
|
||||
SearchNext => {
|
||||
if let Some(tab) = self.tabs.get_mut(self.active) {
|
||||
if tab.search.active {
|
||||
tab.search.next();
|
||||
}
|
||||
if let Some(tab) = self.tabs.get_mut(self.active)
|
||||
&& tab.search.active
|
||||
{
|
||||
tab.search.next();
|
||||
}
|
||||
}
|
||||
SearchPrev => {
|
||||
if let Some(tab) = self.tabs.get_mut(self.active) {
|
||||
if tab.search.active {
|
||||
tab.search.prev();
|
||||
}
|
||||
if let Some(tab) = self.tabs.get_mut(self.active)
|
||||
&& tab.search.active
|
||||
{
|
||||
tab.search.prev();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -382,13 +370,13 @@ impl XserialApp {
|
||||
fn restore_saved_sessions(&mut self, saved_state: PersistedGuiState) {
|
||||
for (i, session_config) in saved_state.sessions.into_iter().enumerate() {
|
||||
self.add_session_tab(session_config);
|
||||
if let Some(tab) = self.tabs.last_mut() {
|
||||
if let Some(log_cfg) = saved_state.sessions_log.get(i) {
|
||||
tab.log_enabled = log_cfg.enabled;
|
||||
tab.log_path = log_cfg.file_path.clone();
|
||||
if log_cfg.enabled && !log_cfg.file_path.is_empty() {
|
||||
tab.log_writer = LogWriter::open(&log_cfg.file_path).ok();
|
||||
}
|
||||
if let Some(tab) = self.tabs.last_mut()
|
||||
&& let Some(log_cfg) = saved_state.sessions_log.get(i)
|
||||
{
|
||||
tab.log_enabled = log_cfg.enabled;
|
||||
tab.log_path = log_cfg.file_path.clone();
|
||||
if log_cfg.enabled && !log_cfg.file_path.is_empty() {
|
||||
tab.log_writer = LogWriter::open(&log_cfg.file_path).ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -521,16 +509,16 @@ impl XserialApp {
|
||||
SessionEvent::Data(id, entry) => {
|
||||
stats.drained_data_events += 1;
|
||||
if let Some(tab) = self.tabs.iter_mut().find(|tab| tab.id == id) {
|
||||
if let Some(ref writer) = tab.log_writer {
|
||||
if let Some(line) = logging::format_data_log(
|
||||
if let Some(ref writer) = tab.log_writer
|
||||
&& let Some(line) = logging::format_data_log(
|
||||
&entry,
|
||||
"IN",
|
||||
self.display.show_timestamp,
|
||||
self.display.show_direction,
|
||||
self.display.show_pipeline,
|
||||
) {
|
||||
writer.write_line(&line);
|
||||
}
|
||||
)
|
||||
{
|
||||
writer.write_line(&line);
|
||||
}
|
||||
match &entry.data {
|
||||
DecodedData::Text(_) => {
|
||||
@@ -1006,6 +994,7 @@ fn transport_summary(transport: &TransportConfig) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn render_font_selector(
|
||||
ui: &mut egui::Ui,
|
||||
title: &str,
|
||||
|
||||
@@ -9,7 +9,7 @@ use xserial_client::config::SessionConfig;
|
||||
|
||||
const GUI_STATE_FILE_NAME: &str = "gui-state.json";
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
pub struct SessionLogConfig {
|
||||
#[serde(default)]
|
||||
pub enabled: bool,
|
||||
@@ -17,15 +17,6 @@ pub struct SessionLogConfig {
|
||||
pub file_path: String,
|
||||
}
|
||||
|
||||
impl Default for SessionLogConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
enabled: false,
|
||||
file_path: String::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
pub struct PersistedGuiState {
|
||||
#[serde(default)]
|
||||
|
||||
@@ -83,7 +83,7 @@ impl TextBuffer {
|
||||
};
|
||||
(0..self.lines.len())
|
||||
.filter(|&i| {
|
||||
self.lines.get(i).map_or(false, |line| {
|
||||
self.lines.get(i).is_some_and(|line| {
|
||||
if case_sensitive {
|
||||
line.text.contains(query)
|
||||
} else {
|
||||
@@ -197,7 +197,7 @@ impl HexBuffer {
|
||||
};
|
||||
(0..self.lines.len())
|
||||
.filter(|&i| {
|
||||
self.lines.get(i).map_or(false, |line| {
|
||||
self.lines.get(i).is_some_and(|line| {
|
||||
if case_sensitive {
|
||||
line.hex.contains(query) || line.ascii.contains(query)
|
||||
} else {
|
||||
|
||||
@@ -878,7 +878,7 @@ fn validate_pipeline(ui: &mut Ui, pipeline: &PipelineForm, errors: &mut Vec<Stri
|
||||
};
|
||||
let sample_bytes = pipeline.plot_sample_type.byte_size();
|
||||
let frame_unit = channel_count.saturating_mul(sample_bytes);
|
||||
if frame_unit == 0 || pipeline.fixed_frame_len % frame_unit != 0 {
|
||||
if frame_unit == 0 || !pipeline.fixed_frame_len.is_multiple_of(frame_unit) {
|
||||
push_error(format!(
|
||||
"Fixed frame length must be a multiple of {} bytes for the current plot layout",
|
||||
frame_unit
|
||||
|
||||
@@ -9,6 +9,7 @@ pub enum PlotDisplayMode {
|
||||
Detached,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct PlotViewState {
|
||||
pub lock_x: bool,
|
||||
pub lock_y: bool,
|
||||
@@ -18,19 +19,6 @@ pub struct PlotViewState {
|
||||
pub detached: bool,
|
||||
}
|
||||
|
||||
impl Default for PlotViewState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
lock_x: false,
|
||||
lock_y: false,
|
||||
box_zoom: false,
|
||||
follow_latest: false,
|
||||
last_bounds: None,
|
||||
detached: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PlotRenderOutput {
|
||||
pub stats: PlotRenderStats,
|
||||
pub toggle_detached: bool,
|
||||
|
||||
@@ -10,19 +10,14 @@ use tracing::{info, warn};
|
||||
|
||||
const FONT_SETTINGS_FILE_NAME: &str = "gui-fonts.json";
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Default)]
|
||||
pub enum FontChoice {
|
||||
Auto,
|
||||
#[default]
|
||||
Default,
|
||||
System(String),
|
||||
}
|
||||
|
||||
impl Default for FontChoice {
|
||||
fn default() -> Self {
|
||||
Self::Default
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct FontCandidate {
|
||||
pub id: String,
|
||||
|
||||
Reference in New Issue
Block a user