mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-28 20:11:05 -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,
|
kind: report::ParseKind::Identifier,
|
||||||
data: parser.parse_str(buffer).map(|i| i.token()).collect(),
|
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)
|
Ok(typos_found)
|
||||||
}
|
}
|
||||||
|
@ -202,7 +204,9 @@ impl Check for ParseIdentifiers {
|
||||||
kind: report::ParseKind::Identifier,
|
kind: report::ParseKind::Identifier,
|
||||||
data: parser.parse_bytes(buffer).map(|i| i.token()).collect(),
|
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)
|
Ok(typos_found)
|
||||||
}
|
}
|
||||||
|
@ -245,7 +249,9 @@ impl Check for ParseWords {
|
||||||
.flat_map(|ident| ident.split().map(|i| i.token()))
|
.flat_map(|ident| ident.split().map(|i| i.token()))
|
||||||
.collect(),
|
.collect(),
|
||||||
};
|
};
|
||||||
reporter.report(msg.into());
|
if !msg.data.is_empty() {
|
||||||
|
reporter.report(msg.into());
|
||||||
|
}
|
||||||
|
|
||||||
Ok(typos_found)
|
Ok(typos_found)
|
||||||
}
|
}
|
||||||
|
@ -267,7 +273,9 @@ impl Check for ParseWords {
|
||||||
.flat_map(|ident| ident.split().map(|i| i.token()))
|
.flat_map(|ident| ident.split().map(|i| i.token()))
|
||||||
.collect(),
|
.collect(),
|
||||||
};
|
};
|
||||||
reporter.report(msg.into());
|
if !msg.data.is_empty() {
|
||||||
|
reporter.report(msg.into());
|
||||||
|
}
|
||||||
|
|
||||||
Ok(typos_found)
|
Ok(typos_found)
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ pub struct BinaryFile<'m> {
|
||||||
#[derive(Clone, Debug, serde::Serialize, derive_setters::Setters)]
|
#[derive(Clone, Debug, serde::Serialize, derive_setters::Setters)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub struct Typo<'m> {
|
pub struct Typo<'m> {
|
||||||
|
#[serde(flatten)]
|
||||||
pub context: Context<'m>,
|
pub context: Context<'m>,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub buffer: Cow<'m, [u8]>,
|
pub buffer: Cow<'m, [u8]>,
|
||||||
|
@ -85,6 +86,7 @@ impl<'m> Default for Typo<'m> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, serde::Serialize, derive_more::From)]
|
#[derive(Clone, Debug, serde::Serialize, derive_more::From)]
|
||||||
|
#[serde(untagged)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum Context<'m> {
|
pub enum Context<'m> {
|
||||||
File(FileContext<'m>),
|
File(FileContext<'m>),
|
||||||
|
@ -139,6 +141,7 @@ impl<'m> Default for PathContext<'m> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, serde::Serialize)]
|
#[derive(Copy, Clone, Debug, serde::Serialize)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum ParseKind {
|
pub enum ParseKind {
|
||||||
Identifier,
|
Identifier,
|
||||||
|
@ -168,6 +171,7 @@ impl<'m> Default for File<'m> {
|
||||||
#[derive(Clone, Debug, serde::Serialize, derive_setters::Setters)]
|
#[derive(Clone, Debug, serde::Serialize, derive_setters::Setters)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub struct Parse<'m> {
|
pub struct Parse<'m> {
|
||||||
|
#[serde(flatten)]
|
||||||
pub context: Context<'m>,
|
pub context: Context<'m>,
|
||||||
pub kind: ParseKind,
|
pub kind: ParseKind,
|
||||||
pub data: Vec<&'m str>,
|
pub data: Vec<&'m str>,
|
||||||
|
|
Loading…
Reference in a new issue