diff --git a/resources/test/src/line_too_long.py b/resources/test/src/line_too_long.py index 337d845359..5152ac824d 100644 --- a/resources/test/src/line_too_long.py +++ b/resources/test/src/line_too_long.py @@ -1,4 +1,6 @@ """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. """ diff --git a/src/check_ast.rs b/src/check_ast.rs index d8aee9f174..5b3f48142d 100644 --- a/src/check_ast.rs +++ b/src/check_ast.rs @@ -129,7 +129,7 @@ mod tests { location: Location::new(1, 1), }]; assert_eq!(actual.len(), expected.len()); - for i in 1..actual.len() { + for i in 0..actual.len() { assert_eq!(actual[i], expected[i]); } } diff --git a/src/check_lines.rs b/src/check_lines.rs index 85da502e93..8d5235a5a6 100644 --- a/src/check_lines.rs +++ b/src/check_lines.rs @@ -10,10 +10,15 @@ pub fn check_lines(contents: &str) -> Vec { .enumerate() .filter_map(|(row, line)| { if line.len() > *MAX_LINE_LENGTH { - Some(Check { - kind: LineTooLong, - location: Location::new(row + 1, MAX_LINE_LENGTH + 1), - }) + let chunks: Vec<&str> = line.split_whitespace().collect(); + if chunks.len() == 1 || (chunks.len() == 2 && chunks[0] == "#") { + None + } else { + Some(Check { + kind: LineTooLong, + location: Location::new(row + 1, MAX_LINE_LENGTH + 1), + }) + } } else { None } diff --git a/src/linter.rs b/src/linter.rs index 46ac4709c1..577949bd0d 100644 --- a/src/linter.rs +++ b/src/linter.rs @@ -74,7 +74,7 @@ mod tests { }, ]; assert_eq!(actual.len(), expected.len()); - for i in 1..actual.len() { + for i in 0..actual.len() { assert_eq!(actual[i], expected[i]); } @@ -105,7 +105,7 @@ mod tests { }, ]; assert_eq!(actual.len(), expected.len()); - for i in 1..actual.len() { + for i in 0..actual.len() { assert_eq!(actual[i], expected[i]); } @@ -131,7 +131,7 @@ mod tests { }, ]; assert_eq!(actual.len(), expected.len()); - for i in 1..actual.len() { + for i in 0..actual.len() { assert_eq!(actual[i], expected[i]); } @@ -157,7 +157,7 @@ mod tests { }, ]; assert_eq!(actual.len(), expected.len()); - for i in 1..actual.len() { + for i in 0..actual.len() { assert_eq!(actual[i], expected[i]); } @@ -172,11 +172,11 @@ mod tests { )?; let expected = vec![Message { kind: LineTooLong, - location: Location::new(3, 88), + location: Location::new(5, 89), filename: "./resources/test/src/line_too_long.py".to_string(), }]; assert_eq!(actual.len(), expected.len()); - for i in 1..actual.len() { + for i in 0..actual.len() { assert_eq!(actual[i], expected[i]); }