mirror of
https://github.com/deps-rs/deps.rs.git
synced 2024-11-22 10:26:30 +00:00
Remove dev-dependencies from badge (#70)
* Remove dev-dependencies from badge * Document behavior of functions on AnalyzedDependencies
This commit is contained in:
parent
a717c9afcc
commit
0a22c413b3
3 changed files with 73 additions and 11 deletions
|
@ -100,12 +100,38 @@ impl AnalyzeDependenciesOutcome {
|
||||||
self.crates.iter().any(|&(_, ref deps)| deps.any_outdated())
|
self.crates.iter().any(|&(_, ref deps)| deps.any_outdated())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(feliix42): Why is this different from the any_outdated() function above?
|
||||||
|
/// Checks if any insecure main or build dependencies exist in the scanned crates
|
||||||
pub fn any_insecure(&self) -> bool {
|
pub fn any_insecure(&self) -> bool {
|
||||||
self.crates
|
self.crates
|
||||||
.iter()
|
.iter()
|
||||||
.any(|&(_, ref deps)| deps.count_insecure() > 0)
|
.any(|&(_, ref deps)| deps.count_insecure() > 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Checks if any dev-dependencies in the scanned crates are either outdated or insecure
|
||||||
|
pub fn any_dev_issues(&self) -> bool {
|
||||||
|
self.crates
|
||||||
|
.iter()
|
||||||
|
.any(|&(_, ref deps)| deps.any_dev_issues())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the number of outdated dev-dependencies
|
||||||
|
pub fn count_dev_outdated(&self) -> usize {
|
||||||
|
self.crates
|
||||||
|
.iter()
|
||||||
|
.map(|&(_, ref deps)| deps.count_dev_outdated())
|
||||||
|
.sum()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the number of insecure dev-dependencies
|
||||||
|
pub fn count_dev_insecure(&self) -> usize {
|
||||||
|
self.crates
|
||||||
|
.iter()
|
||||||
|
.map(|&(_, ref deps)| deps.count_dev_insecure())
|
||||||
|
.sum()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the number of outdated and the number of total main and build dependencies
|
||||||
pub fn outdated_ratio(&self) -> (usize, usize) {
|
pub fn outdated_ratio(&self) -> (usize, usize) {
|
||||||
self.crates
|
self.crates
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -152,41 +152,58 @@ impl AnalyzedDependencies {
|
||||||
AnalyzedDependencies { main, dev, build }
|
AnalyzedDependencies { main, dev, build }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Counts the total number of main and build dependencies
|
||||||
pub fn count_total(&self) -> usize {
|
pub fn count_total(&self) -> usize {
|
||||||
self.main.len() + self.dev.len() + self.build.len()
|
self.main.len() + self.build.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the number of outdated main and build dependencies
|
||||||
pub fn count_outdated(&self) -> usize {
|
pub fn count_outdated(&self) -> usize {
|
||||||
let main_outdated = self
|
let main_outdated = self
|
||||||
.main
|
.main
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|&(_, dep)| dep.is_outdated())
|
.filter(|&(_, dep)| dep.is_outdated())
|
||||||
.count();
|
.count();
|
||||||
let dev_outdated = self
|
|
||||||
.dev
|
|
||||||
.iter()
|
|
||||||
.filter(|&(_, dep)| dep.is_outdated())
|
|
||||||
.count();
|
|
||||||
let build_outdated = self
|
let build_outdated = self
|
||||||
.build
|
.build
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|&(_, dep)| dep.is_outdated())
|
.filter(|&(_, dep)| dep.is_outdated())
|
||||||
.count();
|
.count();
|
||||||
main_outdated + dev_outdated + build_outdated
|
main_outdated + build_outdated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the number of insecure main and build dependencies
|
||||||
pub fn count_insecure(&self) -> usize {
|
pub fn count_insecure(&self) -> usize {
|
||||||
let main_insecure = self.main.iter().filter(|&(_, dep)| dep.insecure).count();
|
let main_insecure = self.main.iter().filter(|&(_, dep)| dep.insecure).count();
|
||||||
let dev_insecure = self.dev.iter().filter(|&(_, dep)| dep.insecure).count();
|
|
||||||
let build_insecure = self.build.iter().filter(|&(_, dep)| dep.insecure).count();
|
let build_insecure = self.build.iter().filter(|&(_, dep)| dep.insecure).count();
|
||||||
main_insecure + dev_insecure + build_insecure
|
main_insecure + build_insecure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Checks if any outdated main or build dependencies exist
|
||||||
pub fn any_outdated(&self) -> bool {
|
pub fn any_outdated(&self) -> bool {
|
||||||
let main_any_outdated = self.main.iter().any(|(_, dep)| dep.is_outdated());
|
let main_any_outdated = self.main.iter().any(|(_, dep)| dep.is_outdated());
|
||||||
let dev_any_outdated = self.dev.iter().any(|(_, dep)| dep.is_outdated());
|
|
||||||
let build_any_outdated = self.build.iter().any(|(_, dep)| dep.is_outdated());
|
let build_any_outdated = self.build.iter().any(|(_, dep)| dep.is_outdated());
|
||||||
main_any_outdated || dev_any_outdated || build_any_outdated
|
main_any_outdated || build_any_outdated
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Counts the number of outdated `dev-dependencies`
|
||||||
|
pub fn count_dev_outdated(&self) -> usize {
|
||||||
|
self.dev
|
||||||
|
.iter()
|
||||||
|
.filter(|&(_, dep)| dep.is_outdated())
|
||||||
|
.count()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Counts the number of insecure `dev-dependencies`
|
||||||
|
pub fn count_dev_insecure(&self) -> usize {
|
||||||
|
self.dev.iter().filter(|&(_, dep)| dep.insecure).count()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns `true` if any dev-dependencies are either insecure or outdated.
|
||||||
|
pub fn any_dev_issues(&self) -> bool {
|
||||||
|
self.dev
|
||||||
|
.iter()
|
||||||
|
.any(|(_, dep)| dep.is_outdated() || dep.insecure)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,22 @@ fn render_title(subject_path: &SubjectPath) -> Markup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn render_dev_dependency_box(outcome: &AnalyzeDependenciesOutcome) -> Markup {
|
||||||
|
let insecure = outcome.count_dev_insecure();
|
||||||
|
let outdated = outcome.count_dev_outdated();
|
||||||
|
let text = if insecure > 0 {
|
||||||
|
format!("{} insecure development dependencies", insecure)
|
||||||
|
} else {
|
||||||
|
format!("{} outdated development dependencies", outdated)
|
||||||
|
};
|
||||||
|
|
||||||
|
html! {
|
||||||
|
div class="notification is-warning" {
|
||||||
|
p { "This project contains " b { (text) } "." }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn render_failure(subject_path: SubjectPath) -> Markup {
|
fn render_failure(subject_path: SubjectPath) -> Markup {
|
||||||
html! {
|
html! {
|
||||||
section class="hero is-light" {
|
section class="hero is-light" {
|
||||||
|
@ -192,6 +208,9 @@ fn render_success(
|
||||||
}
|
}
|
||||||
section class="section" {
|
section class="section" {
|
||||||
div class="container" {
|
div class="container" {
|
||||||
|
@if analysis_outcome.any_dev_issues() {
|
||||||
|
(render_dev_dependency_box(&analysis_outcome))
|
||||||
|
}
|
||||||
@for (crate_name, deps) in analysis_outcome.crates {
|
@for (crate_name, deps) in analysis_outcome.crates {
|
||||||
(dependency_tables(crate_name, deps))
|
(dependency_tables(crate_name, deps))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue