3 use syntax::parse::token::InternedString;
6 /// **What it does:** Checks for various things we like to keep tidy in clippy.
8 /// **Why is this bad?** We like to pretend we're an example of tidy code.
10 /// **Known problems:** None.
12 /// **Example:** Wrong ordering of the util::paths constants.
14 pub CLIPPY_LINTS_INTERNAL,
16 "various things that will negatively affect your clippy experience"
20 #[derive(Copy, Clone)]
23 impl LintPass for Clippy {
24 fn get_lints(&self) -> LintArray {
25 lint_array!(CLIPPY_LINTS_INTERNAL)
29 impl EarlyLintPass for Clippy {
30 fn check_crate(&mut self, cx: &EarlyContext, krate: &Crate) {
31 if let Some(utils) = krate.module.items.iter().find(|item| item.ident.name.as_str() == "utils") {
32 if let ItemKind::Mod(ref utils_mod) = utils.node {
33 if let Some(paths) = utils_mod.items.iter().find(|item| item.ident.name.as_str() == "paths") {
34 if let ItemKind::Mod(ref paths_mod) = paths.node {
35 let mut last_name: Option<InternedString> = None;
36 for item in &paths_mod.items {
37 let name = item.ident.name.as_str();
38 if let Some(ref last_name) = last_name {
39 if **last_name > *name {
41 CLIPPY_LINTS_INTERNAL,
43 "this constant should be before the previous constant due to lexical ordering",
47 last_name = Some(name);