aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-01-04 18:15:04 -0800
committerFuwn <[email protected]>2022-01-04 18:15:04 -0800
commitf12a352b5009dacf71a5d29ad158285a0d0ae7a2 (patch)
treeca42458b429d7e18a28b1deb5267a432736fbe25
parentfeat(main.rs): ratelimit (100 requests/minute) (diff)
downloadapi-f12a352b5009dacf71a5d29ad158285a0d0ae7a2.tar.xz
api-f12a352b5009dacf71a5d29ad158285a0d0ae7a2.zip
chore: stricter clippy
-rw-r--r--Cargo.toml2
-rw-r--r--src/main.rs10
-rw-r--r--src/structures.rs2
-rw-r--r--src/utils.rs9
4 files changed, 21 insertions, 2 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 09bbc68..2bbc990 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,7 +2,7 @@
name = "senpy-api"
version = "0.1.0"
authors = ["Fuwn <[email protected]>"]
-edition = "2018"
+edition = "2021"
#description = ""
readme = "README.md"
homepage = "https://github.com/senpy-club/api"
diff --git a/src/main.rs b/src/main.rs
index cd689ed..d0daf04 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,6 +2,16 @@
// SPDX-License-Identifier: GPL-3.0-only
#![feature(type_ascription)]
+#![deny(
+ warnings,
+ nonstandard_style,
+ unused,
+ future_incompatible,
+ rust_2018_idioms,
+ unsafe_code
+)]
+#![deny(clippy::all, clippy::pedantic)] // clippy::nursery
+#![recursion_limit = "128"]
#[macro_use]
extern crate actix_web;
diff --git a/src/structures.rs b/src/structures.rs
index 3b5a59e..7aa684c 100644
--- a/src/structures.rs
+++ b/src/structures.rs
@@ -1,6 +1,8 @@
// Copyright (C) 2021-2021 the senpy club
// SPDX-License-Identifier: GPL-3.0-only
+#![allow(clippy::used_underscore_binding)]
+
use serde_derive::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
diff --git a/src/utils.rs b/src/utils.rs
index 275978d..a55ddc6 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -6,6 +6,8 @@ use crate::{
structures::GitHubAPIResponse,
};
+/// # Errors
+/// if GitHub API is unresponsive
pub async fn github_api() -> Result<GitHubAPIResponse, Box<dyn std::error::Error>> {
let mut client = actix_web::client::Client::new()
.get(GITHUB_API_ENDPOINT)
@@ -33,10 +35,13 @@ pub async fn github_api() -> Result<GitHubAPIResponse, Box<dyn std::error::Error
)
}
+/// # Panics
+/// if GitHub API is unresponsive
pub async fn filter_languages() -> Vec<String> {
let mut languages = vec![];
for i in github_api().await.unwrap().tree {
+ #[allow(clippy::used_underscore_binding)]
if i._type == "tree" {
languages.push(i.path);
}
@@ -45,6 +50,8 @@ pub async fn filter_languages() -> Vec<String> {
languages
}
+/// # Panics
+/// if GitHub API is unresponsive
pub async fn filter_images_by_language(language: &str) -> Vec<String> {
let mut images = vec![];
@@ -55,7 +62,7 @@ pub async fn filter_images_by_language(language: &str) -> Vec<String> {
// TODO: Fix this with type_ascription
let x: Vec<&str> = i.path.split('/').collect();
if x[0] == language && i.path.contains('/') {
- images.push(format!("{}{}", GITHUB_USER_CONTENT, i.path))
+ images.push(format!("{}{}", GITHUB_USER_CONTENT, i.path));
}
}