Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
Linting Configuration Cleanup
Merged lorenz opened 15 days ago

A collection of changes that all work to decrease the amount of linter customization we need to maintain.

34 files changed +32 -74 547a7537 91b2fd89
modified Cargo.toml
@@ -84,15 +84,13 @@ zeroize = "1.5.7"
git-ref-format-core = { version = "0.6.0", default-features = false }
radicle-surf = "0.27.1"

-
[workspace.lints]
-
clippy.type_complexity = "allow"
-
clippy.enum_variant_names = "allow"
-
clippy.indexing_slicing = "deny"
-
clippy.fallible_impl_from = "deny"
-
clippy.wildcard_enum_match_arm = "deny"
-
clippy.unneeded_field_pattern = "deny"
-
clippy.fn_params_excessive_bools = "deny"
-
clippy.must_use_candidate = "deny"
+
[workspace.lints.clippy]
+
fallible_impl_from = "deny"
+
fn_params_excessive_bools = "deny"
+
indexing_slicing = "deny"
+
must_use_candidate = "deny"
+
unneeded_field_pattern = "deny"
+
wildcard_enum_match_arm = "deny"

[profile.container]
inherits = "release"
added clippy.toml
@@ -0,0 +1 @@
+
allow-unwrap-in-tests = true

\ No newline at end of file
modified crates/radicle-cli-test/src/lib.rs
@@ -1,4 +1,3 @@
-
#![allow(clippy::collapsible_else_if)]
use std::borrow::Cow;
use std::collections::HashMap;
use std::path::{Path, PathBuf};
modified crates/radicle-cli/src/commands/auth.rs
@@ -1,4 +1,3 @@
-
#![allow(clippy::or_fun_call)]
mod args;

use std::str::FromStr;
modified crates/radicle-cli/src/commands/checkout.rs
@@ -1,4 +1,3 @@
-
#![allow(clippy::box_default)]
mod args;

use std::path::PathBuf;
modified crates/radicle-cli/src/commands/init.rs
@@ -1,6 +1,3 @@
-
#![allow(clippy::or_fun_call)]
-
#![allow(clippy::collapsible_else_if)]
-

mod args;

pub use args::Args;
modified crates/radicle-cli/src/commands/inspect.rs
@@ -1,5 +1,3 @@
-
#![allow(clippy::or_fun_call)]
-

mod args;

use std::collections::HashMap;
modified crates/radicle-cli/src/commands/patch/list.rs
@@ -39,10 +39,8 @@ pub fn run(
                continue;
            }
        };
-
        if !authors.is_empty() {
-
            if !authors.contains(patch.author().id()) {
-
                continue;
-
            }
+
        if !authors.is_empty() && !authors.contains(patch.author().id()) {
+
            continue;
        }
        all.push((id, patch));
    }
