Skip to content

Commit

Permalink
Add lint for default lint description
Browse files Browse the repository at this point in the history
- Lint for any new lints that have the default lint description
  from the automation
  • Loading branch information
bradsherman committed Jan 11, 2020
1 parent fd21bfe commit 9842670
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,7 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
LintId::of(&utils::internal_lints::LINT_WITHOUT_LINT_PASS),
LintId::of(&utils::internal_lints::OUTER_EXPN_EXPN_DATA),
LintId::of(&utils::internal_lints::PRODUCE_ICE),
LintId::of(&utils::internal_lints::DEFAULT_LINT),
]);

store.register_group(true, "clippy::all", Some("clippy"), vec![
Expand Down
33 changes: 33 additions & 0 deletions clippy_lints/src/utils/internal_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,29 @@ declare_clippy_lint! {
"this message should not appear anywhere as we ICE before and don't emit the lint"
}

declare_clippy_lint! {
/// **What it does:** Checks for cases of an auto-generated lint without an updated description,
/// ie `default lint description`.
///
/// **Why is this bad?** Indicates that the lint is not finished.
///
/// **Known problems:** None
///
/// **Example:**
/// Bad:
/// ```rust,ignore
/// declare_lint! { pub COOL_LINT, nursery, "default lint description" }
/// ```
///
/// Good:
/// ```rust,ignore
/// declare_lint! { pub COOL_LINT, nursery, "a great new lint" }
/// ```
pub DEFAULT_LINT,
internal,
"found 'default lint description' in a lint declaration"
}

declare_lint_pass!(ClippyLintsInternal => [CLIPPY_LINTS_INTERNAL]);

impl EarlyLintPass for ClippyLintsInternal {
Expand Down Expand Up @@ -345,3 +368,13 @@ fn is_trigger_fn(fn_kind: FnKind<'_>) -> bool {
FnKind::Closure(..) => false,
}
}

declare_lint_pass!(DefaultLint => [DEFAULT_LINT]);

impl EarlyLintPass for DefaultLint {
fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &ast::Mac) {
if mac.path == sym!(declare_lint) {
println!("{:?}", mac);
}
}
}

0 comments on commit 9842670

Please sign in to comment.