Skip to content

Commit

Permalink
fix most clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
haraldmaida committed Feb 11, 2018
1 parent 0cdc63a commit 47559cd
Show file tree
Hide file tree
Showing 40 changed files with 309 additions and 181 deletions.
23 changes: 23 additions & 0 deletions clippy.toml
@@ -0,0 +1,23 @@

#blacklisted-names =

# The list of words that should not be considered as identifiers needing ticks
doc-valid-idents = ["ArangoDB", "MMFiles"]

#cyclomatic-complexity-threshold =

#enum-variant-name-threshold =

#enum-variant-size-threshold =

#single-char-binding-names-threshold =

#third-part =

#too-large-for-stack =

#too-many-arguments-threshold =

#type-complexity-threshold =

#verbose-bit-mask-threshold =
1 change: 0 additions & 1 deletion rincon_aql/Cargo.toml
Expand Up @@ -20,5 +20,4 @@ codecov = { repository = "innoave/rincon" }
rincon_core = { path = "../rincon_core" }

[dev-dependencies]
#quickcheck = "0.5"
version-sync = "0.5"
1 change: 0 additions & 1 deletion rincon_client/Cargo.toml
Expand Up @@ -33,7 +33,6 @@ serde_json = "1.0"
[dev-dependencies]
rincon_connector = { path = "../rincon_connector" }
rincon_test_helper = { path = "../rincon_test_helper" }
#quickcheck = "0.5"
tokio-core = "0.1"
version-sync = "0.5"

