Skip to content

Commit

Permalink
make clippy happy and add a github workflow (#12)
Browse files Browse the repository at this point in the history
* 🚨 make `clippy` happy

* 👷 add first github actions workflow

* 👷 fix workflow

* 👷 exclude the dependencies in the clippy check
  • Loading branch information
AucaCoyan committed Jun 1, 2023
1 parent c503f00 commit 205315b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/clippy_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
on: [push, pull_request]

name: Clippy check

jobs:
clippy_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Rust toolchain and cache
uses: actions-rust-lang/[email protected]

- name: cargo fmt
run: cargo fmt --all -- --check

- name: Clippy
run: cargo clippy --no-deps
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ impl Config {
/// You cannot skip any field yet.
pub fn new(tab_spaces: usize, max_width: usize, margin: usize) -> Self {
Config {
tab_spaces: tab_spaces,
max_width: max_width,
margin: margin,
tab_spaces,
max_width,
margin,
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pub struct Session<'b, T: Write> {
impl<'b, T: Write + 'b> Session<'b, T> {
pub fn new(config: config::Config, out: Option<&'b mut T>) -> Self {
Self {
config: config,
out: out,
config,
out,
has_operational_errors: false,
}
}
Expand Down Expand Up @@ -62,9 +62,9 @@ impl Input {

fn contents(&self) -> Vec<u8> {
match self {
Input::File(path) => std::fs::read(path).expect(
format!("something went wrong reading the file {}", path.display()).as_str(),
),
Input::File(path) => std::fs::read(path).unwrap_or_else(|_| {
panic!("something went wrong reading the file {}", path.display())
}),
Input::Text(string) => string.as_bytes().to_vec(),
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#[allow(unused_import_braces)]
use anyhow::Result;
use clap::Parser;
use env_logger;
use nufmt::config::Config;
use nufmt::{Input, Session};
use std::error::Error;
Expand Down Expand Up @@ -108,9 +107,7 @@ fn execute(files: Vec<PathBuf>, options: Config) -> Result<i32> {
}

fn format_and_emit_report<T: Write>(session: &mut Session<'_, T>, input: Input) {
match session.format(input) {
_ => {} // _ => todo!("Here `nufmt` gives you a FormatReport"),
}
session.format(input);
}

#[cfg(test)]
Expand Down

0 comments on commit 205315b

Please sign in to comment.