Auto merge of #60338 - petrochenkov:notidy, r=varkor
tidy: Fix some more false positives for long URLs A URL that's simply longer than 100 characters is ok regardless of context. r? @varkor
This commit is contained in:
commit
1b6caa7cd6
@ -1,5 +1,3 @@
|
|||||||
# ignore-tidy-linelength
|
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
curl -fo /usr/local/bin/sccache \
|
curl -fo /usr/local/bin/sccache \
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
// ignore-tidy-linelength
|
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
// Error messages for EXXXX errors.
|
// Error messages for EXXXX errors.
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
// ignore-tidy-linelength
|
|
||||||
// ignore-tidy-filelength
|
// ignore-tidy-filelength
|
||||||
|
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
@ -38,7 +38,7 @@ when executed when assertions are disabled.
|
|||||||
Use llvm::report_fatal_error for increased robustness.";
|
Use llvm::report_fatal_error for increased robustness.";
|
||||||
|
|
||||||
/// Parser states for `line_is_url`.
|
/// Parser states for `line_is_url`.
|
||||||
#[derive(PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
enum LIUState {
|
enum LIUState {
|
||||||
EXP_COMMENT_START,
|
EXP_COMMENT_START,
|
||||||
@ -56,11 +56,12 @@ enum LIUState {
|
|||||||
fn line_is_url(line: &str) -> bool {
|
fn line_is_url(line: &str) -> bool {
|
||||||
use self::LIUState::*;
|
use self::LIUState::*;
|
||||||
let mut state: LIUState = EXP_COMMENT_START;
|
let mut state: LIUState = EXP_COMMENT_START;
|
||||||
|
let is_url = |w: &str| w.starts_with("http://") || w.starts_with("https://");
|
||||||
|
|
||||||
for tok in line.split_whitespace() {
|
for tok in line.split_whitespace() {
|
||||||
match (state, tok) {
|
match (state, tok) {
|
||||||
(EXP_COMMENT_START, "//") => state = EXP_LINK_LABEL_OR_URL,
|
(EXP_COMMENT_START, "//") |
|
||||||
(EXP_COMMENT_START, "///") => state = EXP_LINK_LABEL_OR_URL,
|
(EXP_COMMENT_START, "///") |
|
||||||
(EXP_COMMENT_START, "//!") => state = EXP_LINK_LABEL_OR_URL,
|
(EXP_COMMENT_START, "//!") => state = EXP_LINK_LABEL_OR_URL,
|
||||||
|
|
||||||
(EXP_LINK_LABEL_OR_URL, w)
|
(EXP_LINK_LABEL_OR_URL, w)
|
||||||
@ -68,14 +69,18 @@ fn line_is_url(line: &str) -> bool {
|
|||||||
=> state = EXP_URL,
|
=> state = EXP_URL,
|
||||||
|
|
||||||
(EXP_LINK_LABEL_OR_URL, w)
|
(EXP_LINK_LABEL_OR_URL, w)
|
||||||
if w.starts_with("http://") || w.starts_with("https://")
|
if is_url(w)
|
||||||
=> state = EXP_END,
|
=> state = EXP_END,
|
||||||
|
|
||||||
(EXP_URL, w)
|
(EXP_URL, w)
|
||||||
if w.starts_with("http://") || w.starts_with("https://") || w.starts_with("../")
|
if is_url(w) || w.starts_with("../")
|
||||||
=> state = EXP_END,
|
=> state = EXP_END,
|
||||||
|
|
||||||
(_, _) => return false,
|
(_, w)
|
||||||
|
if w.len() > COLS && is_url(w)
|
||||||
|
=> state = EXP_END,
|
||||||
|
|
||||||
|
(_, _) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user