Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc. cleanup tasks #53

Merged
merged 3 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion hipcheck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ lazy_static = "1.4.0"
log = "0.4.16"
libc = "0.2.154"
maplit = "1.0.2"
native-tls = "0.2.11"
nom = "7.1.3"
once_cell = "1.10.0"
ordered-float = { version = "4.2.0", features = ["serde"] }
paste = "1.0.7"
pathbuf = "1.0.0"
petgraph = { version = "0.6.0", features = ["serde-1"] }
regex = "1.5.5"
salsa = "0.16.1"
Expand All @@ -59,7 +61,6 @@ url = "2.2.2"
walkdir = "2.5.0"
which = { version = "6.0.1", default-features = false }
xml-rs = "0.8.20"
native-tls = "0.2.11"

[target.'cfg(windows)'.dependencies.winapi]
version = "0.3.9"
Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/analysis/metric/affiliation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::data::git::Commit;
use crate::data::git::CommitContributorView;
use crate::error::Error;
use crate::error::Result;
use crate::filesystem as file;
use crate::hc_error;
use crate::util::fs as file;
use serde::de::Error as SerdeError;
use serde::de::Visitor;
use serde::Deserialize;
Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/analysis/metric/binary_detector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ pub use query::*;

use crate::context::Context;
use crate::error::Result;
use crate::filesystem::read_toml;
use crate::hc_error;
use crate::util::fs::read_toml;
use content_inspector::inspect;
use content_inspector::ContentType;
use serde::de::Visitor;
Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/analysis/metric/linguist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub use query::*;

