mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
Check for path dev-dependencies with a version number
This commit is contained in:
parent
9860a39603
commit
203cfff826
1 changed files with 33 additions and 10 deletions
|
@ -101,21 +101,44 @@ fn cargo_files_are_tidy() {
|
||||||
let mut section = None;
|
let mut section = None;
|
||||||
for (line_no, text) in read_file(&cargo).unwrap().lines().enumerate() {
|
for (line_no, text) in read_file(&cargo).unwrap().lines().enumerate() {
|
||||||
let text = text.trim();
|
let text = text.trim();
|
||||||
if text.starts_with("[") {
|
if text.starts_with('[') {
|
||||||
|
if !text.ends_with(']') {
|
||||||
|
panic!(
|
||||||
|
"\nplease don't add comments or trailing whitespace in section lines.\n\
|
||||||
|
{}:{}\n",
|
||||||
|
cargo.display(),
|
||||||
|
line_no + 1
|
||||||
|
)
|
||||||
|
}
|
||||||
section = Some(text);
|
section = Some(text);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if !section.map(|it| it.starts_with("[dependencies")).unwrap_or(false) {
|
let text: String = text.split_whitespace().collect();
|
||||||
|
if !text.contains("path=") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let text: String = text.split_whitespace().collect();
|
match section {
|
||||||
if text.contains("path=") && !text.contains("version") {
|
Some(s) if s.contains("dev-dependencies") => {
|
||||||
panic!(
|
if text.contains("version") {
|
||||||
"\ncargo internal dependencies should have version.\n\
|
panic!(
|
||||||
{}:{}\n",
|
"\ncargo internal dev-dependencies should not have a version.\n\
|
||||||
cargo.display(),
|
{}:{}\n",
|
||||||
line_no + 1
|
cargo.display(),
|
||||||
)
|
line_no + 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Some(s) if s.contains("dependencies") => {
|
||||||
|
if !text.contains("version") {
|
||||||
|
panic!(
|
||||||
|
"\ncargo internal dependencies should have a version.\n\
|
||||||
|
{}:{}\n",
|
||||||
|
cargo.display(),
|
||||||
|
line_no + 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue