Skip to content

Conversation

@renkun-ken
Copy link
Collaborator

Closes #559

Since lintr might pass a partial or invalid parse data to xmlparsedata::xml_parse_data, it could also generate invalid XML text, which also causes xml2::read_xml() to fail.

This PR adds a tryCatch() to all xml2::read_xml(xmlparsedata::xml_parse_data(pc)) so that invalid XML text would not cause lintr::lint to fail.

Note that all linters that uses the source_file$xml_parsed_content must check if it is NULL before querying it. This PR adds such checks to seq_linter, missing_package_linter and namespace_linter.

@renkun-ken renkun-ken requested a review from AshesITR November 5, 2020 08:08
Copy link
Collaborator

@AshesITR AshesITR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked for other uses of xml_parsed_content (and global_xml_parsed_content()).
All other users already did NULL checks, these were:

  • object_name_linter
  • object_usage_linter
  • pipe_continuation_linter

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid "\" crashes lintr

2 participants