From a2f0a07cdb556177e534fa5bf2d5ac0a2c4822f0 Mon Sep 17 00:00:00 2001 From: Helio Frota <00hf11@gmail.com> Date: Mon, 9 Dec 2024 16:31:54 -0300 Subject: [PATCH] chore: removes some unused async --- modules/analysis/src/service.rs | 18 +++++++----------- .../fundamental/src/weakness/endpoints/test.rs | 6 +++--- modules/fundamental/tests/weakness/mod.rs | 2 +- modules/ingestor/src/service/format.rs | 2 +- modules/ingestor/src/service/weakness/mod.rs | 2 +- test-context/src/lib.rs | 2 +- xtask/src/main.rs | 2 +- xtask/src/precommit.rs | 3 +-- xtask/src/schema.rs | 2 +- 9 files changed, 17 insertions(+), 22 deletions(-) diff --git a/modules/analysis/src/service.rs b/modules/analysis/src/service.rs index 90268e930..3d4efab34 100644 --- a/modules/analysis/src/service.rs +++ b/modules/analysis/src/service.rs @@ -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(); @@ -469,7 +469,7 @@ impl AnalysisService { }) } - pub async fn query_ancestor_graph( + pub fn query_ancestor_graph( component_name: Option, component_purl: Option, query: Option, @@ -694,8 +694,7 @@ impl AnalysisService { None, Option::from(query), distinct_sbom_ids, - ) - .await; + ); Ok(paginated.paginate_array(&components)) } @@ -717,8 +716,7 @@ impl AnalysisService { None, None, distinct_sbom_ids, - ) - .await; + ); let mut root_components = Vec::new(); for component in components { @@ -764,8 +762,7 @@ impl AnalysisService { None, None, distinct_sbom_ids, - ) - .await; + ); Ok(paginated.paginate_array(&components)) } @@ -801,8 +798,7 @@ impl AnalysisService { Option::from(component_purl), None, distinct_sbom_ids, - ) - .await; + ); Ok(paginated.paginate_array(&components)) } @@ -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", diff --git a/modules/fundamental/src/weakness/endpoints/test.rs b/modules/fundamental/src/weakness/endpoints/test.rs index 7ca4423cd..87a8b5f13 100644 --- a/modules/fundamental/src/weakness/endpoints/test.rs +++ b/modules/fundamental/src/weakness/endpoints/test.rs @@ -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)?; @@ -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)?; @@ -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)?; diff --git a/modules/fundamental/tests/weakness/mod.rs b/modules/fundamental/tests/weakness/mod.rs index 1119e6ec0..acb166bcc 100644 --- a/modules/fundamental/tests/weakness/mod.rs +++ b/modules/fundamental/tests/weakness/mod.rs @@ -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)?; diff --git a/modules/ingestor/src/service/format.rs b/modules/ingestor/src/service/format.rs index eed018026..5f79e4b9f 100644 --- a/modules/ingestor/src/service/format.rs +++ b/modules/ingestor/src/service/format.rs @@ -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(); diff --git a/modules/ingestor/src/service/weakness/mod.rs b/modules/ingestor/src/service/weakness/mod.rs index beceb66a4..2ccfc8a0d 100644 --- a/modules/ingestor/src/service/weakness/mod.rs +++ b/modules/ingestor/src/service/weakness/mod.rs @@ -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)?; diff --git a/test-context/src/lib.rs b/test-context/src/lib.rs index 3a4f2099a..3b1ff9b26 100644 --- a/test-context/src/lib.rs +++ b/test-context/src/lib.rs @@ -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 { +pub fn document_read(path: &str) -> Result { Ok(std::fs::File::open(absolute(path)?)?) } diff --git a/xtask/src/main.rs b/xtask/src/main.rs index fec0b89b5..2beb730c0 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -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, } diff --git a/xtask/src/precommit.rs b/xtask/src/precommit.rs index 47f6a8099..43bd5c4eb 100644 --- a/xtask/src/precommit.rs +++ b/xtask/src/precommit.rs @@ -13,8 +13,7 @@ impl Precommit { GenerateSchema { base: Path::new(".").to_path_buf(), } - .run() - .await?; + .run()?; Openapi::default().run().await?; diff --git a/xtask/src/schema.rs b/xtask/src/schema.rs index 3b20e925a..8fdad44e0 100644 --- a/xtask/src/schema.rs +++ b/xtask/src/schema.rs @@ -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::("xtask/schema/generate-dump.json")?; self.write_schema::("common/auth/schema/auth.json")?;