Skip to content

Need a better way to skip when XML parse fails #608

Closed

Description

@MichaelChirico

Split off from #546.

Right now we have to use this workaround:

(!length(source_file$full_parsed_content) || is.null(source_file$xml_parsed_content)) return(list())

This is pretty arcane & unreadable IMO -- hard to know without being pretty experienced with lintr internals what's going on here. And with lints, it's tough to just wrap that into a helper function because now that's something we need to export for downstreams to use as well I think.

Both checks are needed because

  1. We want to skip on the last expression (where full_parsed_content is present) and
  2. We can't use !is.null(source_file$parsed_content) because there are cases where parsed_content is present (e.g. in some parsing error situations, as fixed in Allow invalid xml #560) but xml_parsed_content is not. lastly
  3. We can't skip based on xml_parsed_content because that element has the same name for the full file & individual expressions.

I think the easiest solution is to rename xml_parsed_content to full_xml_parsed_content to be consistent with parsed_content ➡️ full_parsed_content. There is some (?) breakage potential here in the event that some downstream logic depends on xml_parsed_content being the name for the full file, but I think it's worth the change for consistency & readability.

Activity

  1. added
    internals
    on Nov 28, 2020
  2. AshesITR commented on Nov 28, 2020

    @AshesITR
    Collaborator

    Found one usage in all of CRAN for this.
    Can we check if {goodpractice} would break on this change?
    I suspect it won't.

    https://github.com/cran/goodpractice/blob/1755c716e56043d7c471eea6ca56c639cf6ec38c/R/my_linters.R

    Full search

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

internals

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions