summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKornel <kornel@geekhood.net>2019-04-14 00:39:52 +0100
committerKornel <kornel@geekhood.net>2019-04-14 02:10:48 +0100
commite7bccb59b615b7295c74d6779b88ce51f1329a66 (patch)
tree3fc2b339ccb098025afe82d3b3a486107fc05d67
parent5244f3fc4e772a695c6867406751eae3312e0397 (diff)
Rustfmt
-rw-r--r--categories/src/categories.rs4
-rw-r--r--crate_db/src/lib_crate_db.rs22
-rw-r--r--crate_files/src/tarball.rs20
-rw-r--r--front_end/src/bin/crate_pages.rs5
-rw-r--r--front_end/src/bin/website.rs4
-rw-r--r--front_end/src/cat_page.rs2
-rw-r--r--front_end/src/crate_page.rs1
-rw-r--r--front_end/src/front_end.rs2
-rw-r--r--front_end/src/home_page.rs2
-rw-r--r--front_end/src/search_page.rs2
-rw-r--r--front_end/src/urler.rs2
-rw-r--r--github_info/src/lib_github.rs16
-rw-r--r--kitchen_sink/src/deps_stats.rs6
-rw-r--r--kitchen_sink/src/git_crates_index.rs8
-rw-r--r--kitchen_sink/src/index.rs17
-rw-r--r--kitchen_sink/src/lib_kitchen_sink.rs15
-rw-r--r--kitchen_sink/src/yearly.rs11
-rw-r--r--ranking/src/lib_ranking.rs63
-rw-r--r--reindex/src/bin/reindex_crates.rs22
-rw-r--r--rich_crate/src/rich_crate.rs3
-rw-r--r--rich_crate/src/rich_crate_version.rs54
-rw-r--r--search_index/src/lib_search_index.rs2
-rw-r--r--server/src/main.rs226
-rw-r--r--udedokei/src/lib.rs10
24 files changed, 261 insertions, 258 deletions
diff --git a/categories/src/categories.rs b/categories/src/categories.rs
index fcc3aeb..891b235 100644
--- a/categories/src/categories.rs
+++ b/categories/src/categories.rs
@@ -4,9 +4,9 @@ use toml;
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate quick_error;
-use toml::value::{Value, Table};
-use std::collections::BTreeMap;
use std::borrow::Cow;
+use std::collections::BTreeMap;
+use toml::value::{Table, Value};
mod tuning;
pub use crate::tuning::*;
diff --git a/crate_db/src/lib_crate_db.rs b/crate_db/src/lib_crate_db.rs
index 490f7d6..a4360cd 100644
--- a/crate_db/src/lib_crate_db.rs
+++ b/crate_db/src/lib_crate_db.rs
@@ -1,7 +1,7 @@
-use std::fmt::Write;
+use categories;
use rusqlite::types::ToSql;
use rusqlite::NO_PARAMS;
-use categories;
+use std::fmt::Write;
use rusqlite;
#[macro_use]
@@ -20,12 +20,12 @@ use rich_crate::Repo;
use rich_crate::RichCrate;
use rich_crate::RichCrateVersion;
use rusqlite::*;
-use std::fs;
-use std::sync::Mutex;
use std::cell::RefCell;
use std::collections::HashMap;
use std::collections::HashSet;
+use std::fs;
use std::path::Path;
+use std::sync::Mutex;
use thread_local::ThreadLocal;
type FResult<T> = std::result::Result<T, failure::Error>;
@@ -687,12 +687,12 @@ impl CrateDb {
// sort by relevance to the category, downrank for being crappy (later also downranked for being removed from crates)
// low number of downloads is mostly by rank, rather than downloads
let mut query = conn.prepare_cached(
- "SELECT k.origin, (k.ranking * c.rank_weight) as w
+ "SELECT k.origin, (k.ranking * c.rank_weight) as w
FROM categories c
JOIN crates k on c.crate_id = k.id
WHERE c.slug = ?1
ORDER by w desc
- LIMIT ?2"
+ LIMIT ?2",
)?;
let args: &[&dyn ToSql] = &[&slug, &limit];
let q = query.query_map(args, |row| {
@@ -709,12 +709,12 @@ impl CrateDb {
// sort by relevance to the category, downrank for being crappy (later also downranked for being removed from crates)
// low number of downloads is mostly by rank, rather than downloads
let mut query = conn.prepare_cached(
- "SELECT k.origin, k.ranking as w
+ "SELECT k.origin, k.ranking as w
FROM crates k
LEFT JOIN categories c on c.crate_id = k.id
WHERE c.slug IS NULL
ORDER by w desc
- LIMIT ?1"
+ LIMIT ?1",
)?;
let args: &[&dyn ToSql] = &[&limit];
let q = query.query_map(args, |row| {
@@ -812,7 +812,7 @@ impl CrateDb {
if let Some(s) = c.description() {
if let Some(more) = c.alternative_description() {
return Some((1., format!("{}{}", s, more).into()));
- }
+ }
return Some((1., s.into()));
}
if let Ok(Some(r)) = c.readme() {
@@ -824,8 +824,8 @@ impl CrateDb {
return Some((0.5, sub.into()));
}
None
- }
- }
+ }
+}
pub enum RepoChange {
Removed { crate_name: String, weight: f64 },
diff --git a/crate_files/src/tarball.rs b/crate_files/src/tarball.rs
index f4cc746..96a6e3d 100644
--- a/crate_files/src/tarball.rs
+++ b/crate_files/src/tarball.rs
@@ -1,15 +1,15 @@
+use crate::is_readme_filename;
+use crate::readme_from_repo;
+use crate::{CrateFile, Result, UnarchiverError};
use cargo_toml::Manifest;
use libflate::gzip::Decoder;
use render_readme::Markup;
+use std::collections::HashSet;
use std::io;
use std::io::Read;
use std::path::Path;
use std::path::PathBuf;
-use std::collections::HashSet;
use tar::Archive;
-use crate::readme_from_repo;
-use crate::is_readme_filename;
-use crate::{Result, UnarchiverError, CrateFile};
use udedokei;
enum ReadAs {
@@ -57,14 +57,16 @@ pub fn read_archive(archive: impl Read, prefix: &Path) -> Result<CrateFile> {
ReadAs::ReadmeMarkdown(path_prefix)
}
},
- p => if let Some(lang) = is_source_code_file(p) {
- if lang.is_code() {
- ReadAs::GetStatsOfFile(lang)
+ p => {
+ if let Some(lang) = is_source_code_file(p) {
+ if lang.is_code() {
+ ReadAs::GetStatsOfFile(lang)
+ } else {
+ continue;
+ }
} else {
continue;
}
- } else {
- continue;
},
}
};
diff --git a/front_end/src/bin/crate_pages.rs b/front_end/src/bin/crate_pages.rs
index f9b7089..9eca978 100644
--- a/front_end/src/bin/crate_pages.rs
+++ b/front_end/src/bin/crate_pages.rs
@@ -1,8 +1,8 @@
-use kitchen_sink::RichCrate;
use front_end;
use kitchen_sink;
-use rayon;
+use kitchen_sink::RichCrate;
use kitchen_sink::{stopped, CrateData, KitchenSink, Origin};
+use rayon;
use render_readme::{Highlighter, ImageOptimAPIFilter, Renderer};
use rich_crate::RichCrateVersion;
use std::fs;
@@ -40,7 +40,6 @@ fn is_useful2(c: &RichCrateVersion) -> bool {
}
fn render(origin: &Origin, crates: &KitchenSink, path: &PathBuf, markup: &Renderer, always: bool) -> Result<(), failure::Error> {
-
let allver = crates.rich_crate(origin)?;
if !always && !is_useful1(&allver) {
return Ok(());
diff --git a/front_end/src/bin/website.rs b/front_end/src/bin/website.rs
index 97f123b..4644fe8 100644
--- a/front_end/src/bin/website.rs
+++ b/front_end/src/bin/website.rs
@@ -11,6 +11,7 @@ use categories::CategoryMap;
use failure::ResultExt;
use kitchen_sink::running;
use kitchen_sink::{CrateData, KitchenSink, Origin};
+use parking_lot::Mutex;
use rayon::prelude::*;
use render_readme::ImageOptimAPIFilter;
use render_readme::{Highlighter, Renderer};
@@ -20,8 +21,7 @@ use std::fs::File;
use std::io::BufWriter;
use std::path::Path;
use std::path::PathBuf;
-use std::sync::{Arc};
-use parking_lot::Mutex;
+use std::sync::Arc;
///
/// See home_page.rs for interesting bits
diff --git a/front_end/src/cat_page.rs b/front_end/src/cat_page.rs
index a652507..f708422 100644
--- a/front_end/src/cat_page.rs
+++ b/front_end/src/cat_page.rs
@@ -53,7 +53,7 @@ impl<'a> CatPage<'a> {
!self.cat.sub.is_empty() || !self.cat.siblings.is_empty()
}
- pub fn subcategories_and_siblings(&self) -> impl Iterator<Item=&Category> {
+ pub fn subcategories_and_siblings(&self) -> impl Iterator<Item = &Category> {
self.cat.sub.values().chain(self.cat.siblings.iter().flat_map(|slug| CATEGORIES.from_slug(slug)))
}
diff --git a/front_end/src/crate_page.rs b/front_end/src/crate_page.rs
index 021745d..5c5135b 100644
--- a/front_end/src/crate_page.rs
+++ b/front_end/src/crate_page.rs
@@ -573,7 +573,6 @@ impl<'a> CratePage<'a> {
Some(DownloadsGraph::new(self.kitchen_sink.weekly_downloads(self.all, 16).ok()?, self.ver.has_bin(), width, height))
}
-
pub fn downloads_per_month(&self) -> Option<usize> {
self.kitchen_sink.downloads_per_month(self.all.origin()).ok().and_then(|x| x)
}
diff --git a/front_end/src/front_end.rs b/front_end/src/front_end.rs
index 4464a1e..073deb5 100644
--- a/front_end/src/front_end.rs
+++ b/front_end/src/front_end.rs
@@ -12,8 +12,8 @@ mod cat_page;
mod crate_page;
mod download_graph;
mod home_page;
-mod search_page;
mod iter;
+mod search_page;
mod urler;
pub use crate::search_page::*;
diff --git a/front_end/src/home_page.rs b/front_end/src/home_page.rs
index c9a0be2..d17f736 100644
--- a/front_end/src/home_page.rs
+++ b/front_end/src/home_page.rs
@@ -1,11 +1,11 @@
#![allow(unused_imports)]
-use kitchen_sink::CrateAuthor;
use crate::Page;
use categories::Category;
use categories::CategoryMap;
use categories::CATEGORIES;
use failure;
use kitchen_sink::stopped;
+use kitchen_sink::CrateAuthor;
use kitchen_sink::{CrateData, KitchenSink};
use rayon::prelude::*;
use rich_crate::Origin;
diff --git a/front_end/src/search_page.rs b/front_end/src/search_page.rs
index 6552f54..2d8615b 100644
--- a/front_end/src/search_page.rs
+++ b/front_end/src/search_page.rs
@@ -1,8 +1,8 @@
use crate::templates;
use crate::Page;
use crate::Urler;
-use std::io::Write;
use render_readme::Renderer;
+use std::io::Write;
pub enum SearchKind<'a> {
Query(&'a str),
diff --git a/front_end/src/urler.rs b/front_end/src/urler.rs
index 367778e..130f27f 100644
--- a/front_end/src/urler.rs
+++ b/front_end/src/urler.rs
@@ -1,9 +1,9 @@
use categories::Category;
use kitchen_sink::CrateAuthor;
use kitchen_sink::UserType;
+use rich_crate::Origin;
use rich_crate::RichCrateVersion;
use rich_crate::RichDep;
-use rich_crate::Origin;
use urlencoding::encode;
/// One thing responsible for link URL scheme on the site.
diff --git a/github_info/src/lib_github.rs b/github_info/src/lib_github.rs
index 040b806..ea3455c 100644
--- a/github_info/src/lib_github.rs
+++ b/github_info/src/lib_github.rs
@@ -11,16 +11,16 @@ use simple_cache;
use std::path::Path;
-use urlencoding::encode;
-use repo_url::SimpleRepo;
use github_rs::client;
-use github_rs::{HeaderMap, StatusCode};
use github_rs::client::Executor;
-use std::time::{SystemTime, UNIX_EPOCH};
-use std::time::Duration;
-use std::thread;
-use simple_cache::TempCache;
use github_rs::headers::{rate_limit_remaining, rate_limit_reset};
+use github_rs::{HeaderMap, StatusCode};
+use repo_url::SimpleRepo;
+use simple_cache::TempCache;
+use std::thread;
+use std::time::Duration;
+use std::time::{SystemTime, UNIX_EPOCH};
+use urlencoding::encode;
mod model;
pub use crate::model::*;
@@ -264,7 +264,7 @@ impl GitHub {
}
Ok(None)
},
- Err(err) => Err(err)?
+ Err(err) => Err(err)?,
}
}
}
diff --git a/kitchen_sink/src/deps_stats.rs b/kitchen_sink/src/deps_stats.rs
index 80f9953..e409dbd 100644
--- a/kitchen_sink/src/deps_stats.rs
+++ b/kitchen_sink/src/deps_stats.rs
@@ -1,10 +1,10 @@
-use fxhash::FxHashSet;
-use fxhash::FxHashMap;
use crate::index::*;
use crate::KitchenSinkErr;
use crates_index::Crate;
-use rayon::prelude::*;
+use fxhash::FxHashMap;
+use fxhash::FxHashSet;
use parking_lot::Mutex;
+use rayon::prelude::*;
use string_interner::Sym;
pub struct DepsStats {
diff --git a/kitchen_sink/src/git_crates_index.rs b/kitchen_sink/src/git_crates_index.rs
index 696be34..89cf9b5 100644
--- a/kitchen_sink/src/git_crates_index.rs
+++ b/kitchen_sink/src/git_crates_index.rs
@@ -1,10 +1,10 @@
-use fxhash::FxHashSet;
-use crate::Origin;
use crate::KitchenSinkErr;
-use std::path::Path;
-use std::path::PathBuf;
+use crate::Origin;
+use fxhash::FxHashSet;
use std::fs::File;
use std::io::BufReader;
+use std::path::Path;
+use std::path::PathBuf;
pub struct GitIndex {
#[allow(unused)]
diff --git a/kitchen_sink/src/index.rs b/kitchen_sink/src/index.rs
index cd2ee3e..d6f680e 100644
--- a/kitchen_sink/src/index.rs
+++ b/kitchen_sink/src/index.rs
@@ -1,22 +1,22 @@
-use string_interner::StringInterner;
-use string_interner::Sym;
use crate::deps_stats::DepsStats;
+use crate::git_crates_index::*;
use crate::KitchenSink;
use crate::KitchenSinkErr;
-use crate::git_crates_index::*;
use crates_index;
use crates_index::Crate;
use crates_index::Version;
+use fxhash::{FxHashMap, FxHashSet};
use lazyonce::LazyOnce;
+use parking_lot::Mutex;
use rich_crate::Origin;
use semver::Version as SemVer;
use semver::VersionReq;
use std::iter;
use std::path::Path;
-use std::sync::RwLock;
use std::sync::Arc;
-use parking_lot::Mutex;
-use fxhash::{FxHashMap, FxHashSet};
+use std::sync::RwLock;
+use string_interner::StringInterner;
+use string_interner::Sym;
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub struct MiniVer {
@@ -34,7 +34,7 @@ impl MiniVer {
minor: self.minor.into(),
patch: self.patch.into(),
pre: self.pre.clone().into(),
- build: if self.build > 0 {vec![semver::Identifier::Numeric(self.build.into())]} else {Vec::new()},
+ build: if self.build > 0 { vec![semver::Identifier::Numeric(self.build.into())] } else { Vec::new() },
}
}
}
@@ -333,8 +333,7 @@ pub fn is_deprecated(name: &str) -> bool {
}
fn semver_parse(ver: &str) -> SemVer {
- SemVer::parse(ver)
- .unwrap_or_else(|_| SemVer::parse("0.0.0").expect("must parse"))
+ SemVer::parse(ver).unwrap_or_else(|_| SemVer::parse("0.0.0").expect("must parse"))
}
impl From<SemVer> for MiniVer {
diff --git a/kitchen_sink/src/lib_kitchen_sink.rs b/kitchen_sink/src/lib_kitchen_sink.rs
index 66976a0..f4dd541 100644
--- a/kitchen_sink/src/lib_kitchen_sink.rs
+++ b/kitchen_sink/src/lib_kitchen_sink.rs
@@ -1,14 +1,14 @@
#[macro_use] extern crate failure;
-use github_info::GitHubRepo;
use chrono::prelude::*;
-use rich_crate::DownloadWeek;
use crate_files;
use crate_git_checkout;
use crates_index;
use crates_io_client;
use docs_rs_client;
use github_info;
+use github_info::GitHubRepo;
+use rich_crate::DownloadWeek;
#[macro_use]
extern crate serde_derive;
@@ -34,31 +34,31 @@ pub use crate::ctrlcbreak::*;
pub use crates_index::Crate as CratesIndexCrate;
use crates_index::Version;
pub use crates_io_client::CrateDepKind;
-pub use crates_io_client::OwnerKind;
pub use crates_io_client::CrateDependency;
pub use crates_io_client::CrateMetaVersion;
use crates_io_client::CrateOwner;
pub use crates_io_client::CratesIoCrate;
+pub use crates_io_client::OwnerKind;
pub use github_info::User;
pub use github_info::UserType;
use rich_crate::CrateVersion;
+pub use rich_crate::Edition;
pub use rich_crate::Include;
+pub use rich_crate::MaintenanceStatus;
pub use rich_crate::Markup;
pub use rich_crate::Origin;
-pub use rich_crate::Edition;
pub use rich_crate::RichCrate;
pub use rich_crate::RichCrateVersion;
pub use rich_crate::RichDep;
-pub use rich_crate::MaintenanceStatus;
pub use rich_crate::{Cfg, Target};
-use fxhash::FxHashMap;
use cargo_toml::Manifest;
use cargo_toml::Package;
use chrono::DateTime;
use crate_db::{CrateDb, RepoChange};
use crate_files::CrateFile;
use failure::ResultExt;
+use fxhash::FxHashMap;
use github_info::GitCommitAuthor;
use itertools::Itertools;
use lazyonce::LazyOnce;
@@ -395,7 +395,6 @@ impl KitchenSink {
})
}
-
fn crates_io_meta(&self, origin: &Origin) -> CResult<CratesIoCrate> {
let krate = self.index.crates_io_crate_by_name(origin).context("rich_crate")?;
let name = krate.name();
@@ -675,7 +674,7 @@ impl KitchenSink {
None => {
warnings.insert(Warning::NotAPackage);
return warnings;
- }
+ },
};
if let Some(repo) = maybe_repo {
let res = crate_git_checkout::checkout(repo, &self.git_checkout_path)
diff --git a/kitchen_sink/src/yearly.rs b/kitchen_sink/src/yearly.rs
index 0fc4b9c..f47600a 100644
--- a/kitchen_sink/src/yearly.rs
+++ b/kitchen_sink/src/yearly.rs
@@ -1,10 +1,9 @@
-
+use parking_lot::Mutex;
use simple_cache::TempCache;
-use std::collections::HashMap;
use std::collections::hash_map::Entry::*;
-use std::path::PathBuf;
-use parking_lot::Mutex;
+use std::collections::HashMap;
use std::fmt;
+use std::path::PathBuf;
/// Downloads each day of the year
#[derive(Serialize, Deserialize, Clone)]
@@ -76,8 +75,8 @@ impl Default for VersionMap {
}
// Serde workaround
-use serde::ser::{Serializer, SerializeTuple};
-use serde::de::{Deserializer, Visitor, SeqAccess, Error};
+use serde::de::{Deserializer, Error, SeqAccess, Visitor};
+use serde::ser::{SerializeTuple, Serializer};
trait BigArray<'de>: Sized {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
diff --git a/ranking/src/lib_ranking.rs b/ranking/src/lib_ranking.rs
index 2166d9a..e7ac62d 100644
--- a/ranking/src/lib_ranking.rs
+++ b/ranking/src/lib_ranking.rs
@@ -1,14 +1,14 @@
mod scorer;
+pub use self::scorer::*;
+use cargo_toml::MaintenanceStatus;
+use chrono::prelude::*;
use render_readme::Handle;
use render_readme::NodeData;
-use rich_crate::Edition;
use rich_crate::Author;
-use rich_crate::CrateVersion;
-use cargo_toml::MaintenanceStatus;
use rich_crate::CrateOwner;
+use rich_crate::CrateVersion;
+use rich_crate::Edition;
use semver::Version as SemVer;
-pub use self::scorer::*;
-use chrono::prelude::*;
/// Only changes when a new version is released
pub struct CrateVersionInputs<'a> {
@@ -42,8 +42,6 @@ pub struct CrateVersionInputs<'a> {
pub total_code_lines: u32,
pub rust_comment_lines: u32,
pub rust_code_lines: u32,
-
-
// (relative) weight of dependencies?
// rust loc
@@ -73,7 +71,6 @@ pub struct CrateTemporalInputs<'a> {
pub number_of_indirect_reverse_deps: u32,
/// Includes non-optional (i.e. it's the upper bound, not just the optional ones)
pub number_of_indirect_reverse_optional_deps: u32,
-
// most recent commit
// avg time issues are left unanswered?
// pub crate_score_context_free: f64,
@@ -169,30 +166,30 @@ fn is_badge_url(url: &str) -> bool {
.trim_start_matches("ci.")
.trim_start_matches("build.");
url.starts_with("appveyor.com") ||
- url.starts_with("badge.") ||
- url.starts_with("badgen.") ||
- url.starts_with("badges.") ||
- url.starts_with("codecov.io") ||
- url.starts_with("coveralls.io") ||
- url.starts_with("docs.rs") ||
- url.starts_with("gitlab.com") ||
- url.starts_with("isitmaintained.com") ||
- url.starts_with("meritbadge") ||
- url.starts_with("microbadger") ||
- url.starts_with("ohloh.net") ||
- url.starts_with("openhub.net") ||
- url.starts_with("repostatus.org") ||
- url.starts_with("shields.io") ||
- url.starts_with("snapcraft.io") ||
- url.starts_with("spearow.io") ||
- url.starts_with("travis-ci.") ||
- url.starts_with("zenodo.org") ||
- url.ends_with("?branch=master") ||
- url.ends_with("/pipeline.svg") ||
- url.ends_with("/coverage.svg") ||
- url.ends_with("/build.svg") ||
- url.ends_with("badge.svg") ||
- url.ends_with("badge.png")
+ url.starts_with("badge.") ||
+ url.starts_with("badgen.") ||
+ url.starts_with("badges.") ||
+ url.starts_with("codecov.io") ||
+ url.starts_with("coveralls.io") ||
+ url.starts_with("docs.rs") ||
+ url.starts_with("gitlab.com") ||
+ url.starts_with("isitmaintained.com") ||
+ url.starts_with("meritbadge") ||
+ url.starts_with("microbadger") ||
+ url.starts_with("ohloh.net") ||
+ url.starts_with("openhub.net") ||
+ url.starts_with("repostatus.org") ||
+ url.starts_with("shields.io") ||
+ url.starts_with("snapcraft.io") ||
+ url.starts_with("spearow.io") ||
+ url.starts_with("travis-ci.") ||
+ url.starts_with("zenodo.org") ||
+ url.ends_with("?branch=master") ||
+ url.ends_with("/pipeline.svg") ||
+ url.ends_with("/coverage.svg") ||
+ url.ends_with("/build.svg") ||
+ url.ends_with("badge.svg") ||
+ url.ends_with("badge.png")
}
fn fill_props(node: &Handle, props: &mut MarkupProps, mut in_code: bool) {
@@ -347,7 +344,7 @@ pub fn crate_score_temporal(cr: &CrateTemporalInputs) -> Score {
Err(e) => {
eprintln!("Release time parse error: {}", e);
0.
- }
+ },
};
score.frac("Freshness of latest release", 8, freshness_score);
score.frac("Freshness of deps", 8, cr.dependency_freshness.iter()
diff --git a/reindex/src/bin/reindex_crates.rs b/reindex/src/bin/reindex_crates.rs
index d8b5557..bf8ab72 100644
--- a/reindex/src/bin/reindex_crates.rs
+++ b/reindex/src/bin/reindex_crates.rs
@@ -1,17 +1,17 @@
-use ranking::CrateTemporalInputs;
-use ranking::CrateVersionInputs;
-use kitchen_sink::RichCrate;
-use render_readme::{Renderer, Markup};
use either::*;
-use search_index::*;
use failure;
-use kitchen_sink::{self, stopped, MaintenanceStatus, CrateData, KitchenSink, Origin, RichCrateVersion, Include};
+use kitchen_sink::RichCrate;
+use kitchen_sink::{self, stopped, CrateData, Include, KitchenSink, MaintenanceStatus, Origin, RichCrateVersion};
+use parking_lot::Mutex;
use rand::{seq::SliceRandom, thread_rng};
+use ranking::CrateTemporalInputs;
+use ranking::CrateVersionInputs;
use rayon;
-use std::sync::mpsc;
+use render_readme::{Markup, Renderer};
+use search_index::*;
use std::collections::HashSet;
+use std::sync::mpsc;
use std::sync::Arc;
-use parking_lot::Mutex;
fn main() {
let crates = Arc::new(match kitchen_sink::KitchenSink::new_default() {
@@ -116,7 +116,6 @@ fn index_crate(crates: &KitchenSink, c: &Origin, renderer: &Renderer, search_sen
Ok(v)
}
-
fn index_search(indexer: &mut Indexer, k: &RichCrateVersion, downloads_per_month: usize, score: f64) -> Result<(), failure::Error> {
let keywords: Vec<_> = k.keywords(Include::Cleaned).collect();
@@ -174,7 +173,8 @@ fn crate_overall_score(crates: &KitchenSink, all: &RichCrate, k: &RichCrateVersi
has_badges: k.has_badges(),
maintenance: k.maintenance(),
is_nightly: k.is_nightly(),
- }).total();
+ })
+ .total();
let downloads_per_month = crates.downloads_per_month_or_equivalent(all.origin()).expect("dl numbers").unwrap_or(0) as u32;
let dependency_freshness = if let Ok((runtime, _, build)) = k.direct_dependencies() {
@@ -223,7 +223,6 @@ fn crate_overall_score(crates: &KitchenSink, all: &RichCrate, k: &RichCrateVersi
}
let removals_divisor = if let Some(removals_weighed) = crates.crate_removals(k.origin()) {
-
// count some indirect/optional deps in case removals have been due to moving the crate behind another facade
// +20 is a fudge factor to smooth out nosiy data for rarely used crates.
// We don't care about small amount of removals, only mass exodus from big dead crates.
@@ -280,7 +279,6 @@ fn is_deprecated(k: &RichCrateVersion) -> bool {
false
}
-
fn print_res<T>(res: Result<T, failure::Error>) {
if let Err(e) = res {
eprintln!("••• Error: {}", e);
diff --git a/rich_crate/src/rich_crate.rs b/rich_crate/src/rich_crate.rs
index 9c72094..2284e87 100644
--- a/rich_crate/src/rich_crate.rs
+++ b/rich_crate/src/rich_crate.rs
@@ -1,6 +1,6 @@
+use crate::Origin;
pub use crates_io_client::CrateOwner;
pub use crates_io_client::DownloadWeek;
-use crate::Origin;
/// Struct representing all versions of the crate
/// (metadata that is version-independent or for all versions).
@@ -24,7 +24,6 @@ pub struct CrateVersion {
// pub features: HashMap<String, Vec<String>>,
pub yanked: bool,
// pub license: Option<String>, // "MIT",
-
}
impl RichCrate {
diff --git a/rich_crate/src/rich_crate_version.rs b/rich_crate/src/rich_crate_version.rs
index 73dadcb..a23f284 100644
--- a/rich_crate/src/rich_crate_version.rs
+++ b/rich_crate/src/rich_crate_version.rs
@@ -1,18 +1,18 @@
-pub use cargo_toml::{Edition, FeatureSet, TargetDepsSet, DepsSet, MaintenanceStatus};
-use cargo_toml::{Dependency, Package, Product, Manifest};
+use crate::Author;
+use crate::Markup;
+use crate::Origin;
+use crate::Readme;
+use cargo_toml::{Dependency, Manifest, Package, Product};
+pub use cargo_toml::{DepsSet, Edition, FeatureSet, MaintenanceStatus, TargetDepsSet};
use categories::Categories;
use crates_index::Version;
use repo_url::Repo;
use semver;
-use udedokei;
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::collections::HashSet;
-use crate::Author;
-use crate::Origin;
-use crate::Readme;
-use crate::Markup;
+use udedokei;
pub use parse_cfg::ParseError as CfgErr;
pub use parse_cfg::{Cfg, Target};
@@ -78,7 +78,12 @@ impl RichCrateVersion {
has_examples: !manifest.example.is_empty(),
has_tests: !manifest.test.is_empty(),
has_benches: !manifest.bench.is_empty(),
- has_badges: manifest.badges.appveyor.is_some() || manifest.badges.circle_ci.is_some() || manifest.badges.gitlab.is_some() || manifest.badges.travis_ci.is_some() || manifest.badges.codecov.is_some() || manifest.badges.coveralls.is_some(),
+ has_badges: manifest.badges.appveyor.is_some() ||
+ manifest.badges.circle_ci.is_some() ||
+ manifest.badges.gitlab.is_some() ||
+ manifest.badges.travis_ci.is_some() ||
+ manifest.badges.codecov.is_some() ||
+ manifest.badges.coveralls.is_some(),
maintenance: manifest.badges.maintenance.status,
features: manifest.features,
target: manifest.target,
@@ -178,8 +183,9 @@ impl RichCrateVersion {
Include::RawCargoTomlOnly => {
let tmp: Vec<_> = self.package.categories.iter().map(From::from).collect();
tmp
- }
- }.into_iter()
+ },
+ }
+ .into_iter()
}
pub fn license(&self) -> Option<&str> {
@@ -210,7 +216,8 @@ impl RichCrateVersion {
},
Include::Cleaned => self.derived.keywords.as_ref().unwrap_or(&self.package.keywords),
}
- .iter().map(|s| s.as_str())
+ .iter()
+ .map(|s| s.as_str())
}
/// Globally unique URL-like string identifying source & the crate within that source
@@ -364,14 +371,15 @@ impl RichCrateVersion {
pub fn is_sys(&self) -> bool {
!self.has_bin() &&
- self.has_buildrs() &&
- !self.is_proc_macro() &&
- (self.links().is_some() || (
- self.short_name().ends_with("-sys") ||
- self.short_name().ends_with("_sys") ||
- self.category_slugs(Include::RawCargoTomlOnly).any(|c| c == "external-ffi-bindings")
- // _dll suffix is a false positive
- ))
+ self.has_buildrs() &&
+ !self.is_proc_macro() &&
+ (self.links().is_some() ||
+ (
+ self.short_name().ends_with("-sys") ||
+ self.short_name().ends_with("_sys") ||
+ self.category_slugs(Include::RawCargoTomlOnly).any(|c| c == "external-ffi-bindings")
+ // _dll suffix is a false positive
+ ))
}
pub fn has_runtime_deps(&self) -> bool {
@@ -423,7 +431,6 @@ impl RichCrateVersion {
add_targets(&mut dev, &plat.dev_dependencies, target)?;
}
-
// Don't display deps twice if they're required anyway
for dep in normal.keys() {
dev.remove(dep);
@@ -479,8 +486,11 @@ impl RichCrateVersion {
if cat == "parsers" {
if self.direct_dependencies.keys().any(|k| k == "nom" || k == "peresil" || k == "combine") ||
self.package.keywords.iter().any(|k| match k.to_ascii_lowercase().as_ref() {
- "asn1" | "tls" | "idl" | "crawler" | "xml" | "nom" | "json" | "logs" | "elf" | "uri" | "html" | "protocol" | "semver" | "ecma" | "chess" | "vcard" | "exe" | "fasta" => true, _ => false
- }) {
+ "asn1" | "tls" | "idl" | "crawler" | "xml" | "nom" | "json" | "logs" | "elf" | "uri" | "html" | "protocol" | "semver" | "ecma" |
+ "chess" | "vcard" | "exe" | "fasta" => true,
+ _ => false,
+ })
+ {
*cat = "parser-implementations".into();
}
}
diff --git a/search_index/src/lib_search_index.rs b/search_index/src/lib_search_index.rs
index dbfb514..436222b 100644
--- a/search_index/src/lib_search_index.rs
+++ b/search_index/src/lib_search_index.rs
@@ -1,5 +1,5 @@
-use std::{fs, path::Path};
use std::cmp::Ordering;
+use std::{fs, path::Path};
use tantivy::{self, collector::TopDocs, query::QueryParser, schema::*, Index, IndexWriter};
const CRATE_SCORE_MAX: f64 = 1000000.0;