use crate::context::Context as _;
use crate::error::Result;
use crate::filesystem::read_toml;
use crate::util::fs::read_toml;
use serde::de::Visitor;
use serde::Deserialize;
use serde::Deserializer;
Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/analysis/metric/typo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::context::Context as _;
use crate::data::Dependencies;
use crate::data::Lang;
use crate::error::Result;
use crate::filesystem as file;
use crate::util::fs as file;
use maplit::hashmap;
use serde::Deserialize;
use serde::Serialize;
Expand Down
10 changes: 5 additions & 5 deletions hipcheck/src/analysis/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ use crate::data::ModuleProviderStorage;
use crate::data::PullRequestReviewProviderStorage;
use crate::error::Error;
use crate::error::Result;
use crate::filesystem::create_dir_all;
use crate::hc_error;
use crate::pathbuf;
use crate::report::Format;
use crate::report::ReportParams;
use crate::report::ReportParamsStorage;
use crate::shell::Phase;
use crate::shell::Shell;
use crate::util::fs::create_dir_all;
use crate::version::get_version;
use crate::version::VersionQuery;
use crate::version::VersionQueryStorage;
use crate::HIPCHECK_TOML_FILE;
use chrono::prelude::*;
use dotenv::var;
use pathbuf::pathbuf;
use std::ffi::OsStr;
use std::ffi::OsString;
use std::fmt;
Expand Down Expand Up @@ -372,7 +372,7 @@ pub fn resolve_config(config_flag: Option<&Path>) -> Result<PathBuf> {
// (See https://docs.rs/dirs/3.0.2/dirs/fn.cache_dir.html)

if let Some(config_path) = config_flag {
let full_config_path = pathbuf![&config_path, HIPCHECK_TOML_FILE];
let full_config_path = pathbuf![config_path, HIPCHECK_TOML_FILE];
if full_config_path.exists() {
return Ok(full_config_path);
}
Expand Down Expand Up @@ -673,7 +673,7 @@ mod tests {
],
|| {
let data_dir = None;
let data_path = pathbuf![dirs::data_dir().unwrap(), "hipcheck"];
let data_path = pathbuf![&dirs::data_dir().unwrap(), "hipcheck"];
create_dir_all(data_path.as_path()).unwrap();
let result = resolve_data(data_dir).unwrap();
let path = result.to_str().unwrap();
Expand Down Expand Up @@ -748,7 +748,7 @@ mod tests {
("HC_DATA", None),
],
|| {
let data_path = pathbuf![dirs::data_dir().unwrap(), "hipcheck"];
let data_path = pathbuf![&dirs::data_dir().unwrap(), "hipcheck"];
create_dir_all(data_path.as_path()).unwrap();
let result = resolve_data(None).unwrap();
let path = result.to_str().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions hipcheck/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

use crate::context::Context;
use crate::error::Result;
use crate::filesystem as file;
use crate::pathbuf;
use crate::util::fs as file;
use crate::BINARY_CONFIG_FILE;
use crate::F64;
use crate::LANGS_FILE;
use crate::ORGS_FILE;
use crate::TYPO_FILE;
use pathbuf::pathbuf;
use serde::Deserialize;
use serde::Serialize;
use smart_default::SmartDefault;
Expand Down
13 changes: 7 additions & 6 deletions hipcheck/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,36 @@

//! Functions and types for data retrieval.

mod code_quality;
mod es_lint;
pub mod git;
pub mod git_command;
pub mod npm;
pub mod source;

mod code_quality;
mod es_lint;
mod github;
mod hash;
mod modules;
pub mod npm;
mod query;
pub mod source;

pub use query::*;
use std::collections::HashSet;

use crate::context::Context;
use crate::error::Error;
use crate::error::Result;
use crate::hc_error;
use crate::pathbuf;
use git::get_commits_for_file;
use git::Commit;
use git::CommitContributor;
use git::Contributor;
use git::Diff;
use github::*;
use modules::RawModule;
use pathbuf::pathbuf;
use petgraph::visit::Dfs;
use petgraph::Graph;
use serde::Serialize;
use std::collections::HashSet;
use std::path::Path;
use std::rc::Rc;

Expand Down
4 changes: 2 additions & 2 deletions hipcheck/src/data/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::context::Context as _;
use crate::error::Error;
use crate::error::Result;
use crate::hc_error;
use crate::pathbuf;
use pathbuf::pathbuf;
use serde::Deserialize;
use serde_json::Value as JsonValue;
use std::collections::HashMap;
Expand All @@ -21,7 +21,7 @@ use std::process::Command;

pub fn generate_module_model(repo_dir: &Path, module_deps: &Path) -> Result<Vec<RawModule>> {
let root = detect_npm_package_root(&pathbuf![repo_dir, "package.json"])?;
if !pathbuf![&repo_dir, &root].exists() {
if !pathbuf![repo_dir, &root].exists() {
return Err(Error::msg(
"Unable to identify module structure of repository code",
));
Expand Down
4 changes: 2 additions & 2 deletions hipcheck/src/data/npm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use crate::command_util::log_args;
use crate::command_util::DependentProgram;
use crate::context::Context;
use crate::error::Result;
use crate::filesystem as file;
use crate::hc_error;
use crate::pathbuf;
use crate::util::fs as file;
use pathbuf::pathbuf;
use serde::Deserialize;
use std::collections::HashMap;
use std::convert::AsRef;
Expand Down
8 changes: 3 additions & 5 deletions hipcheck/src/data/query/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

//! Query group for module information.

use std::path::PathBuf;
use std::rc::Rc;

use crate::data::associate_modules_and_commits;
use crate::data::git::Commit;
use crate::data::git::GitProvider;
use crate::data::Module;
use crate::data::ModuleGraph;

use crate::error::Error;
use crate::error::Result;
use crate::pathbuf;
use pathbuf::pathbuf;
use std::path::PathBuf;
use std::rc::Rc;

/// A module and an associated commit
pub type ModuleCommitMap = Rc<Vec<(Rc<Module>, Rc<Commit>)>>;
Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/data/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use crate::data::git_command::GitCommand;
use crate::error::Error;
use crate::error::Result;
use crate::hc_error;
use crate::pathbuf;
use crate::shell::Phase;
use log::debug;
use pathbuf::pathbuf;
use std::ffi::OsStr;
use std::fmt;
use std::fmt::Debug;
Expand Down
8 changes: 4 additions & 4 deletions hipcheck/src/data/source/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use crate::data::source::Remote;
use crate::data::source::Source;
use crate::hash;
use crate::pathbuf;
use pathbuf::pathbuf;
use std::path::PathBuf;
use std::rc::Rc;

Expand Down Expand Up @@ -80,14 +80,14 @@ fn storage_path(db: &dyn SourceQuery) -> Rc<PathBuf> {
repo,
pull_request,
..
} => pathbuf!["remote", "github", owner, repo, pull_request.to_string()],
} => pathbuf!["remote", "github", owner, repo, &pull_request.to_string()],
// This is an unknown remote source.
Unknown(url) => pathbuf!["remote", "unknown", hash!(url).to_string()],
Unknown(url) => pathbuf!["remote", "unknown", &hash!(url).to_string()],
},
// This is a local source.
None => match db.local().file_name() {
Some(file_name) => pathbuf!["local", file_name],
None => pathbuf!["local", "unknown", hash!(db.local()).to_string()],
None => pathbuf!["local", "unknown", &hash!(db.local()).to_string()],
},
};

Expand Down
9 changes: 3 additions & 6 deletions hipcheck/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ mod config;
mod context;
mod data;
mod error;
mod filesystem;
mod pathbuf;
mod report;
mod shell;
#[cfg(test)]
mod test_util;
#[cfg(test)]
mod tests;
mod try_any;
mod try_filter;
mod util;
mod version;

use crate::analysis::report_builder::build_pr_report;
Expand All @@ -39,6 +36,8 @@ use crate::shell::ColorChoice;
use crate::shell::Output;
use crate::shell::Shell;
use crate::shell::Verbosity;
use crate::util::iter::TryAny;
use crate::util::iter::TryFilter;
use clap::Arg;
use clap::ArgAction;
use clap::Command;
Expand All @@ -51,8 +50,6 @@ use std::path::Path;
use std::path::PathBuf;
use std::process::exit;
use std::str::FromStr;
use try_any::TryAny;
use try_filter::TryFilter;

/// Entry point for Hipcheck.
///
Expand Down
78 changes: 0 additions & 78 deletions hipcheck/src/pathbuf.rs

This file was deleted.

Loading