sqruff_lib/core/linter/
linting_result.rs1use std::time::Instant;
2
3use crate::core::linter::linted_dir::LintedDir;
4
5#[derive(Debug)]
6pub struct LintingResult {
7 pub paths: Vec<LintedDir>,
8 start_time: Instant,
9 total_time: f64,
10}
11
12impl Default for LintingResult {
13 fn default() -> Self {
14 Self::new()
15 }
16}
17
18impl LintingResult {
19 pub fn new() -> Self {
20 LintingResult {
21 paths: vec![],
22 start_time: Instant::now(),
23 total_time: 0.0,
24 }
25 }
26
27 pub fn add(&mut self, path: LintedDir) -> usize {
29 let idx = self.paths.len();
30 self.paths.push(path);
31 idx
32 }
33
34 pub(crate) fn stop_timer(&mut self) {
36 self.total_time = self.start_time.elapsed().as_secs_f64();
37 }
38}