Skip to content

Commit

Permalink
feat(ft): clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
attilarepka committed Sep 24, 2024
1 parent 52ccdae commit e602b3d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: lint
run: cargo fmt -- --check

- name: clippy
run: cargo clippy -- -D warnings

- name: build
run: cargo build --verbose

- name: run tests
run: cargo test --verbose
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl App {
let mut terminal = Self::init_terminal()?;

while !self.exit {
terminal.draw(|frame| self.ui.run(frame, &mut self.model))?;
terminal.draw(|frame| self.ui.run(frame, &self.model))?;
self.handle_events().await?;
}

Expand Down
4 changes: 2 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use clap::Parser;
#[derive(Parser, Debug)]
#[command(author, version, about = "sqliters", long_about = None)]
pub struct Args {
/// Input archive file
/// Input sqlite file
#[clap(long, short)]
pub input_file: String,
pub input: String,
}

impl Args {
Expand Down
2 changes: 1 addition & 1 deletion src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl Sqlite {
.into_iter()
.map(|row| {
row.columns()
.into_iter()
.iter()
.map(|column| {
let ordinal = column.ordinal();
let type_name = column.type_info().name();
Expand Down
14 changes: 7 additions & 7 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl Table {
&self.rows
}
pub fn schema(&self) -> &str {
&self.schema.as_str()
self.schema.as_str()
}
}

Expand Down Expand Up @@ -130,15 +130,15 @@ impl Model {
let i = match self.state.selected() {
Some(i) => match self.view_state {
ViewState::Main => {
if i >= self.tables.len().checked_sub(1).unwrap_or(0) {
if i >= self.tables.len().saturating_sub(1) {
0
} else {
i + 1
}
}
ViewState::Table => match self.tables.get(self.selected_table_id) {
Some(table) => {
if i >= table.rows().len().checked_sub(1).unwrap_or(0) {
if i >= table.rows().len().saturating_sub(1) {
0
} else {
i + 1
Expand All @@ -158,15 +158,15 @@ impl Model {
Some(i) => match self.view_state {
ViewState::Main => {
if i == 0 {
self.tables.len().checked_sub(1).unwrap_or(0)
self.tables.len().saturating_sub(1)
} else {
i - 1
}
}
ViewState::Table => match self.tables.get(self.selected_table_id) {
Some(table) => {
if i == 0 {
table.rows().len().checked_sub(1).unwrap_or(0)
table.rows().len().saturating_sub(1)
} else {
i - 1
}
Expand Down Expand Up @@ -214,7 +214,7 @@ impl Model {
.state
.selected()
.unwrap_or(0)
.min(self.tables.len().checked_sub(1).unwrap_or(0));
.min(self.tables.len().saturating_sub(1));
self.state = TableState::default().with_selected(0);
self.view_state = ViewState::Main;
for i in 0..self.tables.len() {
Expand All @@ -223,7 +223,7 @@ impl Model {
self.tables[i].columns = Self::columns(None, &self.db, &ViewState::Main).await?;
}
self.scroll_state =
ScrollbarState::new((self.tables.len().checked_sub(1).unwrap_or(0)) * ITEM_HEIGHT);
ScrollbarState::new(self.tables.len().saturating_sub(1) * ITEM_HEIGHT);
}
Ok(())
}
Expand Down

0 comments on commit e602b3d

Please sign in to comment.