diff --git a/.github/workflows/clippy.yaml b/.github/workflows/clippy.yaml new file mode 100644 index 0000000..3320f5f --- /dev/null +++ b/.github/workflows/clippy.yaml @@ -0,0 +1,24 @@ + +name: Clippy +on: + push: + branches: [ main ] + pull_request: + workflow_dispatch: + +jobs: + test: + name: Clippy + runs-on: ubuntu-20.04 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libayatana-appindicator3-dev librsvg2-dev + + - name: Static Analysis (Clippy) + working-directory: src-tauri + run: cargo clippy \ No newline at end of file diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index d589cdb..9410405 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -28,7 +28,6 @@ async fn list(config: tauri::State<'_, Config>) -> std::result::Result return Ok(note_names), Err(e) => error_handling(e.to_string()) } - Ok(Vec::::new()) } @@ -42,21 +41,19 @@ fn get_note_names(base_path: PathBuf) -> Result> { Err(e) => error_handling(e.to_string()) } } - return Ok(note_names) + Ok(note_names) } /// check if the `dir_entry` contains a `README.md` file inside and returns the folder name if so fn get_note_name(dir_entry: Result) -> Result { let dir_entry = dir_entry?; - if dir_entry.file_type()?.is_dir() { - if Path::new(&dir_entry.path()).join("README.md").is_file() { - return Ok(dir_entry.file_name().into_string().unwrap()); - } + if dir_entry.file_type()?.is_dir() && Path::new(&dir_entry.path()).join("README.md").is_file() { + return Ok(dir_entry.file_name().into_string().unwrap()); } - return Err( + Err( Error::new( std::io::ErrorKind::NotFound, - format!("README.md not found for `{}`.", dir_entry.path().to_str().unwrap().to_string()) + format!("README.md not found for `{}`.", dir_entry.path().to_str().unwrap()) ) ) }