Skip to content

Commit 33670c5

Browse files
committed
Remove unnecessary mutability
Signed-off-by: Jim Crossley <[email protected]>
1 parent c403fe2 commit 33670c5

File tree

8 files changed

+19
-35
lines changed

8 files changed

+19
-35
lines changed

modules/importer/src/runner/clearly_defined_curation/handler.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ where
2424
{
2525
type Error = Error;
2626

27-
fn process(
28-
&mut self,
29-
path: &Path,
30-
relative_path: &Path,
31-
) -> Result<(), HandlerError<Self::Error>> {
27+
fn process(&self, path: &Path, relative_path: &Path) -> Result<(), HandlerError<Self::Error>> {
3228
if let Some(head) = relative_path.components().next() {
3329
if let Some(head) = head.as_os_str().to_str() {
3430
if self.types.iter().any(|e| e.matches(head)) {
@@ -58,7 +54,7 @@ impl<C> ClearlyDefinedHandler<C>
5854
where
5955
C: Callbacks<Vec<u8>> + Send + 'static,
6056
{
61-
fn process_file(&mut self, path: &Path, rel_path: &Path) -> Result<(), ProcessingError> {
57+
fn process_file(&self, path: &Path, rel_path: &Path) -> Result<(), ProcessingError> {
6258
let curation = match path.extension().map(|s| s.to_string_lossy()).as_deref() {
6359
Some("yaml") => {
6460
let mut bytes = Vec::new();

modules/importer/src/runner/clearly_defined_curation/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ impl<C: RunContext> Context<C> {
5252
}
5353

5454
impl<C: RunContext> Callbacks<Vec<u8>> for Context<C> {
55-
fn loading_error(&mut self, path: PathBuf, message: String) {
55+
fn loading_error(&self, path: PathBuf, message: String) {
5656
self.report
5757
.lock()
5858
.add_error(Phase::Validation, path.to_string_lossy(), message);
5959
}
6060

61-
fn process(&mut self, path: &Path, curation: Vec<u8>) -> Result<(), CallbackError> {
61+
fn process(&self, path: &Path, curation: Vec<u8>) -> Result<(), CallbackError> {
6262
if let Err(err) = self.store(path, curation) {
6363
self.report
6464
.lock()

modules/importer/src/runner/common/walker/git.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,13 @@ pub enum HandlerError<T> {
2727
pub trait Handler: Send + 'static {
2828
type Error: Display + Debug;
2929

30-
fn process(
31-
&mut self,
32-
path: &Path,
33-
relative_path: &Path,
34-
) -> Result<(), HandlerError<Self::Error>>;
30+
fn process(&self, path: &Path, relative_path: &Path) -> Result<(), HandlerError<Self::Error>>;
3531
}
3632

3733
impl Handler for () {
3834
type Error = Infallible;
3935

40-
fn process(&mut self, _: &Path, _: &Path) -> Result<(), HandlerError<Self::Error>> {
36+
fn process(&self, _: &Path, _: &Path) -> Result<(), HandlerError<Self::Error>> {
4137
Ok(())
4238
}
4339
}
@@ -173,12 +169,12 @@ where
173169
/// Run the walker
174170
#[instrument(skip(self), ret)]
175171
pub async fn run(self) -> Result<Continuation, Error> {
176-
tokio::task::spawn_blocking(move || self.run_sync()).await?
172+
tokio::task::spawn_blocking(|| self.run_sync()).await?
177173
}
178174

179175
/// Sync version, as all git functions are sync
180176
#[instrument(skip(self))]
181-
fn run_sync(mut self) -> Result<Continuation, Error> {
177+
fn run_sync(self) -> Result<Continuation, Error> {
182178
log::debug!("Starting run for: {}", self.source);
183179

184180
let working_dir = self
@@ -407,7 +403,7 @@ where
407403
}
408404

409405
#[instrument(skip(self, changes), err)]
410-
fn walk(&mut self, base: &Path, changes: &Option<HashSet<PathBuf>>) -> Result<(), Error> {
406+
fn walk(&self, base: &Path, changes: &Option<HashSet<PathBuf>>) -> Result<(), Error> {
411407
let mut collected = vec![];
412408

413409
for entry in WalkDir::new(base)

modules/importer/src/runner/common/walker/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ pub enum CallbackError {
1414
pub trait Callbacks<T>: Send + 'static {
1515
/// Handle an error while loading the file
1616
#[allow(unused)]
17-
fn loading_error(&mut self, path: PathBuf, message: String) {}
17+
fn loading_error(&self, path: PathBuf, message: String) {}
1818

1919
/// Process the file.
2020
///
2121
/// Any error returned will terminate the walk with a critical error.
2222
#[allow(unused)]
23-
fn process(&mut self, path: &Path, document: T) -> Result<(), CallbackError> {
23+
fn process(&self, path: &Path, document: T) -> Result<(), CallbackError> {
2424
Ok(())
2525
}
2626
}

modules/importer/src/runner/cve/handler.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ where
2222
{
2323
type Error = Error;
2424

25-
fn process(
26-
&mut self,
27-
path: &Path,
28-
relative_path: &Path,
29-
) -> Result<(), HandlerError<Self::Error>> {
25+
fn process(&self, path: &Path, relative_path: &Path) -> Result<(), HandlerError<Self::Error>> {
3026
// Get the year, as we walk with a base of `cves`, that must be the year folder.
3127
// If it is not, we skip it.
3228
let Some(year) = relative_path
@@ -69,7 +65,7 @@ impl<C> CveHandler<C>
6965
where
7066
C: Callbacks<Vec<u8>> + Send + 'static,
7167
{
72-
fn process_file(&mut self, path: &Path, rel_path: &Path) -> Result<(), ProcessingError> {
68+
fn process_file(&self, path: &Path, rel_path: &Path) -> Result<(), ProcessingError> {
7369
let cve = match path.extension().map(|s| s.to_string_lossy()).as_deref() {
7470
Some("json") => {
7571
let mut data = Vec::new();

modules/importer/src/runner/cve/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ impl<C: RunContext> Context<C> {
5252
}
5353

5454
impl<C: RunContext> Callbacks<Vec<u8>> for Context<C> {
55-
fn loading_error(&mut self, path: PathBuf, message: String) {
55+
fn loading_error(&self, path: PathBuf, message: String) {
5656
self.report
5757
.lock()
5858
.add_error(Phase::Validation, path.to_string_lossy(), message);
5959
}
6060

61-
fn process(&mut self, path: &Path, cve: Vec<u8>) -> Result<(), CallbackError> {
61+
fn process(&self, path: &Path, cve: Vec<u8>) -> Result<(), CallbackError> {
6262
if let Err(err) = self.store(path, cve) {
6363
self.report
6464
.lock()

modules/importer/src/runner/osv/handler.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ where
1717
{
1818
type Error = Error;
1919

20-
fn process(
21-
&mut self,
22-
path: &Path,
23-
relative_path: &Path,
24-
) -> Result<(), HandlerError<Self::Error>> {
20+
fn process(&self, path: &Path, relative_path: &Path) -> Result<(), HandlerError<Self::Error>> {
2521
match self.process_file(path, relative_path) {
2622
Ok(()) => Ok(()),
2723
Err(ProcessingError::Critical(err)) => {
@@ -41,7 +37,7 @@ impl<C> OsvHandler<C>
4137
where
4238
C: Callbacks<Vec<u8>> + Send + 'static,
4339
{
44-
fn process_file(&mut self, path: &Path, rel_path: &Path) -> Result<(), ProcessingError> {
40+
fn process_file(&self, path: &Path, rel_path: &Path) -> Result<(), ProcessingError> {
4541
let osv = match path.extension().map(|s| s.to_string_lossy()).as_deref() {
4642
Some("yaml") | Some("json") => {
4743
let mut data = Vec::new();

modules/importer/src/runner/osv/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ impl<C: RunContext> Context<C> {
7979
}
8080

8181
impl<C: RunContext> Callbacks<Vec<u8>> for Context<C> {
82-
fn loading_error(&mut self, path: PathBuf, message: String) {
82+
fn loading_error(&self, path: PathBuf, message: String) {
8383
self.report
8484
.lock()
8585
.add_error(Phase::Validation, path.to_string_lossy(), message);
8686
}
8787

88-
fn process(&mut self, path: &Path, osv: Vec<u8>) -> Result<(), CallbackError> {
88+
fn process(&self, path: &Path, osv: Vec<u8>) -> Result<(), CallbackError> {
8989
if let Err(err) = self.store(path, osv) {
9090
self.report
9191
.lock()

0 commit comments

Comments
 (0)