Skip to content

Commit

Permalink
chore: No more "module-inception"
Browse files Browse the repository at this point in the history
Previously, as an artifact (I think) left-over from when we merged all the
previously-distinct crates comprising Hipcheck into one crate, we had a
"module-inception" problem that Clippy complained about. Besides Clippy
complaining, it also just made for some awkward imports.

This commit removes this problem, moving the contents of the doubly-named
modules up to their parent module, and updating imports to use the new
locations.

Signed-off-by: Andrew Lilley Brinker <[email protected]>
  • Loading branch information
alilleybrinker authored and mchernicoff committed Aug 28, 2024
1 parent fc941b2 commit 3963760
Show file tree
Hide file tree
Showing 17 changed files with 1,221 additions and 1,246 deletions.
403 changes: 0 additions & 403 deletions hipcheck/src/analysis/analysis.rs

This file was deleted.

405 changes: 401 additions & 4 deletions hipcheck/src/analysis/mod.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions hipcheck/src/analysis/report_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::error::Result;
use crate::hc_error;
use crate::report::Concern;
pub use crate::report::*;
use crate::session::session::Session;
use crate::source::source::SourceQuery;
use crate::session::Session;
use crate::source::SourceQuery;
use crate::version::VersionQuery;
use std::default::Default;
use std::result::Result as StdResult;
Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/analysis/score.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::analysis::analysis::AnalysisOutcome;
use crate::analysis::result::*;
use crate::analysis::AnalysisOutcome;
use crate::analysis::AnalysisProvider;
use crate::config::{visit_leaves, WeightTree, WeightTreeProvider};
use crate::error::Result;
Expand Down
1 change: 0 additions & 1 deletion hipcheck/src/cache/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[allow(clippy::module_inception)]
#[allow(dead_code)]
pub mod plugin_cache;
pub mod repo_cache;
2 changes: 1 addition & 1 deletion hipcheck/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::hc_error;
use crate::report::Format;
use crate::session::pm;
use crate::shell::{color_choice::ColorChoice, verbosity::Verbosity};
use crate::source::source;
use crate::source;
use crate::target::{
LocalGitRepo, MavenPackage, Package, PackageHost, Sbom, SbomStandard, TargetSeed,
TargetSeedKind, TargetType, ToTargetSeed, ToTargetSeedKind,
Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/data/git/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::data::git::SignerKeyView;
use crate::data::git::SignerNameView;
use crate::data::git::SignerView;
use crate::error::Result;
use crate::source::source::SourceQuery;
use crate::source::SourceQuery;
use crate::version::VersionQuery;
use chrono::prelude::*;
use std::sync::Arc;
Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/data/query/code_quality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::rc::Rc;
use crate::data::code_quality::get_eslint_report;
use crate::data::code_quality::CodeQualityReport;
use crate::error::Result;
use crate::source::source::SourceQuery;
use crate::source::SourceQuery;
use crate::version::VersionQuery;

/// Queries about code quality
Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/data/query/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::data::npm::get_package_file;
use crate::data::npm::PackageFile;
use crate::data::Dependencies;
use crate::error::Result;
use crate::source::source::SourceQuery;
use crate::source::SourceQuery;
use crate::version::VersionQuery;
use std::sync::Arc;

Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/data/query/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::error::Error;
use crate::error::Result;
use crate::source::source::SourceQuery;
use crate::source::SourceQuery;
use crate::target::KnownRemote;
use std::sync::Arc;

Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use crate::context::Context as _;
use crate::error::Error;
use crate::error::Result;
use crate::plugin::{Plugin, PluginExecutor, PluginWithConfig};
use crate::session::session::Session;
use crate::session::Session;
use crate::setup::{resolve_and_transform_source, SourceType};
use crate::shell::verbosity::Verbosity;
use crate::shell::Shell;
Expand Down
88 changes: 0 additions & 88 deletions hipcheck/src/metric/metric.rs

This file was deleted.

89 changes: 85 additions & 4 deletions hipcheck/src/metric/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,92 @@ pub mod fuzz;
pub mod identity;
pub mod linguist;
mod math;
#[allow(clippy::module_inception)]
pub mod metric;
pub mod module;
pub mod review;
pub mod typo;

pub use metric::MetricProvider;
pub use metric::MetricProviderStorage;
use crate::config::AttacksConfigQuery;
use crate::config::CommitConfigQuery;
use crate::data::git::GitProvider;
use crate::data::DependenciesProvider;
use crate::data::FuzzProvider;
use crate::data::ModuleProvider;
use crate::data::PullRequestReviewProvider;
use crate::error::Result;
use crate::metric::activity::ActivityOutput;
use crate::metric::affiliation::AffiliationOutput;
use crate::metric::binary::BinaryOutput;
use crate::metric::binary_detector::BinaryFile;
use crate::metric::churn::ChurnOutput;
use crate::metric::commit_trust::CommitTrustOutput;
use crate::metric::contributor_trust::ContributorTrustOutput;
use crate::metric::entropy::EntropyOutput;
use crate::metric::fuzz::FuzzOutput;
use crate::metric::identity::IdentityOutput;
use crate::metric::linguist::Linguist;
use crate::metric::module::ModuleOutput;
use crate::metric::review::ReviewOutput;
use crate::metric::typo::TypoOutput;
use std::sync::Arc;

/// Queries about metrics
#[salsa::query_group(MetricProviderStorage)]
pub trait MetricProvider:
AttacksConfigQuery
+ BinaryFile
+ CommitConfigQuery
+ DependenciesProvider
+ GitProvider
+ Linguist
+ ModuleProvider
+ FuzzProvider
+ PullRequestReviewProvider
{
/// Returns result of activity metric
#[salsa::invoke(activity::activity_metric)]
fn activity_metric(&self) -> Result<Arc<ActivityOutput>>;

/// Returns result of affiliation metric
#[salsa::invoke(affiliation::affiliation_metric)]
fn affiliation_metric(&self) -> Result<Arc<AffiliationOutput>>;

/// Returns result of binary metric
#[salsa::invoke(binary::binary_metric)]
fn binary_metric(&self) -> Result<Arc<BinaryOutput>>;

/// Returns result of churn metric
#[salsa::invoke(churn::churn_metric)]
fn churn_metric(&self) -> Result<Arc<ChurnOutput>>;

/// Returns result of contributor trust metric
#[salsa::invoke(commit_trust::commit_trust_metric)]
fn commit_trust_metric(&self) -> Result<Arc<CommitTrustOutput>>;

/// Returns result of contributor trust metric
#[salsa::invoke(contributor_trust::contributor_trust_metric)]
fn contributor_trust_metric(&self) -> Result<Arc<ContributorTrustOutput>>;

/// Returns result of entropy metric
#[salsa::invoke(entropy::entropy_metric)]
fn entropy_metric(&self) -> Result<Arc<EntropyOutput>>;

/// Returns result of identity metric
#[salsa::invoke(identity::identity_metric)]
fn identity_metric(&self) -> Result<Arc<IdentityOutput>>;

/// Returns result of module analysis.
#[salsa::invoke(module::module_analysis)]
fn module_analysis(&self) -> Result<Arc<ModuleOutput>>;

/// Returns result of fuzz metric
#[salsa::invoke(fuzz::fuzz_metric)]
fn fuzz_metric(&self) -> Result<Arc<FuzzOutput>>;

/// Returns result of review metric
#[salsa::invoke(review::review_metric)]
fn review_metric(&self) -> Result<Arc<ReviewOutput>>;

/// Returns result of typo metric
#[salsa::invoke(typo::typo_metric)]
fn typo_metric(&self) -> Result<Arc<TypoOutput>>;
}
Loading

0 comments on commit 3963760

Please sign in to comment.