Skip to content
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
1 change: 0 additions & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ resolver = "2"
[workspace.dependencies]
thiserror = "1.0"
anyhow = "1.0"
lazy_static = { version = "1.5", default-features = false }
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = { version = "1.0", default-features = false, features = ["std"] }
serde_yml = "0.0"
Expand Down
1 change: 0 additions & 1 deletion rust/bear/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ path = "src/bin/wrapper.rs"
[dependencies]
thiserror.workspace = true
anyhow.workspace = true
lazy_static.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_yml.workspace = true
Expand Down
12 changes: 6 additions & 6 deletions rust/bear/src/semantic/interpreters/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ impl Interpreter for Gcc {
}

mod internal {
use lazy_static::lazy_static;
use nom::{error::ErrorKind, IResult};
use regex::Regex;
use std::path::PathBuf;
Expand Down Expand Up @@ -194,16 +193,17 @@ mod internal {
todo!()
}

lazy_static! {
static COMPILER_REGEX: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
// - cc
// - c++
// - cxx
// - CC
// - mcc, gcc, m++, g++, gfortran, fortran
// - with prefixes like: arm-none-eabi-
// - with postfixes like: -7.0 or 6.4.0
static ref COMPILER_REGEX: Regex = Regex::new(
r"(^(cc|c\+\+|cxx|CC|(([^-]*-)*([mg](cc|\+\+)|[g]?fortran)(-?\d+(\.\d+){0,2})?))$)"
).unwrap();
}
Regex::new(
r"(^(cc|c\+\+|cxx|CC|(([^-]*-)*([mg](cc|\+\+)|[g]?fortran)(-?\d+(\.\d+){0,2})?))$)",
)
.unwrap()
});
}
10 changes: 3 additions & 7 deletions rust/bear/src/semantic/interpreters/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ impl Interpreter for Generic {
mod test {
use std::collections::HashMap;

use lazy_static::lazy_static;

use crate::{vec_of_pathbuf, vec_of_strings};

use super::*;
Expand Down Expand Up @@ -126,9 +124,7 @@ mod test {
assert_eq!(Recognition::Unknown, SUT.recognize(&input));
}

lazy_static! {
static ref SUT: Generic = Generic {
executables: vec_of_pathbuf!["/usr/bin/something"].into_iter().collect()
};
}
static SUT: std::sync::LazyLock<Generic> = std::sync::LazyLock::new(|| Generic {
executables: vec_of_pathbuf!["/usr/bin/something"].into_iter().collect(),
});
}
66 changes: 32 additions & 34 deletions rust/bear/src/semantic/interpreters/matchers/source.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-or-later

use lazy_static::lazy_static;
use std::collections::HashSet;

#[cfg(target_family = "unix")]
Expand All @@ -27,39 +26,38 @@ pub fn looks_like_a_source_file(argument: &str) -> bool {
false
}

lazy_static! {
static ref EXTENSIONS: HashSet<&'static str> = {
HashSet::from([
// header files
"h", "hh", "H", "hp", "hxx", "hpp", "HPP", "h++", "tcc",
// C
"c", "C",
// C++
"cc", "CC", "c++", "C++", "cxx", "cpp", "cp",
// CUDA
"cu",
// ObjectiveC
"m", "mi", "mm", "M", "mii",
// Preprocessed
"i", "ii",
// Assembly
"s", "S", "sx", "asm",
// Fortran
"f", "for", "ftn",
"F", "FOR", "fpp", "FPP", "FTN",
"f90", "f95", "f03", "f08",
"F90", "F95", "F03", "F08",
// go
"go",
// brig
"brig",
// D
"d", "di", "dd",
// Ada
"ads", "abd"
])
};
}
#[rustfmt::skip]
static EXTENSIONS: std::sync::LazyLock<HashSet<&'static str>> = std::sync::LazyLock::new(|| {
HashSet::from([
// header files
"h", "hh", "H", "hp", "hxx", "hpp", "HPP", "h++", "tcc",
// C
"c", "C",
// C++
"cc", "CC", "c++", "C++", "cxx", "cpp", "cp",
// CUDA
"cu",
// ObjectiveC
"m", "mi", "mm", "M", "mii",
// Preprocessed
"i", "ii",
// Assembly
"s", "S", "sx", "asm",
// Fortran
"f", "for", "ftn",
"F", "FOR", "fpp", "FPP", "FTN",
"f90", "f95", "f03", "f08",
"F90", "F95", "F03", "F08",
// go
"go",
// brig
"brig",
// D
"d", "di", "dd",
// Ada
"ads", "abd",
])
});

#[cfg(test)]
mod test {
Expand Down
13 changes: 7 additions & 6 deletions rust/bear/tests/intercept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use bear::intercept::*;
mod test {
use super::*;
use crossbeam_channel::bounded;
use lazy_static::lazy_static;
use std::collections::HashMap;
use std::io::Cursor;
use std::path::PathBuf;
Expand Down Expand Up @@ -77,8 +76,8 @@ mod test {
}
}

lazy_static! {
static ref ENVELOPES: Vec<Envelope> = vec![
static ENVELOPES: std::sync::LazyLock<Vec<Envelope>> = std::sync::LazyLock::new(|| {
vec![
Envelope {
rid: ReporterId::new(),
timestamp: fixtures::timestamp(),
Expand Down Expand Up @@ -124,9 +123,11 @@ mod test {
},
},
},
];
static ref EVENTS: Vec<Event> = ENVELOPES.iter().map(|e| e.event.clone()).collect();
}
]
});

static EVENTS: std::sync::LazyLock<Vec<Event>> =
std::sync::LazyLock::new(|| ENVELOPES.iter().map(|e| e.event.clone()).collect());
}

mod fixtures {
Expand Down
Loading