From 93794c4984c382833f0923f4e466bdfb95c566bb Mon Sep 17 00:00:00 2001 From: Will Bush Date: Wed, 30 Oct 2024 05:42:48 -0500 Subject: [PATCH] lint: rename nix_file::NixFileStore to nix_file::Store part of clippy::module_name_repetitions --- src/eval.rs | 8 ++++---- src/main.rs | 3 +-- src/nix_file.rs | 6 +++--- src/references.rs | 8 ++++---- src/structure.rs | 6 +++--- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/eval.rs b/src/eval.rs index e8b3a4a..701cf52 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -13,7 +13,7 @@ use crate::ratchet::State::{Loose, Tight}; use crate::structure::{self, BASE_SUBPATH}; use crate::validation::ResultIteratorExt as _; use crate::validation::{self, Validation::Success}; -use crate::NixFileStore; +use crate::nix_file::Store; use crate::{location, ratchet}; const EVAL_NIX: &[u8] = include_bytes!("eval.nix"); @@ -154,7 +154,7 @@ fn mutate_nix_instatiate_arguments_based_on_cfg( /// achieved on the Nix side. pub fn check_values( nixpkgs_path: &Path, - nix_file_store: &mut NixFileStore, + nix_file_store: &mut Store, package_names: &[String], ) -> validation::Result { let work_dir = tempfile::Builder::new() @@ -263,7 +263,7 @@ pub fn check_values( /// Handle the evaluation result for an attribute in `pkgs/by-name`, making it a validation result. fn by_name( - nix_file_store: &mut NixFileStore, + nix_file_store: &mut Store, nixpkgs_path: &Path, attribute_name: &str, by_name_attribute: ByNameAttribute, @@ -450,7 +450,7 @@ fn by_name_override( /// validation result. fn handle_non_by_name_attribute( nixpkgs_path: &Path, - nix_file_store: &mut NixFileStore, + nix_file_store: &mut Store, attribute_name: &str, non_by_name_attribute: NonByNameAttribute, ) -> validation::Result { diff --git a/src/main.rs b/src/main.rs index bec50f3..fa1a367 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,7 +21,6 @@ use std::path::{Path, PathBuf}; use std::process::ExitCode; use std::{panic, thread}; -use crate::nix_file::NixFileStore; use crate::status::{ColoredStatus, Status}; use crate::validation::Validation::Failure; use crate::validation::Validation::Success; @@ -113,7 +112,7 @@ fn check_nixpkgs(nixpkgs_path: &Path) -> validation::Result { return Ok(Success(ratchet::Nixpkgs::default())); } - let mut nix_file_store = NixFileStore::default(); + let mut nix_file_store = nix_file::Store::default(); let structure = structure::check(&nixpkgs_path, &mut nix_file_store)?; // Only if we could successfully parse the structure, we do the evaluation checks diff --git a/src/nix_file.rs b/src/nix_file.rs index 91532c0..fe513ab 100644 --- a/src/nix_file.rs +++ b/src/nix_file.rs @@ -19,11 +19,11 @@ use std::path::PathBuf; /// A structure to store parse results of Nix files in memory, making sure that the same file never /// has to be parsed twice. #[derive(Default)] -pub struct NixFileStore { +pub struct Store { entries: HashMap, } -impl NixFileStore { +impl Store { /// Get the store entry for a Nix file if it exists, otherwise parse the file, insert it into /// the store, and return the value. /// @@ -116,7 +116,7 @@ impl NixFile { /// /// results in `{ file = ./default.nix; line = 2; column = 3; }` /// - /// - Get the `NixFile` for `.file` from a `NixFileStore` + /// - Get the `NixFile` for `.file` from a `nix_file::Store` /// /// - Call this function with `.line`, `.column` and `relative_to` as the (absolute) current /// directory. diff --git a/src/references.rs b/src/references.rs index aa8bc44..d816750 100644 --- a/src/references.rs +++ b/src/references.rs @@ -9,12 +9,12 @@ use crate::nix_file::ResolvedPath; use crate::problem::{npv_121, npv_122, npv_123, npv_124, npv_125, npv_126}; use crate::structure::read_dir_sorted; use crate::validation::{self, ResultIteratorExt, Validation::Success}; -use crate::NixFileStore; +use crate::nix_file::Store; /// Check that every package directory in pkgs/by-name doesn't link to outside that directory. /// Both symlinks and Nix path expressions are checked. pub fn check( - nix_file_store: &mut NixFileStore, + nix_file_store: &mut Store, relative_package_dir: &RelativePath, absolute_package_dir: &Path, ) -> validation::Result<()> { @@ -40,7 +40,7 @@ pub fn check( /// A relative path so that the error messages don't get absolute paths (which are messy in CI). /// The absolute package directory gets prepended before doing anything with it though. fn check_path( - nix_file_store: &mut NixFileStore, + nix_file_store: &mut Store, relative_package_dir: &RelativePath, absolute_package_dir: &Path, subpath: &RelativePath, @@ -111,7 +111,7 @@ fn check_path( /// Check whether a Nix file contains path expression references pointing outside the package /// directory. fn check_nix_file( - nix_file_store: &mut NixFileStore, + nix_file_store: &mut Store, relative_package_dir: &RelativePath, absolute_package_dir: &Path, subpath: &RelativePath, diff --git a/src/structure.rs b/src/structure.rs index 7d88826..78434d3 100644 --- a/src/structure.rs +++ b/src/structure.rs @@ -10,7 +10,7 @@ use relative_path::RelativePathBuf; use crate::problem::{npv_109, npv_110, npv_111, npv_140, npv_141, npv_142, npv_143, npv_144}; use crate::references; use crate::validation::{self, ResultIteratorExt, Validation::Success}; -use crate::NixFileStore; +use crate::nix_file::Store; pub const BASE_SUBPATH: &str = "pkgs/by-name"; pub const PACKAGE_NIX_FILENAME: &str = "package.nix"; @@ -52,7 +52,7 @@ pub fn relative_file_for_package(package_name: &str) -> RelativePathBuf { /// Check the structure of Nixpkgs, returning the attribute names that are defined in /// `pkgs/by-name` -pub fn check(path: &Path, nix_file_store: &mut NixFileStore) -> validation::Result> { +pub fn check(path: &Path, nix_file_store: &mut Store) -> validation::Result> { let base_dir = path.join(BASE_SUBPATH); let shard_results = read_dir_sorted(&base_dir)? @@ -118,7 +118,7 @@ pub fn check(path: &Path, nix_file_store: &mut NixFileStore) -> validation::Resu } fn check_package( - nix_file_store: &mut NixFileStore, + nix_file_store: &mut Store, path: &Path, shard_name: &str, shard_name_valid: bool,