Skip to content

Commit

Permalink
Make clippy pedantic happy (#499)
Browse files Browse the repository at this point in the history
Signed-off-by: Sergio Castaño Arteaga <[email protected]>
  • Loading branch information
tegioz authored Nov 15, 2023
1 parent 2f63066 commit 7d8b10d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
5 changes: 3 additions & 2 deletions clotributor-apiserver/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct RouterState {
}

/// Setup HTTP server router.
pub(crate) fn setup_router(cfg: Arc<Config>, db: DynDB) -> Result<Router> {
pub(crate) fn setup_router(cfg: &Arc<Config>, db: DynDB) -> Result<Router> {
// Setup some paths
let static_path = cfg.get_string("apiserver.staticPath")?;
let index_path = Path::new(&static_path).join("index.html");
Expand Down Expand Up @@ -94,6 +94,7 @@ async fn search_issues(State(db): State<DynDB>, RawQuery(query): RawQuery) -> im
}

/// Helper for mapping any error into a `500 Internal Server Error` response.
#[allow(clippy::needless_pass_by_value)]
fn internal_error<E>(err: E) -> StatusCode
where
E: Into<Error> + Display,
Expand Down Expand Up @@ -211,6 +212,6 @@ mod tests {
.unwrap()
.build()
.unwrap();
setup_router(Arc::new(cfg), Arc::new(db)).unwrap()
setup_router(&Arc::new(cfg), Arc::new(db)).unwrap()
}
}
7 changes: 5 additions & 2 deletions clotributor-apiserver/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#![warn(clippy::all, clippy::pedantic)]
#![allow(clippy::doc_markdown)]

use crate::db::PgDB;
use anyhow::{Context, Result};
use clap::Parser;
Expand Down Expand Up @@ -37,7 +40,7 @@ async fn main() -> Result<()> {

// Setup logging
if std::env::var_os("RUST_LOG").is_none() {
std::env::set_var("RUST_LOG", "clotributor_apiserver=debug,tower_http=debug")
std::env::set_var("RUST_LOG", "clotributor_apiserver=debug,tower_http=debug");
}
let s = tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env());
match cfg.get_string("log.format").as_deref() {
Expand All @@ -56,7 +59,7 @@ async fn main() -> Result<()> {

// Setup and launch API HTTP server
debug!("setting up apiserver");
let router = handlers::setup_router(cfg.clone(), db)?;
let router = handlers::setup_router(&cfg.clone(), db)?;
let addr: SocketAddr = cfg.get_string("apiserver.addr")?.parse()?;
info!("apiserver started");
info!(%addr, "listening");
Expand Down
5 changes: 4 additions & 1 deletion clotributor-registrar/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#![warn(clippy::all, clippy::pedantic)]
#![allow(clippy::doc_markdown)]

use crate::db::PgDB;
use anyhow::{Context, Result};
use clap::Parser;
Expand Down Expand Up @@ -32,7 +35,7 @@ async fn main() -> Result<()> {

// Setup logging
if std::env::var_os("RUST_LOG").is_none() {
std::env::set_var("RUST_LOG", "clotributor_registrar=debug")
std::env::set_var("RUST_LOG", "clotributor_registrar=debug");
}
let s = tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env());
match cfg.get_string("log.format").as_deref() {
Expand Down
3 changes: 2 additions & 1 deletion clotributor-tracker/src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ impl repo_view::RepoViewRepository {
.expect("date to be valid");

// Prepare issue
#[allow(clippy::cast_possible_truncation)]
let mut issue = Issue {
issue_id: node.database_id.unwrap(),
title: node.title.clone(),
Expand Down Expand Up @@ -134,8 +135,8 @@ impl GH for GHGraphQL {
.saturating_sub(365.days())
.format(&Iso8601::DEFAULT)?;
let vars = repo_view::Variables {
owner,
repo,
owner,
issues_since,
};
let req_body = &RepoView::build_query(vars);
Expand Down
5 changes: 4 additions & 1 deletion clotributor-tracker/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#![warn(clippy::all, clippy::pedantic)]
#![allow(clippy::doc_markdown)]

use crate::{db::PgDB, github::GHGraphQL};
use anyhow::{Context, Result};
use clap::Parser;
Expand Down Expand Up @@ -34,7 +37,7 @@ async fn main() -> Result<()> {

// Setup logging
if std::env::var_os("RUST_LOG").is_none() {
std::env::set_var("RUST_LOG", "clotributor_tracker=debug")
std::env::set_var("RUST_LOG", "clotributor_tracker=debug");
}
let s = tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env());
match cfg.get_string("log.format").as_deref() {
Expand Down
8 changes: 5 additions & 3 deletions clotributor-tracker/src/tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub(crate) struct Repository {

impl Repository {
/// Update repository's GitHub data.
#[allow(clippy::cast_possible_truncation)]
fn update_gh_data(&mut self, gh_repo: &repo_view::RepoViewRepository) -> Result<bool> {
// Description
self.description = gh_repo.description.clone();
Expand Down Expand Up @@ -190,7 +191,7 @@ impl Issue {
/// Populate the issue with information extracted from the labels, like the
/// issue kind, its difficulty, etc.
pub(crate) fn populate_from_labels(&mut self) {
for label in self.labels.iter() {
for label in &self.labels {
// Area
if label.contains("docs") || label.contains("documentation") {
self.area = Some(IssueArea::Docs);
Expand Down Expand Up @@ -359,7 +360,7 @@ async fn track_repository(
let issues_in_db = db.get_repository_issues(repo.repository_id).await?;

// Register/update new or outdated issues
for issue in issues_in_gh.iter_mut() {
for issue in &mut issues_in_gh {
let digest_in_db = find_issue(issue.issue_id, &issues_in_db);
if issue.digest != digest_in_db {
db.register_issue(&repo, issue).await?;
Expand Down Expand Up @@ -651,6 +652,7 @@ mod tests {
}

#[tokio::test]
#[allow(clippy::too_many_lines)]
async fn run_register_one_issue_and_unregister_another_successfully() {
let cfg = setup_test_config(&[TOKEN1]);
let mut db = MockDB::new();
Expand Down Expand Up @@ -791,7 +793,7 @@ mod tests {
"creds.githubTokens",
tokens
.iter()
.map(|t| t.to_string())
.map(std::string::ToString::to_string)
.collect::<Vec<String>>(),
)
.unwrap()
Expand Down

0 comments on commit 7d8b10d

Please sign in to comment.