Skip to content

Commit b0194f8

Browse files
committed
lint fixes, added github actions, Makefile
1 parent fea9cff commit b0194f8

7 files changed

Lines changed: 104 additions & 33 deletions

File tree

.github/workflows/format_check.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Rustfmt Check
2+
3+
on: [push]
4+
5+
env:
6+
CARGO_TERM_COLOR: always
7+
8+
jobs:
9+
lint:
10+
name: cargo fmt
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions-rust-lang/setup-rust-toolchain@v1
15+
with:
16+
components: rustfmt
17+
- name: Rustfmt Check
18+
uses: actions-rust-lang/rustfmt@v1
19+
- name: Machete
20+
uses: bnjbvr/cargo-machete@main
21+
- name: Clippy Check
22+
run: cargo clippy --benches --tests --bins --no-deps --all-features

.github/workflows/test_build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Building XML2RDF and testing
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * SAT'
6+
push:
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: actions-rust-lang/setup-rust-toolchain@v1
18+
with:
19+
toolchain: ${{ github.event.schedule == '' && 'stable' || 'nightly' }}
20+
cache: false
21+
22+
- name: Build
23+
run: cargo build --verbose
24+
25+
end-to-end:
26+
name: test
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: actions-rust-lang/setup-rust-toolchain@v1
31+
with:
32+
toolchain: ${{ github.event.schedule == '' && 'stable' || 'nightly' }}
33+
cache: false
34+
35+
- name: Run Rust integration tests
36+
run: cargo test
37+

Cargo.lock

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
clap = { version = "4.5.21", features = ["derive","cargo"] }
8-
convert_case = "0.6.0"
7+
clap = { version = "4.5.30", features = ["derive","cargo"] }
8+
convert_case = "0.7.1"
99
csv = "1.3.1"
10-
log = "0.4.22"
11-
oxrdf = "0.2.3"
12-
oxrdfio = "0.1.3"
10+
log = "0.4.25"
11+
oxrdf = "0.2.4"
12+
oxrdfio = "0.1.6"

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
lint:
3+
cargo install cargo-machete
4+
cargo fmt --check
5+
cargo machete
6+
cargo clippy --benches --tests --bins --no-deps --all-features
7+
8+
build:
9+
cargo build
10+
11+
test:
12+
cargo test
13+
14+
presubmit: lint test

src/convert.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use csv::ReaderBuilder;
1919
use log::error;
2020
use oxrdf::{NamedNode, TermRef, TripleRef};
2121

22-
const C2R: &'static str = "https://decisym.ai/csv2rdf/model#";
22+
const C2R: &str = "https://decisym.ai/csv2rdf/model#";
2323

2424
/// Converts CSV data to RDF format.
2525
///
@@ -58,9 +58,7 @@ pub fn parse_csv(
5858
};
5959

6060
for file in files.into_iter() {
61-
let mut rdr = ReaderBuilder::new()
62-
.has_headers(true)
63-
.from_path(file.to_string())?;
61+
let mut rdr = ReaderBuilder::new().has_headers(true).from_path(&file)?;
6462

6563
let mut headers: HashMap<i32, String> = HashMap::new();
6664
let mut column_index = 0;
@@ -86,7 +84,7 @@ pub fn parse_csv(
8684
row_id = field.trim().replace(" ", "");
8785
}
8886
// do not append empty cells
89-
else if field != "" {
87+
else if !field.is_empty() {
9088
let column_id = headers.get(&column_index).unwrap();
9189
let subject = NamedNode::new(format!("{}{}", ns, row_id)).unwrap();
9290
let predicate = NamedNode::new(format!("{}{}", C2R, column_id)).unwrap();

src/writer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ impl<'a> GraphWriter<'a> {
5858
}
5959
}
6060

61-
impl<'a> RdfWriter for GraphWriter<'a> {
61+
impl RdfWriter for GraphWriter<'_> {
6262
fn add_triple(&mut self, triple: TripleRef) -> std::io::Result<()> {
63-
self.graph.insert(triple.clone());
63+
self.graph.insert(triple);
6464
Ok(())
6565
}
6666
}

0 commit comments

Comments
 (0)