Skip to content

Commit 89a8cbc

Browse files
author
Paolo Tranquilli
committed
Rust: use shared path utilities
1 parent aae33db commit 89a8cbc

File tree

5 files changed

+7
-32
lines changed

5 files changed

+7
-32
lines changed

rust/extractor/src/archive.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::path;
1+
use codeql_extractor::file_paths;
22
use log::{debug, warn};
33
use std::fs;
44
use std::path::{Path, PathBuf};
@@ -15,12 +15,11 @@ impl Archiver {
1515
}
1616

1717
fn try_archive(&self, source: &Path) -> std::io::Result<()> {
18-
let mut dest = self.root.clone();
19-
dest.push(path::key(source));
20-
let parent = dest.parent().unwrap();
18+
let dest = file_paths::path_for(&self.root, source, "");
2119
if fs::metadata(&dest).is_ok() {
2220
return Ok(());
2321
}
22+
let parent = dest.parent().unwrap();
2423
fs::create_dir_all(parent)?;
2524
fs::copy(source, dest)?;
2625
debug!("archived {}", source.display());

rust/extractor/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use std::path::PathBuf;
1111
mod archive;
1212
mod config;
1313
pub mod generated;
14-
pub mod path;
1514
mod translate;
1615
pub mod trap;
1716

rust/extractor/src/path.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

rust/extractor/src/trap.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
use crate::config;
12
use crate::config::Compression;
2-
use crate::{config, path};
3-
use codeql_extractor::{extractor, trap};
3+
use codeql_extractor::{extractor, file_paths, trap};
44
use log::debug;
55
use ra_ap_ide_db::line_index::LineCol;
6-
use std::ffi::OsString;
76
use std::fmt::Debug;
87
use std::hash::Hash;
98
use std::marker::PhantomData;
@@ -12,7 +11,6 @@ use std::path::{Path, PathBuf};
1211
pub use trap::Label as UntypedLabel;
1312
pub use trap::Writer;
1413

15-
//TODO: typed labels
1614
pub trait AsTrapKeyPart {
1715
fn as_key_part(&self) -> String;
1816
}
@@ -210,19 +208,8 @@ impl TrapFileProvider {
210208
}
211209

212210
pub fn create(&self, category: &str, key: &Path) -> TrapFile {
213-
let mut path = PathBuf::from(category);
214-
path.push(path::key(key));
215-
path.set_extension(
216-
path.extension()
217-
.map(|e| {
218-
let mut o: OsString = e.to_owned();
219-
o.push(".trap");
220-
o
221-
})
222-
.unwrap_or("trap".into()),
223-
);
211+
let path = file_paths::path_for(&self.trap_dir.join(category), key, ".trap");
224212
debug!("creating trap file {}", path.display());
225-
path = self.trap_dir.join(path);
226213
let mut writer = trap::Writer::new();
227214
extractor::populate_empty_location(&mut writer);
228215
TrapFile {

rust/lint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
fmt = subprocess.run([cargo, "fmt", "--all", "--quiet"], cwd=this_dir)
1414
for manifest in this_dir.rglob("Cargo.toml"):
15-
if not manifest.is_relative_to(this_dir / "ql"):
15+
if not manifest.is_relative_to(this_dir / "ql") and not manifest.is_relative_to(this_dir / "integration-tests"):
1616
clippy = subprocess.run([cargo, "clippy", "--fix", "--allow-dirty", "--allow-staged", "--quiet"],
1717
cwd=manifest.parent)
1818
sys.exit(fmt.returncode or clippy.returncode)

0 commit comments

Comments
 (0)