mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-22 23:52:12 -05:00
refactor(report): Make Parse consistent with Typos
This commit is contained in:
parent
97f90da9bc
commit
eb20ba9f11
2 changed files with 10 additions and 8 deletions
|
@ -89,7 +89,7 @@ impl ParseIdentifiers {
|
|||
|
||||
for part in path.components().filter_map(|c| c.as_os_str().to_str()) {
|
||||
let msg = report::Parse {
|
||||
path,
|
||||
context: report::PathContext { path }.into(),
|
||||
kind: report::ParseKind::Identifier,
|
||||
data: parser.parse(part).map(|i| i.token()).collect(),
|
||||
};
|
||||
|
@ -120,9 +120,10 @@ impl ParseIdentifiers {
|
|||
return Ok(typos_found);
|
||||
}
|
||||
|
||||
for line in buffer.lines() {
|
||||
for (line_idx, line) in buffer.lines().enumerate() {
|
||||
let line_num = line_idx + 1;
|
||||
let msg = report::Parse {
|
||||
path,
|
||||
context: report::FileContext { path, line_num }.into(),
|
||||
kind: report::ParseKind::Identifier,
|
||||
data: parser.parse_bytes(line).map(|i| i.token()).collect(),
|
||||
};
|
||||
|
@ -155,7 +156,7 @@ impl ParseWords {
|
|||
|
||||
for part in path.components().filter_map(|c| c.as_os_str().to_str()) {
|
||||
let msg = report::Parse {
|
||||
path,
|
||||
context: report::PathContext { path }.into(),
|
||||
kind: report::ParseKind::Word,
|
||||
data: parser
|
||||
.parse(part)
|
||||
|
@ -189,9 +190,10 @@ impl ParseWords {
|
|||
return Ok(typos_found);
|
||||
}
|
||||
|
||||
for line in buffer.lines() {
|
||||
for (line_idx, line) in buffer.lines().enumerate() {
|
||||
let line_num = line_idx + 1;
|
||||
let msg = report::Parse {
|
||||
path,
|
||||
context: report::FileContext { path, line_num }.into(),
|
||||
kind: report::ParseKind::Word,
|
||||
data: parser
|
||||
.parse_bytes(line)
|
||||
|
|
|
@ -154,7 +154,7 @@ impl<'m> Default for File<'m> {
|
|||
#[derive(Clone, Debug, serde::Serialize, derive_setters::Setters)]
|
||||
#[non_exhaustive]
|
||||
pub struct Parse<'m> {
|
||||
pub path: &'m std::path::Path,
|
||||
pub context: Context<'m>,
|
||||
pub kind: ParseKind,
|
||||
pub data: Vec<&'m str>,
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ pub struct Parse<'m> {
|
|||
impl<'m> Default for Parse<'m> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
path: std::path::Path::new("-"),
|
||||
context: Context::None,
|
||||
kind: ParseKind::Identifier,
|
||||
data: vec![],
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue