Ignore some 'long line' errors

This commit is contained in:
Charles Marsh 2022-08-18 20:59:44 -04:00
parent ddd554f9de
commit 623152768e
4 changed files with 18 additions and 11 deletions

View File

@ -1,4 +1,6 @@
"""Lorem ipsum dolor sit amet. """Lorem ipsum dolor sit amet.
https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533
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.
""" """

View File

@ -129,7 +129,7 @@ mod tests {
location: Location::new(1, 1), location: Location::new(1, 1),
}]; }];
assert_eq!(actual.len(), expected.len()); assert_eq!(actual.len(), expected.len());
for i in 1..actual.len() { for i in 0..actual.len() {
assert_eq!(actual[i], expected[i]); assert_eq!(actual[i], expected[i]);
} }
} }

View File

@ -10,10 +10,15 @@ pub fn check_lines(contents: &str) -> Vec<Check> {
.enumerate() .enumerate()
.filter_map(|(row, line)| { .filter_map(|(row, line)| {
if line.len() > *MAX_LINE_LENGTH { if line.len() > *MAX_LINE_LENGTH {
Some(Check { let chunks: Vec<&str> = line.split_whitespace().collect();
kind: LineTooLong, if chunks.len() == 1 || (chunks.len() == 2 && chunks[0] == "#") {
location: Location::new(row + 1, MAX_LINE_LENGTH + 1), None
}) } else {
Some(Check {
kind: LineTooLong,
location: Location::new(row + 1, MAX_LINE_LENGTH + 1),
})
}
} else { } else {
None None
} }

View File

@ -74,7 +74,7 @@ mod tests {
}, },
]; ];
assert_eq!(actual.len(), expected.len()); assert_eq!(actual.len(), expected.len());
for i in 1..actual.len() { for i in 0..actual.len() {
assert_eq!(actual[i], expected[i]); assert_eq!(actual[i], expected[i]);
} }
@ -105,7 +105,7 @@ mod tests {
}, },
]; ];
assert_eq!(actual.len(), expected.len()); assert_eq!(actual.len(), expected.len());
for i in 1..actual.len() { for i in 0..actual.len() {
assert_eq!(actual[i], expected[i]); assert_eq!(actual[i], expected[i]);
} }
@ -131,7 +131,7 @@ mod tests {
}, },
]; ];
assert_eq!(actual.len(), expected.len()); assert_eq!(actual.len(), expected.len());
for i in 1..actual.len() { for i in 0..actual.len() {
assert_eq!(actual[i], expected[i]); assert_eq!(actual[i], expected[i]);
} }
@ -157,7 +157,7 @@ mod tests {
}, },
]; ];
assert_eq!(actual.len(), expected.len()); assert_eq!(actual.len(), expected.len());
for i in 1..actual.len() { for i in 0..actual.len() {
assert_eq!(actual[i], expected[i]); assert_eq!(actual[i], expected[i]);
} }
@ -172,11 +172,11 @@ mod tests {
)?; )?;
let expected = vec![Message { let expected = vec![Message {
kind: LineTooLong, kind: LineTooLong,
location: Location::new(3, 88), location: Location::new(5, 89),
filename: "./resources/test/src/line_too_long.py".to_string(), filename: "./resources/test/src/line_too_long.py".to_string(),
}]; }];
assert_eq!(actual.len(), expected.len()); assert_eq!(actual.len(), expected.len());
for i in 1..actual.len() { for i in 0..actual.len() {
assert_eq!(actual[i], expected[i]); assert_eq!(actual[i], expected[i]);
} }