Skip to content

Commit

Permalink
fix invalid escape sequence at end of file, sort messages by kind
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Apr 20, 2023
1 parent 3d03ba3 commit ab7438e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 6 additions & 1 deletion crates/ruff/src/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub use pylint::PylintEmitter;
pub use text::TextEmitter;

use crate::jupyter::JupyterIndex;
use crate::registry::AsRule;
use ruff_diagnostics::{Diagnostic, DiagnosticKind, Fix};
use ruff_python_ast::source_code::{SourceFile, SourceLocation};

Expand Down Expand Up @@ -75,7 +76,11 @@ impl Message {

impl Ord for Message {
fn cmp(&self, other: &Self) -> Ordering {
(self.filename(), self.start()).cmp(&(other.filename(), other.start()))
(self.filename(), self.start(), self.kind.rule()).cmp(&(
other.filename(),
other.start(),
other.kind.rule(),
))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,15 @@ pub fn invalid_escape_sequence(
continue;
}

// If we're at the end of the line, skip.
// If we're at the end of the file, skip.
let Some((_, next_char)) = chars_iter.peek() else {
continue;
};
continue;
};

// If we're at the end of the line, skip
if matches!(next_char, '\n' | '\r') {
continue;
}

// If the next character is a valid escape sequence, skip.
if VALID_ESCAPE_SEQUENCES.contains(next_char) {
Expand Down

0 comments on commit ab7438e

Please sign in to comment.