mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:10:09 +00:00
parent
cf6a23b83c
commit
0d0c8730fa
2 changed files with 29 additions and 1 deletions
3
resources/test/fixtures/E501.py
vendored
3
resources/test/fixtures/E501.py
vendored
|
@ -4,3 +4,6 @@
|
||||||
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_ = "---------------------------------------------------------------------------AAAAAAA"
|
||||||
|
_ = "---------------------------------------------------------------------------亜亜亜亜亜亜亜"
|
||||||
|
|
|
@ -35,7 +35,7 @@ pub fn check_lines(checks: &mut Vec<Check>, contents: &str, settings: &Settings)
|
||||||
|
|
||||||
// Enforce line length.
|
// Enforce line length.
|
||||||
if enforce_line_too_long {
|
if enforce_line_too_long {
|
||||||
let line_length = line.len();
|
let line_length = line.chars().count();
|
||||||
if should_enforce_line_length(line, line_length, settings.line_length) {
|
if should_enforce_line_length(line, line_length, settings.line_length) {
|
||||||
let check = Check::new(
|
let check = Check::new(
|
||||||
CheckKind::LineTooLong(line_length, settings.line_length),
|
CheckKind::LineTooLong(line_length, settings.line_length),
|
||||||
|
@ -53,3 +53,28 @@ pub fn check_lines(checks: &mut Vec<Check>, contents: &str, settings: &Settings)
|
||||||
}
|
}
|
||||||
checks.extend(line_checks);
|
checks.extend(line_checks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::check_lines;
|
||||||
|
use super::*;
|
||||||
|
use std::collections::BTreeSet;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn e501_non_ascii_char() {
|
||||||
|
let line = "'\u{4e9c}' * 2"; // 7 in UTF-32, 9 in UTF-8.
|
||||||
|
let check_with_max_line_length = |line_length: usize| {
|
||||||
|
let mut checks: Vec<Check> = vec![];
|
||||||
|
let settings = Settings {
|
||||||
|
line_length,
|
||||||
|
exclude: vec![],
|
||||||
|
extend_exclude: vec![],
|
||||||
|
select: BTreeSet::from_iter(vec![CheckCode::E501]),
|
||||||
|
};
|
||||||
|
check_lines(&mut checks, line, &settings);
|
||||||
|
return checks;
|
||||||
|
};
|
||||||
|
assert!(!check_with_max_line_length(6).is_empty());
|
||||||
|
assert!(check_with_max_line_length(7).is_empty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue