fn fix_all()

in tools/sdk-lints/src/lint.rs [81:117]


    fn fix_all(&self, dry_run: Mode) -> anyhow::Result<Vec<PathBuf>>
    where
        Self: Fix,
    {
        let mut fixes = vec![];
        for path in self
            .files_to_check()
            .with_context(|| format!("failed to load file list for {}", self.name()))?
        {
            let (errs, new_content) = self
                .fix(&path)
                .with_context(|| format!("error attempting to fix {}", path.display()))?;
            let current_content = std::fs::read_to_string(&path).unwrap_or_default();
            if !errs.is_empty() {
                eprintln!("Errors for {}:", path.display());
                for error in &errs {
                    eprintln!("  {}", error)
                }
            }
            if new_content != current_content {
                if dry_run == Mode::NoDryRun {
                    std::fs::write(&path, new_content)
                        .with_context(|| format!("failure writing fix to {}", path.display()))?;
                }
                fixes.push(path);
            }
        }
        if fixes.len() == 0 {
            eprintln!("{}...OK!", self.name())
        } else {
            eprintln!("Fixed {} files for {}:", fixes.len(), self.name());
            for file in &fixes {
                eprintln!("  {}", file.display())
            }
        }
        Ok(fixes)
    }