refactor: collapse empty modules
All checks were successful
Test / test (push) Successful in 7s

This commit is contained in:
Paul Campbell 2024-09-20 14:28:23 +01:00
parent cf67463016
commit b4552c7304
10 changed files with 43 additions and 77 deletions

View file

@ -1,22 +0,0 @@
use super::Marker;
//
#[derive(Debug, Default)]
pub struct FoundMarkers {
markers: Vec<Marker>,
}
impl FoundMarkers {
pub fn add_marker(&mut self, marker: Marker) {
self.markers.push(marker);
}
}
impl std::fmt::Display for FoundMarkers {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
for marker in self.markers.iter() {
// if !matches!(marker, Marker::Unmarked) {
write!(f, "{marker}")?;
// }
}
Ok(())
}
}

View file

@ -1,15 +0,0 @@
//
#![allow(dead_code)]
use super::Marker;
use bon::Builder;
#[derive(Debug, Builder)]
pub struct IssueMarker {
/// The marker
marker: Marker,
/// The issue number
issue: usize,
}

View file

@ -1,20 +0,0 @@
//
#![allow(dead_code)]
use crate::model::Line;
#[derive(Debug)]
pub enum Marker {
Unmarked,
Invalid(Line),
Valid(Line, String),
}
impl std::fmt::Display for Marker {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Marker::Unmarked => Ok(()),
Marker::Invalid(line) => write!(f, "- Invalid: {line}"),
Marker::Valid(line, _) => write!(f, "- Valid : {line}"),
}
}
}

View file

@ -1,10 +1,41 @@
// //
mod found;
mod issue;
mod marker;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
pub use found::FoundMarkers; use crate::model::Line;
pub use marker::Marker;
#[derive(Debug)]
pub enum Marker {
Unmarked,
Invalid(Line),
#[allow(dead_code)]
Valid(Line, String),
}
impl std::fmt::Display for Marker {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Marker::Unmarked => Ok(()),
Marker::Invalid(line) => write!(f, "- Invalid: {line}"),
Marker::Valid(line, _) => write!(f, "- Valid : {line}"),
}
}
}
#[derive(Debug, Default)]
pub struct Markers {
markers: Vec<Marker>,
}
impl Markers {
pub fn add_marker(&mut self, marker: Marker) {
self.markers.push(marker);
}
}
impl std::fmt::Display for Markers {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
for marker in self.markers.iter() {
write!(f, "{marker}")?;
}
Ok(())
}
}

View file

@ -1,7 +1,5 @@
use crate::model::Line;
// //
use super::*; use crate::model::{markers::Markers, Line};
#[test] #[test]
fn found_when_displayed() -> anyhow::Result<()> { fn found_when_displayed() -> anyhow::Result<()> {
@ -10,7 +8,7 @@ fn found_when_displayed() -> anyhow::Result<()> {
let file = fs.base().join("file-name"); let file = fs.base().join("file-name");
let relative = file.strip_prefix(fs.base())?.to_path_buf(); let relative = file.strip_prefix(fs.base())?.to_path_buf();
let mut found = FoundMarkers::default(); let mut found = Markers::default();
let marker_unmarked = Line::builder() let marker_unmarked = Line::builder()
.file(file.clone()) .file(file.clone())

View file

@ -1,6 +0,0 @@
//
use super::*;
mod found;
mod issue;
mod marker;

View file

@ -8,5 +8,5 @@ mod tests;
pub use config::Config; pub use config::Config;
pub use line::Line; pub use line::Line;
pub use markers::FoundMarkers;
pub use markers::Marker; pub use markers::Marker;
pub use markers::Markers;

View file

@ -1,12 +1,12 @@
// //
use std::path::Path; use std::path::Path;
use crate::model::{Config, FoundMarkers, Line, Marker}; use crate::model::{Config, Line, Marker, Markers};
use anyhow::Result; use anyhow::Result;
use ignore::Walk; use ignore::Walk;
pub fn find_markers(config: &Config) -> Result<FoundMarkers, anyhow::Error> { pub fn find_markers(config: &Config) -> Result<Markers, anyhow::Error> {
let mut markers = FoundMarkers::default(); let mut markers = Markers::default();
for file in Walk::new(config.fs().base()).flatten() { for file in Walk::new(config.fs().base()).flatten() {
let path = file.path(); let path = file.path();
if config.fs().path_is_file(path)? { if config.fs().path_is_file(path)? {
@ -16,7 +16,7 @@ pub fn find_markers(config: &Config) -> Result<FoundMarkers, anyhow::Error> {
Ok(markers) Ok(markers)
} }
fn scan_file(file: &Path, config: &Config, found_markers: &mut FoundMarkers) -> Result<()> { fn scan_file(file: &Path, config: &Config, found_markers: &mut Markers) -> Result<()> {
let relative_path = file.strip_prefix(config.fs().base())?.to_path_buf(); let relative_path = file.strip_prefix(config.fs().base())?.to_path_buf();
config config
.fs() .fs()