Skip to content

Commit 780eff4

Browse files
authored
exp (#915)
1 parent b8ccce1 commit 780eff4

13 files changed

+39
-64
lines changed

aderyn_core/src/detect/detector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub fn get_all_detectors_names() -> Vec<String> {
113113
// Note to maintainers: DO NOT CHANGE THE ORDER OF THESE DERIVE ATTRIBUTES
114114
#[derive(Debug, PartialEq, EnumString, Display)]
115115
#[strum(serialize_all = "kebab-case")]
116-
pub(crate) enum IssueDetectorNamePool {
116+
pub enum IssueDetectorNamePool {
117117
IncorrectUseOfModifier,
118118
ReentrancyStateChange,
119119
StateVariableCouldBeImmutable,

aderyn_core/src/detect/experimental/mod.rs

-7
This file was deleted.

aderyn_core/src/detect/low/empty_block.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,13 @@ impl IssueDetector for EmptyBlockDetector {
7676
#[cfg(test)]
7777
mod empty_block_tests {
7878

79-
use crate::detect::{
80-
detector::IssueDetector,
81-
test_utils::{load_solidity_source_unit, take_loader_lock},
82-
};
79+
use crate::detect::{detector::IssueDetector, test_utils::load_solidity_source_unit};
8380

8481
use super::EmptyBlockDetector;
8582

8683
#[test]
8784

8885
fn test_empty_block_by_loading_contract_directly() {
89-
let _lock = take_loader_lock();
9086
let context = load_solidity_source_unit("../tests/contract-playground/src/EmptyBlocks.sol");
9187

9288
let mut detector = EmptyBlockDetector::default();

aderyn_core/src/detect/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
pub mod detector;
2-
pub(crate) mod experimental;
32
pub mod helpers;
43
pub mod high;
54
pub mod low;
65
pub mod report;
76

8-
#[cfg(test)]
97
pub mod test_utils;
108

119
#[macro_export]

aderyn_core/src/detect/test_utils/load_source_unit.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
#[cfg(test)]
2-
use crate::context::graph::{Transpose, WorkspaceCallGraph};
31
use crate::{
4-
ast::SourceUnit, context::workspace_context::WorkspaceContext, visitor::ast_visitor::Node,
2+
ast::SourceUnit,
3+
context::{
4+
graph::{Transpose, WorkspaceCallGraph},
5+
workspace_context::WorkspaceContext,
6+
},
7+
visitor::ast_visitor::Node,
58
};
69
use semver::Version;
710
use solidity_ast::{

aderyn_core/src/detect/test_utils/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
mod load_source_unit;
22

3-
use once_cell::sync::Lazy;
43
use std::path::PathBuf;
54

65
// Using `solc` to read AST given a source unit (i.e Solidity file)
76
pub use load_source_unit::{
87
load_multiple_solidity_source_units_into_single_context, load_solidity_source_unit,
98
};
109

11-
pub(crate) fn take_loader_lock() -> impl Drop {
12-
static LOCK: Lazy<std::sync::Mutex<()>> = Lazy::new(|| std::sync::Mutex::new(()));
13-
LOCK.lock().unwrap()
14-
}
15-
1610
fn ensure_valid_solidity_file(filepath: &str) -> PathBuf {
1711
let filepath = PathBuf::from(filepath);
1812

aderyn_core/src/detect/experimental/ancestral_line.rs renamed to aderyn_core/tests/ancestral_line.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(clippy::collapsible_match)]
22
use std::{collections::BTreeMap, error::Error};
33

4-
use crate::{
4+
use aderyn_core::{
55
ast::NodeID,
66
capture,
77
context::{
@@ -90,14 +90,12 @@ impl IssueDetector for AncestralLineDemonstrator {
9090

9191
#[cfg(test)]
9292
mod ancestral_line_demo_tests {
93-
use crate::detect::{
94-
detector::IssueDetector, experimental::ancestral_line::AncestralLineDemonstrator,
95-
};
93+
use super::*;
94+
use aderyn_core::detect::{detector::IssueDetector, test_utils::load_solidity_source_unit};
9695

9796
#[test]
98-
9997
fn test_ancestral_line_demo() {
100-
let context = crate::detect::test_utils::load_solidity_source_unit(
98+
let context = load_solidity_source_unit(
10199
"../tests/contract-playground/src/parent_chain/ParentChainContract.sol",
102100
);
103101

aderyn_core/src/detect/experimental/closest_ancestor.rs renamed to aderyn_core/tests/closest_ancestor.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(clippy::collapsible_match)]
22
use std::{collections::BTreeMap, error::Error};
33

4-
use crate::{
4+
use aderyn_core::{
55
ast::{NodeID, NodeType},
66
capture,
77
context::{
@@ -74,14 +74,13 @@ impl IssueDetector for ClosestAncestorDemonstrator {
7474

7575
#[cfg(test)]
7676
mod closest_ancestor_demo_tests {
77-
use crate::detect::{
78-
detector::IssueDetector, experimental::closest_ancestor::ClosestAncestorDemonstrator,
79-
};
77+
use super::*;
78+
use aderyn_core::detect::{detector::IssueDetector, test_utils::load_solidity_source_unit};
8079

8180
#[test]
8281

8382
fn test_closest_ancestor() {
84-
let context = crate::detect::test_utils::load_solidity_source_unit(
83+
let context = load_solidity_source_unit(
8584
"../tests/contract-playground/src/parent_chain/ParentChainContract.sol",
8685
);
8786

aderyn_core/src/detect/experimental/immediate_children.rs renamed to aderyn_core/tests/immediate_children.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(clippy::collapsible_match)]
22
use std::{collections::BTreeMap, error::Error};
33

4-
use crate::{
4+
use aderyn_core::{
55
ast::{NodeID, NodeType},
66
capture,
77
context::{browser::GetImmediateChildren, workspace_context::WorkspaceContext},
@@ -74,14 +74,13 @@ impl IssueDetector for ImmediateChildrenDemonstrator {
7474

7575
#[cfg(test)]
7676
mod child_chain_demo_tests {
77-
use crate::detect::{
78-
detector::IssueDetector, experimental::immediate_children::ImmediateChildrenDemonstrator,
79-
};
77+
use super::*;
78+
use aderyn_core::detect::test_utils::load_solidity_source_unit;
8079

8180
#[test]
8281

8382
fn test_immediate_child_demo() {
84-
let context = crate::detect::test_utils::load_solidity_source_unit(
83+
let context = load_solidity_source_unit(
8584
"../tests/contract-playground/src/parent_chain/ParentChainContract.sol",
8685
);
8786

aderyn_core/src/detect/experimental/immediate_parent.rs renamed to aderyn_core/tests/immediate_parent.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(clippy::collapsible_match)]
22
use std::{collections::BTreeMap, error::Error};
33

4-
use crate::{
4+
use aderyn_core::{
55
ast::NodeID,
66
capture,
77
context::{
@@ -91,14 +91,13 @@ impl IssueDetector for ImmediateParentDemonstrator {
9191

9292
#[cfg(test)]
9393
mod parent_chain_demo_tests {
94-
use crate::detect::{
95-
detector::IssueDetector, experimental::immediate_parent::ImmediateParentDemonstrator,
96-
};
94+
use super::*;
95+
use aderyn_core::detect::test_utils::load_solidity_source_unit;
9796

9897
#[test]
9998

10099
fn test_immediate_parent_demo() {
101-
let context = crate::detect::test_utils::load_solidity_source_unit(
100+
let context = load_solidity_source_unit(
102101
"../tests/contract-playground/src/parent_chain/ParentChainContract.sol",
103102
);
104103

aderyn_core/src/detect/experimental/new_ast_nodes_test.rs renamed to aderyn_core/tests/new_ast_nodes.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{collections::BTreeMap, error::Error};
22

3-
use crate::{
3+
use aderyn_core::{
44
ast::NodeID,
55
capture,
66
context::workspace_context::WorkspaceContext,
@@ -59,16 +59,13 @@ impl IssueDetector for NewASTNodesDemonstrator {
5959

6060
#[cfg(test)]
6161
mod new_ast_nodes_demonstrator_tests {
62-
use crate::detect::{
63-
detector::IssueDetector, experimental::new_ast_nodes_test::NewASTNodesDemonstrator,
64-
};
62+
use super::*;
63+
use aderyn_core::detect::test_utils::load_solidity_source_unit;
6564

6665
#[test]
6766

6867
fn test_new_ast_nodes() {
69-
let context = crate::detect::test_utils::load_solidity_source_unit(
70-
"../tests/adhoc-sol-files/DemoASTNodes.sol",
71-
);
68+
let context = load_solidity_source_unit("../tests/adhoc-sol-files/DemoASTNodes.sol");
7269

7370
let mut detector = NewASTNodesDemonstrator::default();
7471
let _ = detector.detect(&context).unwrap();

aderyn_core/src/detect/experimental/peek_over.rs renamed to aderyn_core/tests/peek_over.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{collections::BTreeMap, error::Error};
22

3-
use crate::{
3+
use aderyn_core::{
44
ast::NodeID,
55
capture,
66
context::{browser::PeekOver, workspace_context::WorkspaceContext},
@@ -53,14 +53,14 @@ impl IssueDetector for PeekOverDemonstrator {
5353

5454
#[cfg(test)]
5555
mod peek_over_demonstrator_tests {
56-
use crate::detect::{detector::IssueDetector, experimental::peek_over::PeekOverDemonstrator};
56+
use aderyn_core::detect::test_utils::load_solidity_source_unit;
57+
58+
use super::*;
5759

5860
#[test]
5961
fn test_peek_over() {
60-
let context = crate::detect::test_utils::load_solidity_source_unit(
61-
"../tests/contract-playground/src/StorageConditionals.sol",
62-
);
63-
62+
let context =
63+
load_solidity_source_unit("../tests/contract-playground/src/StorageConditionals.sol");
6464
let mut detector = PeekOverDemonstrator::default();
6565
let _ = detector.detect(&context).unwrap();
6666

aderyn_core/src/detect/experimental/sibling.rs renamed to aderyn_core/tests/sibling.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{collections::BTreeMap, error::Error};
22

3-
use crate::{
3+
use aderyn_core::{
44
ast::NodeID,
55
capture,
66
context::{
@@ -59,14 +59,13 @@ impl IssueDetector for SiblingDemonstrator {
5959

6060
#[cfg(test)]
6161
mod sibling_demo_tests {
62-
63-
use crate::detect::{detector::IssueDetector, experimental::sibling::SiblingDemonstrator};
62+
use super::*;
63+
use aderyn_core::detect::test_utils::load_solidity_source_unit;
6464

6565
#[test]
6666
fn test_siblings() {
67-
let context = crate::detect::test_utils::load_solidity_source_unit(
68-
"../tests/contract-playground/src/StorageConditionals.sol",
69-
);
67+
let context =
68+
load_solidity_source_unit("../tests/contract-playground/src/StorageConditionals.sol");
7069

7170
let mut detector = SiblingDemonstrator::default();
7271
let _ = detector.detect(&context).unwrap();

0 commit comments

Comments
 (0)