Skip to content

Commit

Permalink
chore: rename files in cache module
Browse files Browse the repository at this point in the history
  • Loading branch information
j-lanson authored and alilleybrinker committed Sep 13, 2024
1 parent 7fb7387 commit f447b7c
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 34 deletions.
18 changes: 0 additions & 18 deletions hipcheck/src/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,21 +211,3 @@ pub fn typo_analysis(db: &dyn AnalysisProvider) -> Result<QueryResult> {
concerns,
})
}

#[allow(unused)]
fn score_by_threshold<T: PartialOrd>(value: T, threshold: T) -> i64 {
if value > threshold {
1
} else {
0
}
}

#[allow(unused)]
fn score_by_threshold_reversed<T: PartialOrd>(value: T, threshold: T) -> i64 {
if value >= threshold {
0
} else {
1
}
}
4 changes: 2 additions & 2 deletions hipcheck/src/cache/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: Apache-2.0

pub mod plugin_cache;
pub mod repo_cache;
pub mod plugin;
pub mod repo;
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion hipcheck/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Data structures for Hipcheck's main CLI.

use crate::{
cache::repo_cache::{RepoCacheDeleteScope, RepoCacheListScope, RepoCacheSort},
cache::repo::{RepoCacheDeleteScope, RepoCacheListScope, RepoCacheSort},
error::Context,
error::Result,
hc_error,
Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pub use crate::plugin::{HcPluginCore, PluginExecutor, PluginWithConfig};
use crate::{
cache::plugin_cache::HcPluginCache,
cache::plugin::HcPluginCache,
hc_error,
plugin::{
get_plugin_key, retrieve_plugins, Plugin, PluginManifest, PluginResponse, QueryResult,
Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub mod hipcheck {

use crate::{
analysis::score::score_results,
cache::repo_cache::HcRepoCache,
cache::repo::HcRepoCache,
cli::Format,
config::WeightTreeProvider,
error::{Context as _, Error, Result},
Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/plugin/download_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use super::{PluginId, PluginManifest, PluginName, PluginPublisher, PluginVersion};
use crate::{
cache::plugin_cache::HcPluginCache,
cache::plugin::HcPluginCache,
error::Error,
hc_error,
plugin::{
Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/plugin/retrieval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use super::{DownloadManifest, PluginId};
use crate::{
cache::plugin_cache::HcPluginCache,
cache::plugin::HcPluginCache,
config::MITRE_PUBLISHER,
error::Error,
hc_error,
Expand Down
20 changes: 12 additions & 8 deletions hipcheck/src/report/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ pub enum Analysis {
#[serde(skip)]
passed: bool,
},
#[allow(unused)]
/// Plugin analysis.
Plugin {
/// The name of the plugin.
Expand All @@ -380,7 +379,7 @@ pub enum Analysis {
///
/// Same as with the message, this is computed eagerly in the case of
/// plugin analyses.
is_passing: bool,
passed: bool,
/// The policy expression used for the plugin.
///
/// We use this when printing the result to help explain to the user
Expand Down Expand Up @@ -440,10 +439,10 @@ impl Analysis {
percent_constructor!(identity);
percent_constructor!(review);

pub fn plugin(name: String, is_passing: bool, policy_expr: String, message: String) -> Self {
pub fn plugin(name: String, passed: bool, policy_expr: String, message: String) -> Self {
Analysis::Plugin {
name,
is_passing,
passed,
policy_expr,
message,
}
Expand Down Expand Up @@ -478,9 +477,7 @@ impl Analysis {
| Entropy { passed, .. }
| Identity { passed, .. }
| Review { passed, .. }
| Plugin {
is_passing: passed, ..
} => *passed,
| Plugin { passed, .. } => *passed,
}
}

Expand Down Expand Up @@ -554,7 +551,14 @@ impl Analysis {
(false, true) => "too many concerning dependency names".to_string(),
(false, false) => "has concerning dependency names".to_string(),
},
Plugin { policy_expr, .. } => format!("failed to meet policy: ({policy_expr})"),
Plugin {
policy_expr,
passed,
..
} => match passed {
true => "satisfied associated policy".to_owned(),
false => format!("failed to meet policy: ({policy_expr})"),
},
}
}

Expand Down
2 changes: 1 addition & 1 deletion hipcheck/src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod spdx;

use crate::{
analysis::{score::ScoringProviderStorage, AnalysisProviderStorage},
cache::plugin_cache::HcPluginCache,
cache::plugin::HcPluginCache,
cli::Format,
config::{
AttacksConfigQueryStorage, CommitConfigQueryStorage, Config, ConfigSource,
Expand Down

0 comments on commit f447b7c

Please sign in to comment.