Skip to content

Commit

Permalink
fixed unused variable warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
iesahin committed Dec 29, 2024
1 parent 226477e commit 99ac91f
Show file tree
Hide file tree
Showing 34 changed files with 41 additions and 132 deletions.
1 change: 0 additions & 1 deletion config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,6 @@ pub fn toml_value_to_hashmap(key: String, value: TomlValue) -> HashMap<String, T
}

#[cfg(test)]

mod tests {

use super::*;
Expand Down
3 changes: 1 addition & 2 deletions core/src/check_ignore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use clap::Parser;
use log::trace;
use std::io::BufRead;
use std::path::{Path, PathBuf};
use xvc_logging::{output, watch, XvcOutputSender};
use xvc_logging::{output, XvcOutputSender};
use xvc_walker::{build_ignore_patterns, IgnoreRules, MatchResult, WalkOptions};

// DIFFERENCES from DVC
Expand Down Expand Up @@ -120,7 +120,6 @@ fn check_ignore_paths(

/// Check whether the records match to the full_path. It reports the details if
/// set true. Non_matching inverts the reporting.
fn check_ignore_line(ignore_rules: &IgnoreRules, absolute_path: &Path) -> String {
match ignore_rules.check(absolute_path) {
MatchResult::NoMatch => {
Expand Down
1 change: 0 additions & 1 deletion core/src/types/xvcroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ impl XvcRootInner {
.expect("Cannot canonicalize the path. Possible symlink loop.");

for parent in abs_path.ancestors() {
let xvc_candidate = parent.join(XVC_DIR);
if parent.join(XVC_DIR).is_dir() {
return Ok(parent.into());
}
Expand Down
1 change: 0 additions & 1 deletion core/src/util/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use std::os::windows::fs as windows_fs;

use std::path::{Path, PathBuf};
use std::sync::{Arc, RwLock};
use xvc_logging::watch;
use xvc_walker::{IgnoreRules, PathMetadata, SharedIgnoreRules, WalkOptions};

use crate::error::Error;
Expand Down
3 changes: 1 addition & 2 deletions core/src/util/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{ffi::OsString, path::PathBuf, str::FromStr};

use crate::XvcRoot;
use subprocess::Exec;
use xvc_logging::{debug, watch, XvcOutputSender};
use xvc_logging::{debug, XvcOutputSender};

use crate::{Error, Result};
use std::path::Path;
Expand Down Expand Up @@ -303,7 +303,6 @@ mod test {
use super::*;
use std::fs;
use test_case::test_case;
use xvc_logging::watch;
use xvc_test_helper::*;
use xvc_walker::MatchResult as M;

Expand Down
1 change: 0 additions & 1 deletion core/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use std::thread::sleep;
use std::time::Duration;

use crossbeam_channel::{bounded, Receiver};
use xvc_logging::watch;

use crate::error::Result;
use crate::{XvcMetadata, XvcPath, CHANNEL_BOUND};
Expand Down
11 changes: 6 additions & 5 deletions core/src/util/pmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::collections::HashMap;
use std::sync::{Arc, Mutex, RwLock};
use std::thread::{self, JoinHandle};
use std::time::Duration;
use xvc_logging::{error, uwr, watch, XvcOutputSender};
use xvc_logging::{error, uwr, XvcOutputSender};
use xvc_walker::{build_ignore_patterns, make_watcher, IgnoreRules, MatchResult, PathEvent};

use crate::error::Error;
Expand All @@ -27,6 +27,8 @@ pub struct XvcPathMetadataProvider {
xvc_root: XvcRoot,
path_map: Arc<RwLock<XvcPathMetadataMap>>,
kill_signal_sender: Arc<Sender<bool>>,
// This is to keep the background thread and no one needs to read it currently
#[allow(dead_code)]
background_thread: Arc<Mutex<JoinHandle<Result<()>>>>,
output_sender: XvcOutputSender,
ignore_rules: IgnoreRules,
Expand All @@ -53,6 +55,7 @@ impl XvcPathMetadataProvider {
let fs_receiver = event_receiver_clone;
let xvc_root = xvc_root_clone;
// This is not used but to keep the watcher within the thread lifetime
#[allow(unused_variables)]
let watcher = watcher;

let handle_fs_event = |fs_event, pmm: Arc<RwLock<XvcPathMetadataMap>>| match fs_event {
Expand Down Expand Up @@ -205,10 +208,8 @@ impl XvcPathMetadataProvider {
let mut matches = XvcPathMetadataMap::new();
let pattern = glob::Pattern::new(glob)?;
for (p, md) in self.path_map.read().unwrap().iter() {
if pattern.matches(p.as_str()) {
if !md.is_missing() {
matches.insert(p.clone(), *md);
}
if pattern.matches(p.as_str()) && !md.is_missing() {
matches.insert(p.clone(), *md);
}
}
Ok(matches)
Expand Down
2 changes: 1 addition & 1 deletion core/src/util/xvcignore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crossbeam_channel::{bounded, Sender};

use std::sync::{Arc, RwLock};
use std::thread;
use xvc_logging::{warn, watch, XvcOutputSender};
use xvc_logging::{warn, XvcOutputSender};
use xvc_walker::{self, IgnoreRules, PathMetadata, WalkOptions};
use xvc_walker::{Result as XvcWalkerResult, SharedIgnoreRules};

Expand Down
1 change: 0 additions & 1 deletion ecs/src/ecs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use std::time::SystemTime;
use std::time::UNIX_EPOCH;

use serde::{Deserialize, Serialize};
use xvc_logging::watch;

use crate::error::{Error as XvcError, Result};

Expand Down
1 change: 0 additions & 1 deletion ecs/src/ecs/r11store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ where
/// use xvc_ecs::R11Store;
/// let rs = R11Store::<String, i32>::new();
/// ```
pub fn new() -> Self {
Self {
left: XvcStore::<T>::new(),
Expand Down
2 changes: 1 addition & 1 deletion file/src/bring/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use clap::Parser;

use xvc_core::{ContentDigest, RecheckMethod, XvcCachePath, XvcFileType, XvcMetadata, XvcRoot};
use xvc_ecs::{HStore, XvcStore};
use xvc_logging::{debug, error, uwr, warn, watch, XvcOutputSender};
use xvc_logging::{debug, error, uwr, warn, XvcOutputSender};

use xvc_storage::XvcStorageEvent;
use xvc_storage::{storage::get_storage_record, StorageIdentifier, XvcStorageOperations};
Expand Down
5 changes: 2 additions & 3 deletions file/src/common/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use xvc_core::{
};

use xvc_ecs::{HStore, XvcEntity, XvcStore};
use xvc_logging::{debug, error, panic, watch, XvcOutputSender};
use xvc_logging::{debug, error, panic, XvcOutputSender};

use super::FileTextOrBinary;

Expand Down Expand Up @@ -198,8 +198,7 @@ pub fn diff_file_content_digest(
Diff::RecordMissing { actual } => {
let path = actual.to_absolute_path(xvc_root);
let actual_digest = ContentDigest::new(&path, algorithm, text_or_binary.0)?;
let res = compare_with_stored_digest(actual_digest);
res
compare_with_stored_digest(actual_digest)
}
// The path is changed. This can happen after a move
// operation, for example.
Expand Down
3 changes: 1 addition & 2 deletions file/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use xvc_core::{
};
use xvc_core::{get_absolute_git_command, get_git_tracked_files, HashAlgorithm};
use xvc_ecs::ecs::event::EventLog;
use xvc_logging::{error, info, uwr, warn, watch, XvcOutputSender};
use xvc_logging::{error, info, uwr, warn, XvcOutputSender};

use xvc_ecs::{persist, HStore, Storable, XvcStore};

Expand Down Expand Up @@ -253,7 +253,6 @@ pub fn build_glob_matcher(
/// If some day we need to optimize first walking the ignores, then walking the
/// directories in the targets, I'd be glad that this is used in very large
/// repositories.
pub fn targets_from_disk(
output_snd: &XvcOutputSender,
xvc_root: &XvcRoot,
Expand Down
2 changes: 1 addition & 1 deletion file/src/recheck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use xvc_core::{
XvcMetadata, XvcPath, XvcRoot,
};
use xvc_ecs::{HStore, XvcEntity, XvcStore};
use xvc_logging::{error, info, uwr, warn, watch, XvcOutputSender};
use xvc_logging::{error, info, uwr, warn, XvcOutputSender};

/// Check out file from cache by a copy or link
///
Expand Down
2 changes: 1 addition & 1 deletion file/src/remove/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use itertools::Itertools;
use xvc_core::types::xvcdigest::DIGEST_LENGTH;
use xvc_core::{XvcCachePath, XvcRoot};
use xvc_ecs::XvcEntity;
use xvc_logging::{output, uwr, warn, watch, XvcOutputSender};
use xvc_logging::{output, uwr, warn, XvcOutputSender};
use xvc_storage::storage::get_storage_record;
use xvc_storage::{StorageIdentifier, XvcStorageOperations};

Expand Down
1 change: 0 additions & 1 deletion lib/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use xvc_core::root;
use xvc_core::CHANNEL_BOUND;
use xvc_file as file;
use xvc_logging::setup_logging;
use xvc_logging::watch;
use xvc_pipeline as pipeline;
use xvc_storage as storage;
use xvc_walker::AbsolutePath;
Expand Down
1 change: 0 additions & 1 deletion lib/src/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use xvc_core::default_project_config;
use xvc_core::types::xvcroot::init_xvc_root;
use xvc_core::util::git::inside_git;
use xvc_core::XvcRoot;
use xvc_logging::watch;
use xvc_pipeline;
use xvc_walker::AbsolutePath;

Expand Down
6 changes: 3 additions & 3 deletions lib/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use xvc::init::InitCLI;
use xvc_config::XvcVerbosity;

use xvc_core::XvcRoot;
use xvc_logging::{output, watch};
use xvc_logging::output;

use xvc::error::{Error, Result};

Expand Down Expand Up @@ -118,9 +118,9 @@ pub fn run_in_example_project() -> Result<PathBuf> {
}

pub fn run_in_example_xvc(with_git: bool) -> Result<XvcRoot> {
let example_project_dir = run_in_example_project()?;
run_in_example_project()?;
if with_git {
let output = Command::new("git").arg("init").output()?;
Command::new("git").arg("init").output()?;
let xvc_root = xvc::init::run(
None,
InitCLI {
Expand Down
14 changes: 6 additions & 8 deletions lib/tests/z_test_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use anyhow::anyhow;
use regex::Regex;

use xvc::error::Result;
use xvc_logging::{info, warn, watch};
use xvc_logging::{info, warn};
use xvc_test_helper::{make_symlink, random_temp_dir, test_logging};

use fs_extra::{self, dir::CopyOptions};
Expand Down Expand Up @@ -188,13 +188,11 @@ fn make_output_dir_link(
let source = templates_root.join(&dirname);
if !source.exists() {
let target = docs_target_dir.join(&dirname);
if target.exists() {
if target.read_link().unwrap() == source {
fs::remove_file(&target).unwrap_or_else(|e| {
info!("Failed to remove file: {}", e);
exit(1);
});
}
if target.exists() && target.read_link().unwrap() == source {
fs::remove_file(&target).unwrap_or_else(|e| {
info!("Failed to remove file: {}", e);
exit(1);
});
}
match make_symlink(&source, &target) {
Ok(_) => (),
Expand Down
2 changes: 1 addition & 1 deletion pipeline/src/pipeline/api/dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use tabbycat::{AttrList, Edge, GraphBuilder, Identity, StmtList};
use xvc_config::FromConfigKey;
use xvc_core::{XvcPath, XvcPathMetadataProvider, XvcRoot};
use xvc_ecs::{HStore, R1NStore, XvcEntity};
use xvc_logging::{info, output, watch, XvcOutputSender};
use xvc_logging::{info, output, XvcOutputSender};

use std::collections::HashMap;
use std::{fs::File, io::Write};
Expand Down
2 changes: 1 addition & 1 deletion pipeline/src/pipeline/api/step_dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use regex::Regex;
use url::Url;
use xvc_core::{XvcPath, XvcRoot};
use xvc_ecs::{R1NStore, XvcEntity};
use xvc_logging::{debug, watch, XvcOutputSender};
use xvc_logging::{debug, XvcOutputSender};
use xvc_walker::AbsolutePath;

use crate::{pipeline::deps, XvcDependency, XvcParamFormat, XvcPipeline, XvcStep};
Expand Down
2 changes: 1 addition & 1 deletion pipeline/src/pipeline/api/step_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
use itertools::Itertools;
use xvc_core::XvcRoot;
use xvc_ecs::{HStore, R1NStore};
use xvc_logging::{output, watch, XvcOutputSender};
use xvc_logging::{output, XvcOutputSender};

pub fn cmd_step_list(
output_snd: &XvcOutputSender,
Expand Down
1 change: 0 additions & 1 deletion pipeline/src/pipeline/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::time::Instant;
use subprocess as sp;

use xvc_file::CHANNEL_CAPACITY;
use xvc_logging::watch;

use serde::{Deserialize, Serialize};
use xvc_ecs::persist;
Expand Down
7 changes: 1 addition & 6 deletions pipeline/src/pipeline/deps/param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ impl Diffable for ParamDep {
/// ⚠️ Call actual.update_metadata before calling this function ⚠️
fn diff_superficial(record: &Self::Item, actual: &Self::Item) -> Diff<Self::Item> {
assert!(record.path == actual.path);
watch!(record);
watch!(actual);
match (record.xvc_metadata, actual.xvc_metadata) {
(Some(record_md), Some(actual_md)) => {
if record_md == actual_md {
Expand All @@ -105,8 +103,6 @@ impl Diffable for ParamDep {
/// ⚠️ Call actual.update_metadata and actual.update_value before calling this function ⚠️
fn diff_thorough(record: &Self::Item, actual: &Self::Item) -> Diff<Self::Item> {
assert!(record.path == actual.path);
watch!(record);
watch!(actual);
match Self::diff_superficial(record, actual) {
Diff::Identical => Diff::Identical,
Diff::Different { .. } => {
Expand Down Expand Up @@ -272,11 +268,10 @@ impl XvcParamValue {
/// Loads the key (in the form of a.b.c) from a YAML document
fn parse_yaml(all_content: &str, key: &str) -> Result<XvcParamValue> {
let yaml_map: YamlValue = serde_yaml::from_str(all_content)?;
watch!(yaml_map);

let nested_keys: Vec<&str> = key.split('.').collect();
let mut current_scope: YamlValue = yaml_map;
for k in &nested_keys {
watch!(k);
if let Some(current_value) = current_scope.get(*k) {
match current_value {
YamlValue::Mapping(_) => {
Expand Down
Loading

0 comments on commit 99ac91f

Please sign in to comment.