Skip to main content

stern4rust/settings/
config.rs

1// Copyright 2025 Umberto Gotti <umberto.gotti@umbertogotti.dev>
2// Licensed under the MIT License
3// SPDX-License-Identifier: MIT
4
5use crate::finding::model::manifest_dependency::ManifestDependency;
6use crate::reporting::offence_threshold::OffenceThreshold;
7use crate::reporting::output_format::OutputFormat;
8use crate::settings::rule_selection::RuleSelection;
9use std::path::PathBuf;
10
11// The threshold is an OffenceThreshold rather than a bare usize precisely so
12// this can stay derived. A usize field would default to zero, which this tool
13// reads as "no limit" -- the opposite of the CLI default, and a mismatch that
14// would only surface on a codebase big enough to need the cap.
15//
16// The directory limits are Options for the same reason and the opposite danger:
17// a bare usize defaulting to zero would mean "no files may exist", turning
18// every directory in an unconfigured run into an offence. None means "not
19// configured", and each rule supplies its own default.
20#[derive(Debug, Clone, Default, PartialEq, Eq)]
21pub struct Config {
22    pub baseline: Option<PathBuf>,
23    pub config_file: Option<PathBuf>,
24    pub fix: bool,
25    pub write_baseline: bool,
26    pub manifest_license: Option<String>,
27    pub workspace_dependencies: Option<Vec<ManifestDependency>>,
28    pub manifest_path: Option<PathBuf>,
29    pub max_files_per_directory: Option<usize>,
30    pub max_subfolders_per_directory: Option<usize>,
31    pub packages: Vec<String>,
32    pub excludes: Vec<String>,
33    pub expected_header: Vec<String>,
34    pub format: OutputFormat,
35    pub offence_threshold: OffenceThreshold,
36    pub selection: RuleSelection,
37}