mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-10 06:47:34 +00:00
case insensitive FIXME and TODO
This commit is contained in:
parent
3e29fe3330
commit
2e82ad8c36
@ -16,8 +16,8 @@ use std::fmt;
|
|||||||
|
|
||||||
pub use config::ReportTactic;
|
pub use config::ReportTactic;
|
||||||
|
|
||||||
const TO_DO_CHARS: &[char] = &['T', 'O', 'D', 'O'];
|
const TO_DO_CHARS: &[char] = &['t', 'o', 'd', 'o'];
|
||||||
const FIX_ME_CHARS: &[char] = &['F', 'I', 'X', 'M', 'E'];
|
const FIX_ME_CHARS: &[char] = &['f', 'i', 'x', 'm', 'e'];
|
||||||
|
|
||||||
// Enabled implementation detail is here because it is
|
// Enabled implementation detail is here because it is
|
||||||
// irrelevant outside the issues module
|
// irrelevant outside the issues module
|
||||||
@ -127,44 +127,45 @@ impl BadIssueSeeker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn inspect_issue(&mut self, c: char, mut todo_idx: usize, mut fixme_idx: usize) -> Seeking {
|
fn inspect_issue(&mut self, c: char, mut todo_idx: usize, mut fixme_idx: usize) -> Seeking {
|
||||||
// FIXME: Should we also check for lower case characters?
|
if let Some(lower_case_c) = c.to_lowercase().next() {
|
||||||
if self.report_todo.is_enabled() && c == TO_DO_CHARS[todo_idx] {
|
if self.report_todo.is_enabled() && lower_case_c == TO_DO_CHARS[todo_idx] {
|
||||||
todo_idx += 1;
|
todo_idx += 1;
|
||||||
if todo_idx == TO_DO_CHARS.len() {
|
if todo_idx == TO_DO_CHARS.len() {
|
||||||
return Seeking::Number {
|
return Seeking::Number {
|
||||||
issue: Issue {
|
issue: Issue {
|
||||||
issue_type: IssueType::Todo,
|
issue_type: IssueType::Todo,
|
||||||
missing_number: if let ReportTactic::Unnumbered = self.report_todo {
|
missing_number: if let ReportTactic::Unnumbered = self.report_todo {
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
part: NumberPart::OpenParen,
|
||||||
part: NumberPart::OpenParen,
|
};
|
||||||
};
|
}
|
||||||
}
|
fixme_idx = 0;
|
||||||
fixme_idx = 0;
|
} else if self.report_fixme.is_enabled() && lower_case_c == FIX_ME_CHARS[fixme_idx] {
|
||||||
} else if self.report_fixme.is_enabled() && c == FIX_ME_CHARS[fixme_idx] {
|
// Exploit the fact that the character sets of todo and fixme
|
||||||
// Exploit the fact that the character sets of todo and fixme
|
// are disjoint by adding else.
|
||||||
// are disjoint by adding else.
|
fixme_idx += 1;
|
||||||
fixme_idx += 1;
|
if fixme_idx == FIX_ME_CHARS.len() {
|
||||||
if fixme_idx == FIX_ME_CHARS.len() {
|
return Seeking::Number {
|
||||||
return Seeking::Number {
|
issue: Issue {
|
||||||
issue: Issue {
|
issue_type: IssueType::Fixme,
|
||||||
issue_type: IssueType::Fixme,
|
missing_number: if let ReportTactic::Unnumbered = self.report_fixme {
|
||||||
missing_number: if let ReportTactic::Unnumbered = self.report_fixme {
|
true
|
||||||
true
|
} else {
|
||||||
} else {
|
false
|
||||||
false
|
},
|
||||||
},
|
},
|
||||||
},
|
part: NumberPart::OpenParen,
|
||||||
part: NumberPart::OpenParen,
|
};
|
||||||
};
|
}
|
||||||
|
todo_idx = 0;
|
||||||
|
} else {
|
||||||
|
todo_idx = 0;
|
||||||
|
fixme_idx = 0;
|
||||||
}
|
}
|
||||||
todo_idx = 0;
|
|
||||||
} else {
|
|
||||||
todo_idx = 0;
|
|
||||||
fixme_idx = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Seeking::Issue {
|
Seeking::Issue {
|
||||||
@ -268,12 +269,24 @@ fn find_issue() {
|
|||||||
ReportTactic::Always,
|
ReportTactic::Always,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
assert!(!is_bad_issue(
|
||||||
|
"Todo: mixed case\n",
|
||||||
|
ReportTactic::Never,
|
||||||
|
ReportTactic::Always,
|
||||||
|
));
|
||||||
|
|
||||||
assert!(is_bad_issue(
|
assert!(is_bad_issue(
|
||||||
"This is a FIXME(#1)\n",
|
"This is a FIXME(#1)\n",
|
||||||
ReportTactic::Never,
|
ReportTactic::Never,
|
||||||
ReportTactic::Always,
|
ReportTactic::Always,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
assert!(is_bad_issue(
|
||||||
|
"This is a FixMe(#1) mixed case\n",
|
||||||
|
ReportTactic::Never,
|
||||||
|
ReportTactic::Always,
|
||||||
|
));
|
||||||
|
|
||||||
assert!(!is_bad_issue(
|
assert!(!is_bad_issue(
|
||||||
"bad FIXME\n",
|
"bad FIXME\n",
|
||||||
ReportTactic::Always,
|
ReportTactic::Always,
|
||||||
|
Loading…
Reference in New Issue
Block a user