aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2019-05-02 23:04:07 +0000
committerGitHub <noreply@github.com>2019-05-02 23:04:07 +0000
commitc0ef2fbf569047185ea472702523d7c1b54c030a (patch)
tree478ff421f74e21d26f8e18ec8f030f84ce57a183
parentAdd note about empty arrays (diff)
parentMerge branch 'new-clippy-experiment' into new-clippy (diff)
downloadminiserve-c0ef2fbf569047185ea472702523d7c1b54c030a.tar.gz
miniserve-c0ef2fbf569047185ea472702523d7c1b54c030a.zip
Merge pull request #99 from KSXGitHub/new-clippy
A better Clippy integration
-rw-r--r--.travis.yml7
-rw-r--r--src/auth.rs4
-rw-r--r--src/listing.rs1
-rw-r--r--src/main.rs4
-rw-r--r--src/renderer.rs1
5 files changed, 12 insertions, 5 deletions
diff --git a/.travis.yml b/.travis.yml
index c1bf8f9..b436fb3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -47,6 +47,9 @@ matrix:
- BIN_NAME=miniserve
- PROPER_NAME=miniserve-osx-x86_64
os: osx
+ - rust: nightly-2019-04-26
+ env:
+ - CLIPPY=true
before_install:
- rustup self update
@@ -55,10 +58,12 @@ before_install:
install:
# On Apple, the default target is already the right one.
- if [[ -n $TARGET && $TARGET != "x86_64-apple-darwin" ]]; then rustup target add $TARGET; fi
+ - if [[ -n $CLIPPY ]]; then rustup component add clippy; fi
script:
# If this is a normal, non-deployment build...
- - if [[ -z $TARGET ]]; then cargo build --verbose && RUST_BACKTRACE=1 cargo test; fi
+ - if [[ -z $TARGET && -z $CLIPPY ]]; then cargo build --verbose && RUST_BACKTRACE=1 cargo test; fi
+ - if [[ -n $CLIPPY ]]; then cargo clippy -- --deny clippy::all; fi
- if [[ -n $TARGET ]]; then cargo build --verbose --release --target $TARGET; fi
before_deploy:
diff --git a/src/auth.rs b/src/auth.rs
index 8e6532b..e526923 100644
--- a/src/auth.rs
+++ b/src/auth.rs
@@ -75,8 +75,8 @@ pub fn match_auth(basic_auth: BasicAuthParams, required_auth: &RequiredAuth) ->
}
/// Return `true` if hashing of `password` by `T` algorithm equals to `hash`
-pub fn compare_hash<T: Digest>(password: String, hash: &Vec<u8>) -> bool {
- get_hash::<T>(password) == *hash
+pub fn compare_hash<T: Digest>(password: String, hash: &[u8]) -> bool {
+ get_hash::<T>(password) == hash
}
/// Get hash of a `text`
diff --git a/src/listing.rs b/src/listing.rs
index a030feb..87fd8a8 100644
--- a/src/listing.rs
+++ b/src/listing.rs
@@ -123,6 +123,7 @@ pub fn file_handler(req: &HttpRequest<crate::MiniserveConfig>) -> Result<fs::Nam
/// List a directory and renders a HTML file accordingly
/// Adapted from https://docs.rs/actix-web/0.7.13/src/actix_web/fs.rs.html#564
+#[allow(clippy::identity_conversion)]
pub fn directory_listing<S>(
dir: &fs::Directory,
req: &HttpRequest<S>,
diff --git a/src/main.rs b/src/main.rs
index c1bb0aa..ea58fc6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -83,12 +83,12 @@ fn run() -> Result<(), ContextualError> {
&& miniserve_config
.path
.symlink_metadata()
- .map_err(|e| {
+ .map_err(|e|
ContextualError::IOError(
"Failed to retrieve symlink's metadata".to_string(),
e,
)
- })?
+ )?
.file_type()
.is_symlink()
{
diff --git a/src/renderer.rs b/src/renderer.rs
index b292e70..69224cf 100644
--- a/src/renderer.rs
+++ b/src/renderer.rs
@@ -9,6 +9,7 @@ use crate::listing::{Entry, SortingMethod, SortingOrder};
use crate::themes::ColorScheme;
/// Renders the file listing
+#[allow(clippy::too_many_arguments)]
pub fn page(
serve_path: &str,
entries: Vec<Entry>,