Skip to content

Commit

Permalink
Merge pull request #15 from falk-werner/feature/clippy
Browse files Browse the repository at this point in the history
Feature: Add clippy workflow to perform static code analysis
  • Loading branch information
falk-werner authored Jan 27, 2024
2 parents 7ee0af8 + d88bc3b commit 30ccf6c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/clippy.yaml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 5 additions & 8 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ async fn list(config: tauri::State<'_, Config>) -> std::result::Result<Vec<Strin
Ok(note_names) => return Ok(note_names),
Err(e) => error_handling(e.to_string())
}

Ok(Vec::<String>::new())
}

Expand All @@ -42,21 +41,19 @@ fn get_note_names(base_path: PathBuf) -> Result<Vec<String>> {
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<DirEntry>) -> Result<String> {
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())
)
)
}
Expand Down

0 comments on commit 30ccf6c

Please sign in to comment.