]> git.lizzy.rs Git - rust.git/blob - clippy_dev/src/main.rs
Merge pull request #3269 from rust-lang-nursery/relicense
[rust.git] / clippy_dev / src / main.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10
11 extern crate clap;
12 extern crate clippy_dev;
13 extern crate regex;
14
15 use clap::{App, Arg, SubCommand};
16 use clippy_dev::*;
17
18 fn main() {
19     let matches = App::new("Clippy developer tooling")
20         .subcommand(
21             SubCommand::with_name("update_lints")
22                 .about("Update the lint list")
23                 .arg(
24                     Arg::with_name("print-only")
25                         .long("print-only")
26                         .short("p")
27                         .help("Print a table of lints to STDOUT. Does not modify any files."),
28                 )
29         )
30         .get_matches();
31
32     if let Some(matches) = matches.subcommand_matches("update_lints") {
33         if matches.is_present("print-only") {
34             print_lints();
35         }
36     }
37 }
38
39 fn print_lints() {
40     let lint_list = gather_all().collect::<Vec<Lint>>();
41     let grouped_by_lint_group = Lint::by_lint_group(&lint_list);
42
43     for (lint_group, mut lints) in grouped_by_lint_group {
44         if lint_group == "Deprecated" { continue; }
45         println!("\n## {}", lint_group);
46
47         lints.sort_by(|a, b| a.name.cmp(&b.name));
48
49         for lint in lints {
50             println!("* [{}]({}#{}) ({})", lint.name, clippy_dev::DOCS_LINK.clone(), lint.name, lint.desc);
51         }
52     }
53
54     println!("there are {} lints", Lint::active_lints(&lint_list).count());
55 }