Merge pull request #651 from vbrandl/fix-pedantic-lints
Enable clippy::pedantic lints
This commit is contained in:
commit
88a3b3611b
8
.github/workflows/rust.yml
vendored
8
.github/workflows/rust.yml
vendored
@ -42,13 +42,9 @@ jobs:
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Clippy Linting
|
||||
run: cargo clippy --all-features -- -Dclippy::all
|
||||
# TODO
|
||||
# run: cargo clippy --all-features -- -Dclippy::all -Dclippy::pedantic
|
||||
run: cargo clippy --all-features -- -Dclippy::all -Dclippy::pedantic
|
||||
- name: Clippy Test Linting
|
||||
run: cargo clippy --tests -- -Dclippy::all
|
||||
# TODO
|
||||
# run: cargo clippy --tests -- -Dclippy::all -Dclippy::pedantic
|
||||
run: cargo clippy --tests -- -Dclippy::all -Dclippy::pedantic
|
||||
|
||||
|
||||
test:
|
||||
|
19
src/error.rs
19
src/error.rs
@ -41,17 +41,14 @@ impl ResponseError for Error {
|
||||
|
||||
fn error_response(&self) -> HttpResponse {
|
||||
let mut buf = Vec::new();
|
||||
match self {
|
||||
Error::BranchNotFound => {
|
||||
templates::p404_no_master_html(&mut buf, VERSION_INFO, 0).unwrap();
|
||||
HttpResponse::NotFound().content_type("text/html").body(buf)
|
||||
}
|
||||
_ => {
|
||||
templates::p500_html(&mut buf, VERSION_INFO, 0).unwrap();
|
||||
HttpResponse::InternalServerError()
|
||||
.content_type("text/html")
|
||||
.body(buf)
|
||||
}
|
||||
if let Error::BranchNotFound = self {
|
||||
templates::p404_no_master_html(&mut buf, VERSION_INFO, 0).unwrap();
|
||||
HttpResponse::NotFound().content_type("text/html").body(buf)
|
||||
} else {
|
||||
templates::p500_html(&mut buf, VERSION_INFO, 0).unwrap();
|
||||
HttpResponse::InternalServerError()
|
||||
.content_type("text/html")
|
||||
.body(buf)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -282,6 +282,7 @@ where
|
||||
}
|
||||
pull(&path)?;
|
||||
let (hoc, head, commits) = hoc(&service_url, &state.repos(), &state.cache(), branch)?;
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
let hoc_pretty = match NumberPrefix::decimal(hoc as f64) {
|
||||
NumberPrefix::Standalone(hoc) => hoc.to_string(),
|
||||
NumberPrefix::Prefixed(prefix, hoc) => format!("{hoc:.1}{prefix}"),
|
||||
|
@ -6,7 +6,7 @@ fn init() {
|
||||
dotenvy::dotenv().ok();
|
||||
openssl_probe::init_ssl_cert_env_vars();
|
||||
|
||||
telemetry::init_subscriber(telemetry::get_subscriber("hoc", "info"))
|
||||
telemetry::init_subscriber(telemetry::get_subscriber("hoc", "info"));
|
||||
}
|
||||
|
||||
#[actix_rt::main]
|
||||
|
@ -5,14 +5,14 @@ use tempfile::TempDir;
|
||||
#[test]
|
||||
fn no_repos() {
|
||||
let repos = TempDir::new().unwrap();
|
||||
assert_eq!(0, count_repositories(&repos).unwrap())
|
||||
assert_eq!(0, count_repositories(&repos).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_repos_for_provider() {
|
||||
let repos = TempDir::new().unwrap();
|
||||
let _provider = TempDir::new_in(&repos).unwrap();
|
||||
assert_eq!(0, count_repositories(&repos).unwrap())
|
||||
assert_eq!(0, count_repositories(&repos).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -20,7 +20,7 @@ fn no_repos_for_owner() {
|
||||
let repos = TempDir::new().unwrap();
|
||||
let provider = TempDir::new_in(&repos).unwrap();
|
||||
let _owner = TempDir::new_in(&provider).unwrap();
|
||||
assert_eq!(0, count_repositories(&repos).unwrap())
|
||||
assert_eq!(0, count_repositories(&repos).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -29,7 +29,7 @@ fn one_repo_for_owner() {
|
||||
let provider = TempDir::new_in(&repos).unwrap();
|
||||
let owner = TempDir::new_in(&provider).unwrap();
|
||||
let _repo = TempDir::new_in(&owner).unwrap();
|
||||
assert_eq!(1, count_repositories(&repos).unwrap())
|
||||
assert_eq!(1, count_repositories(&repos).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -39,7 +39,7 @@ fn two_repos_for_owner() {
|
||||
let owner = TempDir::new_in(&provider).unwrap();
|
||||
let _repo1 = TempDir::new_in(&owner).unwrap();
|
||||
let _repo2 = TempDir::new_in(&owner).unwrap();
|
||||
assert_eq!(2, count_repositories(&repos).unwrap())
|
||||
assert_eq!(2, count_repositories(&repos).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -51,7 +51,7 @@ fn two_repos_for_two_providers() {
|
||||
let provider2 = TempDir::new_in(&repos).unwrap();
|
||||
let owner2 = TempDir::new_in(&provider2).unwrap();
|
||||
let _repo2 = TempDir::new_in(&owner2).unwrap();
|
||||
assert_eq!(2, count_repositories(&repos).unwrap())
|
||||
assert_eq!(2, count_repositories(&repos).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -62,5 +62,5 @@ fn two_subdirs_in_one_repo() {
|
||||
let repo = TempDir::new_in(&owner).unwrap();
|
||||
let _subdir1 = TempDir::new_in(&repo).unwrap();
|
||||
let _subdir2 = TempDir::new_in(&repo).unwrap();
|
||||
assert_eq!(1, count_repositories(&repos).unwrap())
|
||||
assert_eq!(1, count_repositories(&repos).unwrap());
|
||||
}
|
||||
|
@ -25,14 +25,14 @@ pub async fn spawn_app() -> TestApp {
|
||||
let listener = TcpListener::bind("127.0.0.1:0").expect("Failed to bind random port");
|
||||
|
||||
let port = listener.local_addr().unwrap().port();
|
||||
let address = format!("http://127.0.0.1:{}", port);
|
||||
let address = format!("http://127.0.0.1:{port}");
|
||||
|
||||
let _repo_dir = tempdir().expect("Cannot create repo_dir");
|
||||
let _cache_dir = tempdir().expect("Cannot create cache_dir");
|
||||
let repo_dir = tempdir().expect("Cannot create repo_dir");
|
||||
let cache_dir = tempdir().expect("Cannot create cache_dir");
|
||||
|
||||
let mut settings = Settings::load().expect("Failed to read configuration.");
|
||||
settings.repodir = _repo_dir.path().to_path_buf();
|
||||
settings.cachedir = _cache_dir.path().to_path_buf();
|
||||
settings.repodir = repo_dir.path().to_path_buf();
|
||||
settings.cachedir = cache_dir.path().to_path_buf();
|
||||
|
||||
let server = hoc::run(listener, settings)
|
||||
.await
|
||||
@ -44,7 +44,7 @@ pub async fn spawn_app() -> TestApp {
|
||||
|
||||
TestApp {
|
||||
address,
|
||||
_repo_dir,
|
||||
_cache_dir,
|
||||
_repo_dir: repo_dir,
|
||||
_cache_dir: cache_dir,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user