diff --git a/aderyn_driver/src/driver.rs b/aderyn_driver/src/driver.rs index da79c75c..594fa57e 100644 --- a/aderyn_driver/src/driver.rs +++ b/aderyn_driver/src/driver.rs @@ -76,7 +76,7 @@ pub fn drive_and_get_results(args: Args) -> Arc>> { if let Ok(report) = get_report(&cx_wrapper.contexts, &root_rel_path, detectors) { let high_issues = report.high_issues(&file_contents); let low_issues = report.low_issues(&file_contents); - let lsp_result = LspReport::from(low_issues, high_issues, args); + let lsp_result = LspReport::from(low_issues, high_issues, &root_rel_path); return Arc::new(tokio::sync::Mutex::new(Some(lsp_result))); } diff --git a/aderyn_driver/src/lsp_report.rs b/aderyn_driver/src/lsp_report.rs index 1c3bf9e9..91ead673 100644 --- a/aderyn_driver/src/lsp_report.rs +++ b/aderyn_driver/src/lsp_report.rs @@ -1,10 +1,7 @@ -use std::{collections::BTreeMap, path::PathBuf}; - use aderyn_core::report::{HighIssues, IssueBody, IssueInstance, LowIssues}; +use std::{collections::BTreeMap, path::PathBuf}; use tower_lsp::lsp_types::{Diagnostic, DiagnosticSeverity, Position, Range, Url}; -use crate::driver::Args; - /// Report structure that is tailored to aid LSP pub struct LspReport { pub high_issues: HighIssues, @@ -13,12 +10,12 @@ pub struct LspReport { } impl LspReport { - pub fn from(low_issues: LowIssues, high_issues: HighIssues, args: Args) -> Self { + pub fn from(low_issues: LowIssues, high_issues: HighIssues, root_rel_path: &PathBuf) -> Self { fn create_diagnostic_from_issue( - args: &Args, issue_body: &IssueBody, instance: &IssueInstance, severity: DiagnosticSeverity, + root_rel_path: &PathBuf, ) -> Option<(Url, Diagnostic)> { // Line number let line_no = instance.line_no.checked_sub(1)?; @@ -62,10 +59,9 @@ impl LspReport { tags: None, data: None, }; - let mut full_contract_path = PathBuf::from(args.root.clone()); + let mut full_contract_path = root_rel_path.clone(); full_contract_path.push(instance.contract_path.clone()); let full_contract_path = full_contract_path.canonicalize().ok()?; - let full_contract_path_string = full_contract_path.to_string_lossy().to_string(); let file_uri = Url::parse(&format!("file://{}", &full_contract_path_string)).ok()?; @@ -77,10 +73,10 @@ impl LspReport { for issue_body in &high_issues.issues { for instance in &issue_body.instances { let Some((file_url, diagnostic)) = create_diagnostic_from_issue( - &args, issue_body, instance, DiagnosticSeverity::WARNING, + root_rel_path, ) else { continue; }; @@ -94,10 +90,10 @@ impl LspReport { for issue_body in &low_issues.issues { for instance in &issue_body.instances { let Some((file_url, diagnostic)) = create_diagnostic_from_issue( - &args, issue_body, instance, DiagnosticSeverity::INFORMATION, + root_rel_path, ) else { continue; };