Expand Down
2 changes: 2 additions & 0 deletions rincon_client/src/admin/methods.rs
Expand Up @@ -5,6 +5,7 @@ use rincon_core::arango::protocol::{FIELD_CODE, PARAM_DETAILS, PATH_ADMIN,
use super::types::*;

#[allow(missing_copy_implementations)]
#[cfg_attr(feature = "cargo-clippy", allow(new_without_default_derive))]
#[derive(Debug, Clone, PartialEq)]
pub struct GetTargetVersion {}

Expand Down Expand Up @@ -52,6 +53,7 @@ pub struct GetServerVersion {
details: bool,
}

#[cfg_attr(feature = "cargo-clippy", allow(new_without_default_derive))]
impl GetServerVersion {
pub fn new() -> Self {
GetServerVersion {
Expand Down
80 changes: 57 additions & 23 deletions rincon_client/src/aql/types.rs
Expand Up @@ -2,7 +2,7 @@
use std::cmp::Ordering;
use std::collections::HashMap;
use std::collections::hash_map::{IntoIter, Iter};
use std::iter::{FromIterator, ExactSizeIterator, Iterator};
use std::iter::{FromIterator, ExactSizeIterator, IntoIterator, Iterator};
use std::mem;

use serde::de::{Deserialize, Deserializer};
Expand Down Expand Up @@ -320,7 +320,7 @@ impl ExecutionPlan {
/// This enum defines all possible execution nodes as listed in the official
/// documentation of *ArangoDB*.
///
/// Source: [https://docs.arangodb.com/devel/AQL/ExecutionAndPerformance/Optimizer.html#list-of-execution-nodes]
/// Source: [https://docs.arangodb.com/devel/AQL/ExecutionAndPerformance/Optimizer.html#list-of-execution-nodes](https://docs.arangodb.com/devel/AQL/ExecutionAndPerformance/Optimizer.html#list-of-execution-nodes)
///
/// Last update: 10/08/2017
#[derive(Debug, Clone, PartialEq)]
Expand Down Expand Up @@ -403,12 +403,12 @@ pub enum ExecutionNode {
/// If your application get this node type returned please file an issue
/// for this crate. Add the query and if possible the debug output of this
/// ExecutionNode to that issue.
Unlisted(GenericExecutionNode),
Unlisted(Box<GenericExecutionNode>),
}

/// The purpose of a SingletonNode is to produce an empty document that is used
/// The purpose of a `SingletonNode` is to produce an empty document that is used
/// as input for other processing steps. Each execution plan will contain
/// exactly one SingletonNode as its top node.
/// exactly one `SingletonNode` as its top node.
#[derive(Debug, Clone, PartialEq)]
pub struct SingletonNode {
id: ExecutionNodeId,
Expand Down Expand Up @@ -451,6 +451,7 @@ pub struct EnumerateCollectionNode {
}

impl EnumerateCollectionNode {
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn new<Deps, Db, Col>(
id: ExecutionNodeId,
dependencies: Deps,
Expand Down Expand Up @@ -497,6 +498,7 @@ pub struct IndexNode {
}

impl IndexNode {
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn new<Deps, Db, Col, Idxs>(
id: ExecutionNodeId,
dependencies: Deps,
Expand Down Expand Up @@ -635,7 +637,7 @@ impl LimitNode {
}

/// Evaluates an expression. The expression result may be used by other nodes,
/// e.g. FilterNode, EnumerateListNode, SortNode etc.
/// e.g. `FilterNode`, `EnumerateListNode`, `SortNode` etc.
#[derive(Debug, Clone, PartialEq)]
pub struct CalculationNode {
id: ExecutionNodeId,
Expand All @@ -649,6 +651,7 @@ pub struct CalculationNode {
}

impl CalculationNode {
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn new<Deps, Etp>(
id: ExecutionNodeId,
dependencies: Deps,
Expand Down Expand Up @@ -756,6 +759,7 @@ pub struct AggregateNode {
}

impl AggregateNode {
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn new<Deps, Out>(
id: ExecutionNodeId,
dependencies: Deps,
Expand Down Expand Up @@ -784,7 +788,7 @@ impl AggregateNode {
}

/// Returns data to the caller. Will appear in each read-only query at least
/// once. Sub-queries will also contain ReturnNodes.
/// once. Sub-queries will also contain `ReturnNode`s.
#[derive(Debug, Clone, PartialEq)]
pub struct ReturnNode {
id: ExecutionNodeId,
Expand Down Expand Up @@ -831,6 +835,7 @@ pub struct InsertNode {
}

impl InsertNode {
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn new<Deps, Db, Cll, OvN>(
id: ExecutionNodeId,
dependencies: Deps,
Expand Down Expand Up @@ -878,6 +883,7 @@ pub struct RemoveNode {
}

impl RemoveNode {
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn new<Deps, Db, Cll, OvO>(
id: ExecutionNodeId,
dependencies: Deps,
Expand Down Expand Up @@ -927,6 +933,7 @@ pub struct ReplaceNode {
}

impl ReplaceNode {
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn new<Deps, Db, Cll, IkV, OvO, OvN>(
id: ExecutionNodeId,
dependencies: Deps,
Expand Down Expand Up @@ -982,6 +989,7 @@ pub struct UpdateNode {
}

impl UpdateNode {
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn new<Deps, Db, Cll, IkV, OvO, OvN>(
id: ExecutionNodeId,
dependencies: Deps,
Expand Down Expand Up @@ -1038,6 +1046,7 @@ pub struct UpsertNode {
}

impl UpsertNode {
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn new<Deps, Db, Cll, IkV>(
id: ExecutionNodeId,
dependencies: Deps,
Expand Down Expand Up @@ -1076,7 +1085,7 @@ impl UpsertNode {
}

/// Will be inserted if FILTER statements turn out to be never satisfiable. The
/// NoResultsNode will pass an empty result set into the processing pipeline.
/// `NoResultsNode` will pass an empty result set into the processing pipeline.
#[derive(Debug, Clone, PartialEq)]
pub struct NoResultsNode {
id: ExecutionNodeId,
Expand Down Expand Up @@ -1204,12 +1213,13 @@ impl DistributeNode {

#[cfg(feature = "cluster")]
//TODO add node specific fields
/// A RemoteNode will perform communication with another ArangoDB instances in
/// the cluster. For example, the cluster coordinator will need to communicate
/// with other servers to fetch the actual data from the shards. It will do so
/// via RemoteNodes. The data servers themselves might again pull further data
/// from the coordinator, and thus might also employ RemoteNodes. So, all of the
/// above cluster relevant nodes will be accompanied by a RemoteNode.
/// A `RemoteNode` will perform communication with another *ArangoDB* instances
/// in the cluster. For example, the cluster coordinator will need to
/// communicate with other servers to fetch the actual data from the shards. It
/// will do so via `RemoteNode`s. The data servers themselves might again pull
/// further data from the coordinator, and thus might also employ `RemoteNode`s.
/// So, all of the above cluster relevant nodes will be accompanied by a
/// `RemoteNode`.
#[derive(Debug, Clone, PartialEq)]
pub struct RemoteNode {
id: ExecutionNodeId,
Expand Down Expand Up @@ -1281,6 +1291,7 @@ pub struct GenericExecutionNode {
}

impl GenericExecutionNode {
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn new(
kind: ExecutionNodeType,
id: ExecutionNodeId,
Expand Down Expand Up @@ -1758,7 +1769,7 @@ impl<'de> Deserialize<'de> for ExecutionNode {
})),
//ExecutionNodeType::Unlisted(_) =>
_ =>
Ok(Unlisted(GenericExecutionNode {
Ok(Unlisted(Box::new(GenericExecutionNode {
kind,
id,
dependencies,
Expand Down Expand Up @@ -1793,7 +1804,7 @@ impl<'de> Deserialize<'de> for ExecutionNode {
insert_variable,
update_variable,
is_replace,
})),
}))),
}
}
}
Expand All @@ -1804,7 +1815,7 @@ impl<'de> Deserialize<'de> for ExecutionNode {
/// This enum defines all possible execution nodes as listed in the official
/// documentation of *ArangoDB*.
///
/// Source: [https://docs.arangodb.com/devel/AQL/ExecutionAndPerformance/Optimizer.html#list-of-execution-nodes]
/// Source: [https://docs.arangodb.com/devel/AQL/ExecutionAndPerformance/Optimizer.html#list-of-execution-nodes](https://docs.arangodb.com/devel/AQL/ExecutionAndPerformance/Optimizer.html#list-of-execution-nodes)
///
/// Last update: 10/08/2017
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -2034,6 +2045,7 @@ pub struct ExecutionExpression {
}

impl ExecutionExpression {
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn new<Kd, Nm, Id, Val, Srt, Qnt, Levs, Subs>(
kind: Kd,
name: Nm,
Expand Down Expand Up @@ -2279,6 +2291,7 @@ pub struct ModificationOptions {
}

impl ModificationOptions {
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn new(
ignore_errors: bool,
wait_for_sync: bool,
Expand Down Expand Up @@ -2395,7 +2408,7 @@ impl NewExplainQuery {
}

pub fn options_mut(&mut self) -> &mut ExplainOptions {
self.options.get_or_insert_with(|| ExplainOptions::new())
self.options.get_or_insert_with(ExplainOptions::new)
}

pub fn remove_options(&mut self) -> Option<ExplainOptions> {
Expand Down Expand Up @@ -2466,7 +2479,7 @@ impl ExplainOptions {

/// Returns a mutable reference to the optimizer options.
pub fn optimizer_mut(&mut self) -> &mut Optimizer {
self.optimizer.get_or_insert_with(|| Optimizer::new())
self.optimizer.get_or_insert_with(Optimizer::new)
}

/// Removes the optimizer options from this struct and returns
Expand Down Expand Up @@ -2508,6 +2521,14 @@ impl Optimizer {
}
}

impl Default for Optimizer {
fn default() -> Self {
Optimizer {
rules: OptimizerRuleSet::default()
}
}
}

#[derive(Debug, Clone, PartialEq)]
pub struct OptimizerRuleSet {
rules_map: HashMap<OptimizerRule, IncludedExcluded>,
Expand Down Expand Up @@ -2561,10 +2582,12 @@ impl OptimizerRuleSet {
inner: self.rules_map.iter(),
}
}
}

pub fn into_iter(self) -> OptimizerRuleIntoIter {
OptimizerRuleIntoIter {
inner: self.rules_map.into_iter(),
impl Default for OptimizerRuleSet {
fn default() -> Self {
OptimizerRuleSet {
rules_map: Default::default(),
}
}
}
Expand Down Expand Up @@ -2596,6 +2619,17 @@ impl Serialize for OptimizerRuleSet {
}
}

impl IntoIterator for OptimizerRuleSet {
type Item = (OptimizerRule, IncludedExcluded);
type IntoIter = OptimizerRuleIntoIter;

fn into_iter(self) -> Self::IntoIter {
OptimizerRuleIntoIter {
inner: self.rules_map.into_iter(),
}
}
}

#[derive(Debug)]
pub struct OptimizerRuleIter<'a> {
inner: Iter<'a, OptimizerRule, IncludedExcluded>,
Expand Down Expand Up @@ -2635,7 +2669,7 @@ pub enum IncludedExcluded {
/// This enum defines all possible optimizer rules as listed in the official
/// documentation of *ArangoDB*.
///
/// Source: [https://docs.arangodb.com/devel/AQL/ExecutionAndPerformance/Optimizer.html#list-of-optimizer-rules]
/// Source: [https://docs.arangodb.com/devel/AQL/ExecutionAndPerformance/Optimizer.html#list-of-optimizer-rules](https://docs.arangodb.com/devel/AQL/ExecutionAndPerformance/Optimizer.html#list-of-optimizer-rules)
///
/// Last updated: 10/08/2017
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand Down
2 changes: 1 addition & 1 deletion rincon_client/src/auth/methods.rs
Expand Up @@ -13,7 +13,7 @@ pub struct Authenticate {
impl Authenticate {
/// Constructs a new instance of the `Authenticate` initialized with the
/// given credentials.
pub fn with_credentials(credentials: Credentials) -> Self {
pub fn with_credentials(credentials: &Credentials) -> Self {
Authenticate {
request: AuthenticationRequest::new(credentials.username(), credentials.password()),
}
Expand Down
15 changes: 11 additions & 4 deletions rincon_client/src/collection/methods.rs
Expand Up @@ -8,6 +8,7 @@ use super::types::*;

/// Retrieves a list of existing collections.
#[allow(missing_copy_implementations)]
#[cfg_attr(feature = "cargo-clippy", allow(new_without_default_derive))]
#[derive(Debug, Clone, PartialEq)]
pub struct ListCollections {
/// Whether or not to exclude system collections from the response.
Expand Down Expand Up @@ -431,9 +432,14 @@ impl Prepare for GetCollectionProperties {

/// Change the properties of a collection identified by name.
///
/// **Note:** except for `wait_for_sync`, `journal_size` (for MMFiles DB) and
/// name, collection properties cannot be changed once a collection is created.
/// To rename a collection, the `RenameCollection` method must be used.
/// With this method only the properties `wait_for_sync`, `journal_size`
/// (for MMFiles DB) can be changed.
///
/// To change the `name` of a collection, rename the collection using the
/// `RenameCollection` method.
///
/// All other collection properties can not be changed once the collection is
/// created.
#[derive(Debug, Clone, PartialEq)]
pub struct ChangeCollectionProperties {
name: String,
Expand Down Expand Up @@ -501,7 +507,7 @@ impl Prepare for ChangeCollectionProperties {

/// Renames a collection.
///
/// ***Note:** this method is not available in a cluster.
/// **Note:** this method is not available in a cluster.
#[derive(Debug, Clone, PartialEq)]
pub struct RenameCollection {
name: String,
Expand Down Expand Up @@ -572,6 +578,7 @@ pub struct RenameCollectionBuilder {

impl RenameCollectionBuilder {
//noinspection RsSelfConvention
#[cfg_attr(feature = "cargo-clippy", allow(wrong_self_convention))]
/// Constructs a new instance of the `RenameCollection` method for the
/// collection name of this builder and the given new name.
pub fn to_name<N>(self, name: N) -> RenameCollection
Expand Down

0 comments on commit 47559cd

Please sign in to comment.