libscilo/config/instantiated_config/
defaults.rs

1//! This module contains default values and the [`Default`] trait implementation for [`InstantiatedConfig`].
2
3use std::sync::LazyLock;
4
5use regex::Regex;
6use strum::IntoEnumIterator;
7
8use crate::{InstantiatedConfig, LintCheck, RootDirs};
9
10/// The default regular expression for [`code`][RootDirs::code]
11/// and [`results`][RootDirs::results] folders to match against.
12/// The format is `YYYY-MM-DD_kebab-case-brief-description`.
13pub(crate) static CODE_RESULTS_SUBDIR_REGEX: LazyLock<Regex> = LazyLock::new(|| {
14    Regex::new(r"2\d{3}-(0[1-9]|1[0-2])-([0-2][0-9]|3[0-1])_[A-Za-z0-9-]+").unwrap()
15});
16
17/// The default accepted file names of the READMEs that should be present in the
18/// project root and within each subdirectory in the [`code`][RootDirs::code]
19/// and [`data`][RootDirs::data] directories.
20static README_FILE_NAMES: LazyLock<Vec<String>> = LazyLock::new(|| {
21    vec![
22        String::from("README.md"),
23        String::from("README.org"),
24        String::from("README.txt"),
25        String::from("README"),
26    ]
27});
28
29/// The default accepted file names of the workflow files that should be present
30/// within each subdirectory in the [`code`][RootDirs::code] directory.
31static WORKFLOW_FILE_NAMES: LazyLock<Vec<String>> = LazyLock::new(|| {
32    vec![
33        // Snakemake
34        String::from("Snakefile"),
35        // Targets
36        String::from("_targets.R"),
37        // Cromwell, Common Workflow Language
38        String::from("main.cwl"),
39        // Nextflow
40        String::from("main.nf"),
41        // BioPipe
42        String::from("main.pipe"),
43        // Guix Workflow Language
44        String::from("main.w"),
45        // Workflow Description Language
46        String::from("main.wdl"),
47        // Make
48        String::from("Makefile"),
49    ]
50});
51
52impl Default for InstantiatedConfig {
53    fn default() -> Self {
54        Self {
55            root_dirs: RootDirs::default(),
56            code_results_subdir_regex: Some((*CODE_RESULTS_SUBDIR_REGEX).clone()),
57            // by default, use all lints
58            lints: LintCheck::iter().collect(),
59            root_files: Vec::new(),
60            readme_names: Some((*README_FILE_NAMES).clone()),
61            workflow_names: Some((*WORKFLOW_FILE_NAMES).clone()),
62            ignored: Vec::new(),
63        }
64    }
65}