mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 05:03:21 +00:00
Remove stderr limit
This commit is contained in:
parent
22606e7358
commit
68b4a43e23
4 changed files with 1 additions and 63 deletions
3
.github/workflows/clippy_dev.yml
vendored
3
.github/workflows/clippy_dev.yml
vendored
|
@ -42,9 +42,6 @@ jobs:
|
|||
run: cargo build --features deny-warnings
|
||||
working-directory: clippy_dev
|
||||
|
||||
- name: Test limit_stderr_length
|
||||
run: cargo dev limit_stderr_length
|
||||
|
||||
- name: Test update_lints
|
||||
run: cargo dev update_lints --check
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ pub mod fmt;
|
|||
pub mod new_lint;
|
||||
pub mod serve;
|
||||
pub mod setup;
|
||||
pub mod stderr_length_check;
|
||||
pub mod update_lints;
|
||||
|
||||
static DEC_CLIPPY_LINT_RE: SyncLazy<Regex> = SyncLazy::new(|| {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#![warn(rust_2018_idioms, unused_lifetimes)]
|
||||
|
||||
use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
|
||||
use clippy_dev::{bless, fmt, new_lint, serve, setup, stderr_length_check, update_lints};
|
||||
use clippy_dev::{bless, fmt, new_lint, serve, setup, update_lints};
|
||||
fn main() {
|
||||
let matches = get_clap_config();
|
||||
|
||||
|
@ -33,9 +33,6 @@ fn main() {
|
|||
Err(e) => eprintln!("Unable to create lint: {}", e),
|
||||
}
|
||||
},
|
||||
("limit_stderr_length", _) => {
|
||||
stderr_length_check::check();
|
||||
},
|
||||
("setup", Some(sub_command)) => match sub_command.subcommand() {
|
||||
("intellij", Some(matches)) => setup::intellij::setup_rustc_src(
|
||||
matches
|
||||
|
@ -152,10 +149,6 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
|
|||
.takes_value(true),
|
||||
),
|
||||
)
|
||||
.subcommand(
|
||||
SubCommand::with_name("limit_stderr_length")
|
||||
.about("Ensures that stderr files do not grow longer than a certain amount of lines."),
|
||||
)
|
||||
.subcommand(
|
||||
SubCommand::with_name("setup")
|
||||
.about("Support for setting up your personal development environment")
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
use crate::clippy_project_root;
|
||||
use std::ffi::OsStr;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use walkdir::WalkDir;
|
||||
|
||||
// The maximum length allowed for stderr files.
|
||||
//
|
||||
// We limit this because small files are easier to deal with than bigger files.
|
||||
const LENGTH_LIMIT: usize = 200;
|
||||
|
||||
pub fn check() {
|
||||
let exceeding_files: Vec<_> = exceeding_stderr_files();
|
||||
|
||||
if !exceeding_files.is_empty() {
|
||||
eprintln!("Error: stderr files exceeding limit of {} lines:", LENGTH_LIMIT);
|
||||
for (path, count) in exceeding_files {
|
||||
println!("{}: {}", path.display(), count);
|
||||
}
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
fn exceeding_stderr_files() -> Vec<(PathBuf, usize)> {
|
||||
// We use `WalkDir` instead of `fs::read_dir` here in order to recurse into subdirectories.
|
||||
WalkDir::new(clippy_project_root().join("tests/ui"))
|
||||
.into_iter()
|
||||
.filter_map(Result::ok)
|
||||
.filter(|f| !f.file_type().is_dir())
|
||||
.filter_map(|e| {
|
||||
let p = e.into_path();
|
||||
let count = count_linenumbers(&p);
|
||||
if p.extension() == Some(OsStr::new("stderr")) && count > LENGTH_LIMIT {
|
||||
Some((p, count))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
fn count_linenumbers(filepath: &Path) -> usize {
|
||||
match fs::read(filepath) {
|
||||
Ok(content) => bytecount::count(&content, b'\n'),
|
||||
Err(e) => {
|
||||
eprintln!("Failed to read file: {}", e);
|
||||
0
|
||||
},
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue