Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: removes some unused async #1090

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions modules/analysis/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ impl AnalysisService {
Ok(())
}

pub async fn clear_all_graphs(&self) -> Result<(), Error> {
pub fn clear_all_graphs(&self) -> Result<(), Error> {
let graph_manager = GraphMap::get_instance();
let mut manager = graph_manager.write();
manager.clear();
Expand All @@ -469,7 +469,7 @@ impl AnalysisService {
})
}

pub async fn query_ancestor_graph(
pub fn query_ancestor_graph(
component_name: Option<String>,
component_purl: Option<Purl>,
query: Option<Query>,
Expand Down Expand Up @@ -694,8 +694,7 @@ impl AnalysisService {
None,
Option::from(query),
distinct_sbom_ids,
)
.await;
);

Ok(paginated.paginate_array(&components))
}
Expand All @@ -717,8 +716,7 @@ impl AnalysisService {
None,
None,
distinct_sbom_ids,
)
.await;
);

let mut root_components = Vec::new();
for component in components {
Expand Down Expand Up @@ -764,8 +762,7 @@ impl AnalysisService {
None,
None,
distinct_sbom_ids,
)
.await;
);

Ok(paginated.paginate_array(&components))
}
Expand Down Expand Up @@ -801,8 +798,7 @@ impl AnalysisService {
Option::from(component_purl),
None,
distinct_sbom_ids,
)
.await;
);

Ok(paginated.paginate_array(&components))
}
Expand Down Expand Up @@ -1140,7 +1136,7 @@ mod test {
assert_eq!(analysis_status.sbom_count, 1);
assert_eq!(analysis_status.graph_count, 1);

let _clear_all_graphs = service.clear_all_graphs().await;
let _clear_all_graphs = service.clear_all_graphs();

ctx.ingest_documents([
"spdx/quarkus-bom-3.2.11.Final-redhat-00001.json",
Expand Down
6 changes: 3 additions & 3 deletions modules/fundamental/src/weakness/endpoints/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use zip::ZipArchive;
#[test_context(TrustifyContext)]
#[test(actix_web::test)]
async fn list_weaknesses(ctx: &TrustifyContext) -> Result<(), anyhow::Error> {
let zip = document_read("cwec_latest.xml.zip").await?;
let zip = document_read("cwec_latest.xml.zip")?;

let mut archive = ZipArchive::new(zip)?;

Expand All @@ -34,7 +34,7 @@ async fn list_weaknesses(ctx: &TrustifyContext) -> Result<(), anyhow::Error> {
#[test_context(TrustifyContext)]
#[test(actix_web::test)]
async fn query_weaknesses(ctx: &TrustifyContext) -> Result<(), anyhow::Error> {
let zip = document_read("cwec_latest.xml.zip").await?;
let zip = document_read("cwec_latest.xml.zip")?;

let mut archive = ZipArchive::new(zip)?;

Expand All @@ -58,7 +58,7 @@ async fn query_weaknesses(ctx: &TrustifyContext) -> Result<(), anyhow::Error> {
#[test_context(TrustifyContext)]
#[test(actix_web::test)]
async fn get_weakness(ctx: &TrustifyContext) -> Result<(), anyhow::Error> {
let zip = document_read("cwec_latest.xml.zip").await?;
let zip = document_read("cwec_latest.xml.zip")?;

let mut archive = ZipArchive::new(zip)?;

Expand Down
2 changes: 1 addition & 1 deletion modules/fundamental/tests/weakness/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async fn simple(ctx: &TrustifyContext) -> Result<(), anyhow::Error> {

// extract document from zip file

let zip = document_read("cwec_latest.xml.zip").await?;
let zip = document_read("cwec_latest.xml.zip")?;

let mut archive = ZipArchive::new(zip)?;

Expand Down
2 changes: 1 addition & 1 deletion modules/ingestor/src/service/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ mod test {
let spdx = document_bytes("ubi9-9.2-755.1697625012.json").await?;
assert!(matches!(Format::from_bytes(&spdx), Ok(Format::SPDX)));

let cwe = document_read("cwec_latest.xml.zip").await?;
let cwe = document_read("cwec_latest.xml.zip")?;
let mut cwe = ZipArchive::new(cwe)?;
let mut cwe = cwe.by_index(0)?;
let mut xml = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion modules/ingestor/src/service/weakness/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ mod test {
let graph = Graph::new(ctx.db.clone());
let loader = CweCatalogLoader::new(&graph);

let zip = document_read("cwec_latest.xml.zip").await?;
let zip = document_read("cwec_latest.xml.zip")?;

let mut archive = ZipArchive::new(zip)?;

Expand Down
2 changes: 1 addition & 1 deletion test-context/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub async fn document_stream(
}

/// Read a document from the test-data directory. Does not decompress.
pub async fn document_read(path: &str) -> Result<impl Read + Seek, anyhow::Error> {
pub fn document_read(path: &str) -> Result<impl Read + Seek, anyhow::Error> {
Ok(std::fs::File::open(absolute(path)?)?)
}

Expand Down
2 changes: 1 addition & 1 deletion xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl Xtask {
match self.command {
Command::Openapi(command) => command.run().await,
Command::GenerateDump(command) => command.run().await,
Command::GenerateSchemas(command) => command.run().await,
Command::GenerateSchemas(command) => command.run(),
Command::Precommit(command) => command.run().await,
Command::Ai(command) => command.run().await,
}
Expand Down
3 changes: 1 addition & 2 deletions xtask/src/precommit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ impl Precommit {
GenerateSchema {
base: Path::new(".").to_path_buf(),
}
.run()
.await?;
.run()?;

Openapi::default().run().await?;

Expand Down
2 changes: 1 addition & 1 deletion xtask/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct GenerateSchema {
}

impl GenerateSchema {
pub async fn run(self) -> anyhow::Result<()> {
pub fn run(self) -> anyhow::Result<()> {
// write schema
self.write_schema::<Instructions>("xtask/schema/generate-dump.json")?;
self.write_schema::<AuthConfig>("common/auth/schema/auth.json")?;
Expand Down
Loading