Skip to content

Commit

Permalink
Suppress all clippy lints except correctness (#337)
Browse files Browse the repository at this point in the history
And setup clippy check in CI
  • Loading branch information
CreepySkeleton authored Jan 22, 2020
1 parent 8618a6b commit 2dd04d9
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 16 deletions.
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ matrix:
- markdown-link-check -c link-check-headers.json CHANGELOG.md
- markdown-link-check -c link-check-headers.json examples/README.md

- rust: stable
name: clippy
before_script: rustup component add clippy
script: cargo clippy --all -- -D warnings

- rust: 1.36.0
- rust: stable
- rust: beta
- rust: nightly

script:
- cargo test $FEATURES
- cargo test

jobs:
allow_failures:
- name: clippy
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# [Upcoming]

* `clippy` warnings triggered by generated code shall not annoy you anymore!
Except for those from `clippy::correctness`, these lints are useful even
for auto generated code.

# v0.3.8 (2020-1-19)

* You don't have to apply `#[no_version]` to every `enum` variant anymore.
Expand Down
14 changes: 3 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@
//! ```
//! # extern crate clap;
//! # fn parse_validator<T>(_: String) -> Result<(), String> { unimplemented!() }
//! # fn main() {
//! clap::Arg::with_name("speed")
//! .takes_value(true)
//! .multiple(false)
Expand All @@ -359,7 +358,6 @@
//! .long("velocity")
//! .help("Set speed")
//! .default_value("42");
//! # }
//! ```
//!
//! ## Specifying argument types
Expand Down Expand Up @@ -426,10 +424,8 @@
//!
//! }
//!
//! # fn main() {
//! # Opt::from_clap(&Opt::clap().get_matches_from(
//! # &["test", "--foo-option", "", "-b", "", "--baz", "", "--custom", "", "positional"]));
//! # }
//! ```
//!
//! ## Default values
Expand Down Expand Up @@ -658,7 +654,6 @@
//! #[structopt(short, long, env = "PARAMETER_VALUE")]
//! parameter_value: String
//! }
//! # fn main() {}
//! ```
//!
//! By default, values from the environment are shown in the help output (i.e. when invoking
Expand Down Expand Up @@ -781,7 +776,6 @@
//! all: bool
//! }
//! }
//! # fn main() {}
//! ```
//!
//! Using `derive(StructOpt)` on an enum instead of a struct will produce
Expand All @@ -793,7 +787,6 @@
//!
//! ```
//! # use structopt::StructOpt;
//! # fn main() {}
//! #[derive(StructOpt)]
//! struct MakeCookie {
//! #[structopt(name = "supervisor", default_value = "Puck", long = "supervisor")]
Expand Down Expand Up @@ -857,7 +850,6 @@
//!
//! ```
//! # use structopt::StructOpt;
//! # fn main() {}
//! #[derive(StructOpt)]
//! struct Foo {
//! file: String,
Expand Down Expand Up @@ -934,7 +926,6 @@
//!
//! ```
//! # use structopt::StructOpt;
//! # fn main() {}
//! #[derive(StructOpt)]
//! enum BaseCli {
//! Ghost10 {
Expand Down Expand Up @@ -965,7 +956,6 @@
//!
//! ```
//! # use structopt::StructOpt;
//! # fn main() {}
//! #[derive(StructOpt)]
//! struct Cmdline {
//! /// switch on verbosity
Expand Down Expand Up @@ -1001,7 +991,6 @@
//!
//! ```
//! # use structopt::StructOpt;
//! # fn main() {}
//! use std::num::ParseIntError;
//! use std::path::PathBuf;
//!
Expand Down Expand Up @@ -1052,6 +1041,9 @@
//! once to validate, and once to parse. Hence, make sure the function is
//! side-effect-free.
// those mains are for a reason
#![allow(clippy::needless_doctest_main)]

#[doc(hidden)]
pub use structopt_derive::*;

Expand Down
48 changes: 44 additions & 4 deletions structopt-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,17 @@ fn impl_structopt_for_struct(
quote! {
#[allow(unused_variables)]
#[allow(unknown_lints)]
#[allow(clippy::all)]
#[allow(
clippy::style,
clippy::complexity,
clippy::pedantic,
clippy::restriction,
clippy::perf,
clippy::deprecated,
clippy::nursery,
clippy::cargo
)]
#[deny(clippy::correctness)]
#[allow(dead_code, unreachable_code)]
impl ::structopt::StructOpt for #name {
#clap_tokens
Expand All @@ -757,7 +767,17 @@ fn impl_structopt_for_struct(

#[allow(unused_variables)]
#[allow(unknown_lints)]
#[allow(clippy::all)]
#[allow(
clippy::style,
clippy::complexity,
clippy::pedantic,
clippy::restriction,
clippy::perf,
clippy::deprecated,
clippy::nursery,
clippy::cargo
)]
#[deny(clippy::correctness)]
#[allow(dead_code, unreachable_code)]
impl ::structopt::StructOptInternal for #name {
#augment_clap
Expand Down Expand Up @@ -785,15 +805,35 @@ fn impl_structopt_for_enum(
quote! {
#[allow(unknown_lints)]
#[allow(unused_variables, dead_code, unreachable_code)]
#[allow(clippy::all)]
#[allow(
clippy::style,
clippy::complexity,
clippy::pedantic,
clippy::restriction,
clippy::perf,
clippy::deprecated,
clippy::nursery,
clippy::cargo
)]
#[deny(clippy::correctness)]
impl ::structopt::StructOpt for #name {
#clap_tokens
#from_clap
}

#[allow(unused_variables)]
#[allow(unknown_lints)]
#[allow(clippy::all)]
#[allow(
clippy::style,
clippy::complexity,
clippy::pedantic,
clippy::restriction,
clippy::perf,
clippy::deprecated,
clippy::nursery,
clippy::cargo
)]
#[deny(clippy::correctness)]
#[allow(dead_code, unreachable_code)]
impl ::structopt::StructOptInternal for #name {
#augment_clap
Expand Down

0 comments on commit 2dd04d9

Please sign in to comment.