Skip to content

Commit

Permalink
add: pre-commit, temporarily suppress clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jsfpdn committed Mar 2, 2024
1 parent 29d82e7 commit 77bfee8
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: cargo fmt --check
check:
name: cargo check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cargo check
clippy:
name: Clippy
runs-on: ubuntu-latest
Expand Down
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
repos:
- repo: local
hooks:
- id: fmt
name: cargo fmt --check
description: Check formatting of files with cargo fmt
language: rust
entry: cargo fmt --check --
files: \.rs$
args: []
- id: check
name: cargo check
description: Check package and dependencies for errors
language: rust
entry: cargo check
files: \.rs$
pass_filenames: false
- id: clippy
name: cargo clippy
description: Lint with Clippy
language: rust
entry: cargo clippy --all-features --tests --benches -- -Dclippy::all -Dclippy::pedantic
files: \.rs$
pass_filenames: false
- id: test
name: cargo test
description: Run unit tests
language: rust
entry: cargo test
files: \.rs$
pass_filenames: false
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
# sdd-rs

Bottom-up sentential decision diagram compiler.

## Development

Run all tests and linters with [pre-commit](https://pre-commit.com) before committing.

```bash
# Install pre-commit: https://pre-commit.com/#install
brew install pre-commit

# Set-up pre-commit
pre-commit install

# Run all hooks
pre-commit run --all-files
```
4 changes: 2 additions & 2 deletions src/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pub struct VarLabel(u64);

impl VarLabel {
#[must_use]
pub fn new(vl: u64) -> VarLabel {
VarLabel(vl)
pub fn new(v: u64) -> VarLabel {
VarLabel(v)
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ use crate::vtree::VTreeManager;

#[allow(clippy::module_name_repetitions)]
pub struct SddManager {
// TODO: Remove all #[allow(unused)] directives.
#[allow(unused)]
options: SddOptions,

#[allow(unused)]
vtree_manager: VTreeManager,

#[allow(unused)]
var_label_manager: VarLabelManager,

// Unique table holding all the decision nodes.
Expand Down
4 changes: 4 additions & 0 deletions src/sdd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@ impl Sdd {
self.is_true() || self.is_false()
}

#[allow(dead_code)]
fn is_literal(&self) -> bool {
matches!(self, Sdd::Literal(_))
}

#[allow(dead_code)]
fn is_decision_node(&self) -> bool {
matches!(self, Sdd::Decision(_)) || matches!(self, Sdd::DecisionCompl(_))
}

#[allow(dead_code)]
fn is_element_node(&self) -> bool {
matches!(self, Sdd::Element(_)) || matches!(self, Sdd::ElementCompl(_))
}
Expand All @@ -73,6 +76,7 @@ impl Sdd {
}
}

#[allow(dead_code)]
fn as_decision(&self) -> &SddOr {
match self {
Sdd::Decision(decision) | Sdd::DecisionCompl(decision) => decision,
Expand Down
7 changes: 7 additions & 0 deletions src/vtree.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
pub struct VTree {
// TODO: Search states, shadow vtree.
// To save implementation time, don't do fancy rollback (at least in the beginning).
#[allow(dead_code)]
left: Option<Box<VTree>>,

#[allow(dead_code)]
right: Option<Box<VTree>>,
}

Expand Down Expand Up @@ -44,9 +47,13 @@ impl VTree {
}

pub struct VTreeManager {
#[allow(dead_code)]
root: Option<VTree>,

#[allow(dead_code)]
dfs_to_bfs: Vec<u64>,

#[allow(dead_code)]
bfs_to_dfs: Vec<u64>,
}

Expand Down

0 comments on commit 77bfee8

Please sign in to comment.