mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-22 23:52:12 -05:00
fix(report): Ensure json output is clean
This commit is contained in:
parent
e12cd8ed55
commit
628c011f77
2 changed files with 16 additions and 4 deletions
|
@ -183,7 +183,9 @@ impl Check for ParseIdentifiers {
|
|||
kind: report::ParseKind::Identifier,
|
||||
data: parser.parse_str(buffer).map(|i| i.token()).collect(),
|
||||
};
|
||||
reporter.report(msg.into());
|
||||
if !msg.data.is_empty() {
|
||||
reporter.report(msg.into());
|
||||
}
|
||||
|
||||
Ok(typos_found)
|
||||
}
|
||||
|
@ -202,7 +204,9 @@ impl Check for ParseIdentifiers {
|
|||
kind: report::ParseKind::Identifier,
|
||||
data: parser.parse_bytes(buffer).map(|i| i.token()).collect(),
|
||||
};
|
||||
reporter.report(msg.into());
|
||||
if !msg.data.is_empty() {
|
||||
reporter.report(msg.into());
|
||||
}
|
||||
|
||||
Ok(typos_found)
|
||||
}
|
||||
|
@ -245,7 +249,9 @@ impl Check for ParseWords {
|
|||
.flat_map(|ident| ident.split().map(|i| i.token()))
|
||||
.collect(),
|
||||
};
|
||||
reporter.report(msg.into());
|
||||
if !msg.data.is_empty() {
|
||||
reporter.report(msg.into());
|
||||
}
|
||||
|
||||
Ok(typos_found)
|
||||
}
|
||||
|
@ -267,7 +273,9 @@ impl Check for ParseWords {
|
|||
.flat_map(|ident| ident.split().map(|i| i.token()))
|
||||
.collect(),
|
||||
};
|
||||
reporter.report(msg.into());
|
||||
if !msg.data.is_empty() {
|
||||
reporter.report(msg.into());
|
||||
}
|
||||
|
||||
Ok(typos_found)
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ pub struct BinaryFile<'m> {
|
|||
#[derive(Clone, Debug, serde::Serialize, derive_setters::Setters)]
|
||||
#[non_exhaustive]
|
||||
pub struct Typo<'m> {
|
||||
#[serde(flatten)]
|
||||
pub context: Context<'m>,
|
||||
#[serde(skip)]
|
||||
pub buffer: Cow<'m, [u8]>,
|
||||
|
@ -85,6 +86,7 @@ impl<'m> Default for Typo<'m> {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, serde::Serialize, derive_more::From)]
|
||||
#[serde(untagged)]
|
||||
#[non_exhaustive]
|
||||
pub enum Context<'m> {
|
||||
File(FileContext<'m>),
|
||||
|
@ -139,6 +141,7 @@ impl<'m> Default for PathContext<'m> {
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, serde::Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[non_exhaustive]
|
||||
pub enum ParseKind {
|
||||
Identifier,
|
||||
|
@ -168,6 +171,7 @@ impl<'m> Default for File<'m> {
|
|||
#[derive(Clone, Debug, serde::Serialize, derive_setters::Setters)]
|
||||
#[non_exhaustive]
|
||||
pub struct Parse<'m> {
|
||||
#[serde(flatten)]
|
||||
pub context: Context<'m>,
|
||||
pub kind: ParseKind,
|
||||
pub data: Vec<&'m str>,
|
||||
|
|
Loading…
Reference in a new issue