Impl Default for SourceLocation (#4328)
Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use crate::message::{Emitter, EmitterContext, Message};
|
||||
use crate::registry::AsRule;
|
||||
use ruff_python_ast::source_code::{OneIndexed, SourceLocation};
|
||||
use ruff_python_ast::source_code::SourceLocation;
|
||||
use std::io::Write;
|
||||
|
||||
/// Generate error logging commands for Azure Pipelines format.
|
||||
@@ -19,10 +19,7 @@ impl Emitter for AzureEmitter {
|
||||
let location = if context.is_jupyter_notebook(message.filename()) {
|
||||
// We can't give a reasonable location for the structured formats,
|
||||
// so we show one that's clearly a fallback
|
||||
SourceLocation {
|
||||
row: OneIndexed::from_zero_indexed(0),
|
||||
column: OneIndexed::from_zero_indexed(0),
|
||||
}
|
||||
SourceLocation::default()
|
||||
} else {
|
||||
message.compute_start_location()
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::fs::relativize_path;
|
||||
use crate::message::{Emitter, EmitterContext, Message};
|
||||
use crate::registry::AsRule;
|
||||
use ruff_python_ast::source_code::{OneIndexed, SourceLocation};
|
||||
use ruff_python_ast::source_code::SourceLocation;
|
||||
use std::io::Write;
|
||||
|
||||
/// Generate error workflow command in GitHub Actions format.
|
||||
@@ -21,10 +21,7 @@ impl Emitter for GithubEmitter {
|
||||
let location = if context.is_jupyter_notebook(message.filename()) {
|
||||
// We can't give a reasonable location for the structured formats,
|
||||
// so we show one that's clearly a fallback
|
||||
SourceLocation {
|
||||
row: OneIndexed::from_zero_indexed(0),
|
||||
column: OneIndexed::from_zero_indexed(0),
|
||||
}
|
||||
SourceLocation::default()
|
||||
} else {
|
||||
source_location.clone()
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::message::{
|
||||
};
|
||||
use crate::registry::AsRule;
|
||||
use quick_junit::{NonSuccessKind, Report, TestCase, TestCaseStatus, TestSuite};
|
||||
use ruff_python_ast::source_code::{OneIndexed, SourceLocation};
|
||||
use ruff_python_ast::source_code::SourceLocation;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
@@ -35,10 +35,7 @@ impl Emitter for JunitEmitter {
|
||||
let location = if context.is_jupyter_notebook(message.filename()) {
|
||||
// We can't give a reasonable location for the structured formats,
|
||||
// so we show one that's clearly a fallback
|
||||
SourceLocation {
|
||||
row: OneIndexed::from_zero_indexed(0),
|
||||
column: OneIndexed::from_zero_indexed(0),
|
||||
}
|
||||
SourceLocation::default()
|
||||
} else {
|
||||
start_location
|
||||
};
|
||||
|
||||
@@ -225,6 +225,15 @@ pub struct SourceLocation {
|
||||
pub column: OneIndexed,
|
||||
}
|
||||
|
||||
impl Default for SourceLocation {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
row: OneIndexed::MIN,
|
||||
column: OneIndexed::MIN,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for SourceLocation {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("SourceLocation")
|
||||
|
||||
Reference in New Issue
Block a user