modified crates/radicle-cli/src/commands/patch/review/builder.rs
@@ -139,6 +139,7 @@ impl FromStr for ReviewAction {
/// A single review item. Can be a hunk or eg. a file move.
/// Files are usually split into multiple review items.
#[derive(Debug)]
+
#[allow(clippy::enum_variant_names)]
pub enum ReviewItem {
    FileAdded {
        path: PathBuf,
@@ -197,6 +198,7 @@ impl ReviewItem {
        self.hunk().and_then(|h| HunkHeader::try_from(h).ok())
    }

+
    #[allow(clippy::type_complexity)]
    fn paths(&self) -> (Option<(&Path, Oid)>, Option<(&Path, Oid)>) {
        match self {
            Self::FileAdded { path, new, .. } => (None, Some((path, Oid::from(*new.oid)))),
modified crates/radicle-cli/src/lib.rs
@@ -1,5 +1,3 @@
-
#![allow(clippy::collapsible_if)]
-
#![allow(clippy::or_fun_call)]
#![allow(clippy::too_many_arguments)]
pub mod commands;
pub mod git;
modified crates/radicle-cob/src/lib.rs
@@ -1,6 +1,6 @@
// Copyright © 2021 The Radicle Link Contributors

-
#![warn(clippy::unwrap_used)]
+
#![deny(clippy::unwrap_used)]
//! # Collaborative Objects
//!
//! Collaborative objects are graphs of CRDTs.
modified crates/radicle-node/src/test/peer.rs
@@ -1,4 +1,3 @@
-
#![allow(dead_code)]
use std::collections::HashSet;
use std::iter;
use std::net;
modified crates/radicle-node/src/test/simulator.rs
@@ -1,7 +1,4 @@
//! A simple P2P network simulator. Acts as the _reactor_, but without doing any I/O.
-
#![allow(clippy::collapsible_if)]
-
#![allow(dead_code)]
-
#![allow(clippy::type_complexity)]

use std::cell::RefCell;
use std::collections::{BTreeMap, BTreeSet, HashSet, VecDeque};
@@ -388,10 +385,8 @@ where
                        let conn = (node, id);

                        let attempted = link.is_outbound() && self.attempts.remove(&conn);
-
                        if attempted || link.is_inbound() {
-
                            if self.connections.insert(conn) {
-
                                p.connected(id, addr, link);
-
                            }
+
                        if (attempted || link.is_inbound()) && self.connections.insert(conn) {
+
                            p.connected(id, addr, link);
                        }
                    }
                    Input::Disconnected(id, reason) => {
modified crates/radicle-protocol/src/service.rs
@@ -1,7 +1,5 @@
#![allow(clippy::too_many_arguments)]
-
#![allow(clippy::collapsible_match)]
-
#![allow(clippy::collapsible_if)]
-
#![warn(clippy::unwrap_used)]
+
#![deny(clippy::unwrap_used)]
pub mod command;
pub use command::{Command, QueryState};

modified crates/radicle-protocol/src/service/filter.rs
@@ -1,4 +1,3 @@
-
#![allow(clippy::identity_op)]
use std::ops::{Deref, DerefMut};

pub use bloomy::BloomFilter;
@@ -7,13 +6,13 @@ use radicle::identity::RepoId;

/// Size in bytes of *large* bloom filter.
/// It can store about 13'675 items with a false positive rate of 1%.
-
pub const FILTER_SIZE_L: usize = 16 * 1024;
+
pub const FILTER_SIZE_L: usize = 1024 * 16;
/// Size in bytes of *medium* bloom filter.
/// It can store about 3'419 items with a false positive rate of 1%.
-
pub const FILTER_SIZE_M: usize = 4 * 1024;
+
pub const FILTER_SIZE_M: usize = 1024 * 4;
/// Size in bytes of *small* bloom filter.
/// It can store about 855 items with a false positive rate of 1%.
-
pub const FILTER_SIZE_S: usize = 1 * 1024;
+
pub const FILTER_SIZE_S: usize = 1024;

/// Valid filter sizes.
pub const FILTER_SIZES: [usize; 3] = [FILTER_SIZE_S, FILTER_SIZE_M, FILTER_SIZE_L];
modified crates/radicle/src/cob.rs
@@ -1,4 +1,4 @@
-
#![warn(clippy::unwrap_used)]
+
#![deny(clippy::unwrap_used)]
pub mod cache;
pub mod common;
pub mod external;
modified crates/radicle/src/cob/issue.rs
@@ -1290,7 +1290,7 @@ mod test {

        let id = issue.id;
        let mut issue = issues.get_mut(&id).unwrap();
-
        let (_, reply1) = &issue.replies_to(&root).nth(0).unwrap();
+
        let (_, reply1) = &issue.replies_to(&root).next().unwrap();
        let (_, reply2) = &issue.replies_to(&root).nth(1).unwrap();

        assert_eq!(reply1.body(), "Hi hi hi.");
@@ -1303,8 +1303,8 @@ mod test {

        let issue = issues.get(&id).unwrap().unwrap();

-
        assert_eq!(issue.replies_to(&c1).nth(0).unwrap().1.body(), "Re: Hi.");
-
        assert_eq!(issue.replies_to(&c2).nth(0).unwrap().1.body(), "Re: Ha.");
+
        assert_eq!(issue.replies_to(&c1).next().unwrap().1.body(), "Re: Hi.");
+
        assert_eq!(issue.replies_to(&c2).next().unwrap().1.body(), "Re: Ha.");
        assert_eq!(
            issue.replies_to(&c2).nth(1).unwrap().1.body(),
            "Re: Ha. Ha."
@@ -1370,7 +1370,7 @@ mod test {

        let id = issue.id;
        let issue = issues.get(&id).unwrap().unwrap();
-
        let (_, c0) = &issue.comments().nth(0).unwrap();
+
        let (_, c0) = &issue.comments().next().unwrap();
        let (_, c1) = &issue.comments().nth(1).unwrap();
        let (_, c2) = &issue.comments().nth(2).unwrap();

modified crates/radicle/src/cob/patch.rs
@@ -3386,7 +3386,7 @@ mod test {
        let review = revision.review_by(alice.signer.public_key()).unwrap();
        assert_eq!(review.verdict(), Some(Verdict::Reject));
        assert_eq!(review.comments().count(), 2);
-
        assert_eq!(review.comments().nth(0).unwrap().1.body(), "First comment!");
+
        assert_eq!(review.comments().next().unwrap().1.body(), "First comment!");
        assert_eq!(
            review.comments().nth(1).unwrap().1.body(),
            "Second comment!"
@@ -3517,7 +3517,7 @@ mod test {
        assert_eq!(patch.revisions.len(), 2);
        assert_eq!(patch.revisions().count(), 2);
        assert_eq!(
-
            patch.revisions().nth(0).unwrap().1.description(),
+
            patch.revisions().next().unwrap().1.description(),
            "Blah blah blah."
        );
        assert_eq!(
modified crates/radicle/src/cob/store.rs
@@ -1,6 +1,4 @@
//! Generic COB storage.
-
#![allow(clippy::large_enum_variant)]
-
#![allow(clippy::type_complexity)]
use std::fmt::Debug;
use std::marker::PhantomData;

modified crates/radicle/src/cob/test.rs
@@ -1,4 +1,3 @@
-
#![allow(clippy::unwrap_used)]
use std::marker::PhantomData;
use std::ops::Deref;

modified crates/radicle/src/cob/thread.rs
@@ -714,7 +714,7 @@ mod tests {
        let a3 = alice.redact(a1.id());
        thread.op(a3, [], &repo).unwrap();

-
        let (_, comment0) = thread.comments().nth(0).unwrap();
+
        let (_, comment0) = thread.comments().next().unwrap();
        let (_, comment1) = thread.comments().nth(1).unwrap();

        assert_eq!(thread.comments().count(), 2);
modified crates/radicle/src/identity.rs
@@ -1,4 +1,4 @@
-
#![warn(clippy::unwrap_used)]
+
#![deny(clippy::unwrap_used)]
pub mod crefs;
pub mod did;
pub mod doc;
modified crates/radicle/src/lib.rs
@@ -1,7 +1,5 @@
-
#![allow(clippy::match_like_matches_macro)]
#![allow(clippy::too_many_arguments)]
-
#![allow(clippy::iter_nth_zero)]
-
#![warn(clippy::unwrap_used)]
+
#![deny(clippy::unwrap_used)]

pub extern crate radicle_crypto as crypto;

modified crates/radicle/src/node.rs
@@ -1,5 +1,3 @@
-
#![allow(clippy::type_complexity)]
-
#![allow(clippy::collapsible_if)]
mod features;

pub mod address;
@@ -516,10 +514,7 @@ impl Address {
    /// Returns `true` if the [`HostName`] is a Tor onion address.
    #[cfg(feature = "tor")]
    pub fn is_onion(&self) -> bool {
-
        match self.0.host {
-
            HostName::Tor(_) => true,
-
            _ => false,
-
        }
+
        matches!(self.0.host, HostName::Tor(_))
    }

    /// Return the port number of the [`Address`].
modified crates/radicle/src/node/notifications/store.rs
@@ -1,4 +1,3 @@
-
#![allow(clippy::type_complexity)]
use std::marker::PhantomData;
use std::num::TryFromIntError;
use std::path::Path;
modified crates/radicle/src/node/policy/store.rs
@@ -1,4 +1,3 @@
-
#![allow(clippy::type_complexity)]
use std::collections::{BTreeMap, BTreeSet};
use std::marker::PhantomData;
use std::path::Path;
modified crates/radicle/src/node/refs/store.rs
@@ -1,4 +1,3 @@
-
#![allow(clippy::type_complexity)]
use std::num::TryFromIntError;
use std::str::FromStr;

modified crates/radicle/src/node/seed/store.rs
@@ -1,4 +1,3 @@
-
#![allow(clippy::type_complexity)]
use std::str::FromStr;

use localtime::LocalTime;
@@ -35,6 +34,7 @@ pub trait Store: address::Store {
        timestamp: Timestamp,
    ) -> Result<bool, Error>;
    /// Get the repos seeded by the given node.
+
    #[allow(clippy::type_complexity)]
    fn seeded_by(
        &self,
        nid: &NodeId,
modified crates/radicle/src/rad.rs
@@ -1,4 +1,3 @@
-
#![allow(clippy::let_unit_value)]
use std::io;
use std::path::Path;
use std::str::FromStr;
modified crates/radicle/src/storage/git.rs
@@ -1,4 +1,4 @@
-
#![warn(clippy::unwrap_used)]
+
#![deny(clippy::unwrap_used)]
pub mod cob;
pub mod transport;

modified crates/radicle/src/storage/refs/sigrefs/git/properties.rs
@@ -1,5 +1,3 @@
-
#![allow(clippy::unwrap_used)]
-

use crypto::{signature, test::signer::MockSigner, PublicKey, Signer as _};
use qcheck::TestResult;
use qcheck_macros::quickcheck;
modified crates/radicle/src/storage/refs/sigrefs/property.rs
@@ -1,5 +1,3 @@
-
#![allow(clippy::unwrap_used)]
-

mod mock;
use mock::*;

modified crates/radicle/src/storage/refs/sigrefs/read/test.rs
@@ -1,5 +1,3 @@
-
#![allow(clippy::unwrap_used)]
-

mod mock;

mod commit_reader;
modified crates/radicle/src/storage/refs/sigrefs/write/test.rs
@@ -1,5 +1,3 @@
-
#![allow(clippy::unwrap_used)]
-

mod mock;

mod commit_writer;