Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in doc_parse_raw: Opening and ending tag mismatch: expr line 28 and equal_assign [76] #403

Closed
step- opened this issue Sep 2, 2019 · 17 comments

Comments

@step-
Copy link

step- commented Sep 2, 2019

In RStudio 1.2.1335 Linux, R 3.6.1:

> lintr::lint("R/lintr-bug.R")
Error in doc_parse_raw(x, encoding = encoding, base_url = base_url, as_html = as_html,  : 
  Opening and ending tag mismatch: expr line 28 and equal_assign [76]

lintr-bug.R attached.
I had just built lintr from github with packrat. I'm attaching packrat.lock so you can see all package versions involved.
attachments.zip

@russHyde
Copy link
Collaborator

russHyde commented Sep 3, 2019

Could you install xmlparsedata from github, eg, using devtools::install_github("r-lib/xmlparsedata"), please. On R.3.6 we were getting this doc_parse_raw error when parsing R code that contained equals-assignments; see here: r-lib/xmlparsedata#5

@step-
Copy link
Author

step- commented Sep 5, 2019

Indeed xmlparsedata from github fixed this issue. Now lintr prints three markers "Use <- not = for assignment" and terminates correctly. Thank you.

@step- step- closed this as completed Sep 5, 2019
@csgillespie
Copy link

I'm now getting this error with R-devel on travis, but __not R-current (3.6). Any suggestions?

@russHyde
Copy link
Collaborator

russHyde commented Feb 10, 2020

@csgillespie Do you have a travis log we could look at or is it a private repo?

@csgillespie
Copy link

csgillespie commented Feb 10, 2020

Travis logs and Github

Passes under R current, not R future. Fails for other repos.

@russHyde
Copy link
Collaborator

@csgillespie had a look at your inteRgrate travis log. OTOH I'm not sure what the problem is.

Can I ask why you use devtools::install(..., upgrade = "never"). Can you be sure you're using lintr>=2 and xmlparsedata >=1.0.3 in your travis run?.

FWIW: our logs looked like this when we had issues with doc_parse_raw https://travis-ci.org/jimhester/lintr/builds/561186819?utm_source=github_status&utm_medium=notification

@russHyde
Copy link
Collaborator

russHyde commented Feb 10, 2020

Sorry, disregard that. I can see the lintr 2 install in your poweRlaw log

@russHyde
Copy link
Collaborator

As a minor point, you're installing two differrent versions of lintr when running CI on poweRlaw. The 2.0.0 version when travis works on the r_packages stub of your .travis.yml; then the dev version when you install integRate. So, the dev version should be responsible for the failing call.

@russHyde
Copy link
Collaborator

I can't see any changes in R 3.7 changelog that would affect get_parse_data at present, and I'm not sure how I could debug against R3.7 locally. Would you mind if I do some experimental PRs against powerLaw?

@csgillespie
Copy link

Feel free to play around on the branch - it's just a test branch. I've removed all R files except 1 (https://github.com/csgillespie/poweRlaw/tree/lintr/R) to simplify things

@russHyde
Copy link
Collaborator

I ran lint_package() on your lintr branch in (todays release) of R-4.0.0 on windows with lintr 2.0.0, and xmlparsedata=1.0.3, xml2=1.2.2

Debugged both xml2::read_xml and xmlparsedata::xml_parse_data. The string passed to read_xml by xml_parse_data had an invalid header.

debug(xmlparsedata::xml_parse_data)
lint_package()

xml_parse_data returned a string with header containing ... encoding=\"UTF-8\"standalone=\"yes\" ...

Note this change to xmlparsedata: r-lib/xmlparsedata#7

The xml header construction should be fixed with current github version of xmlparsedata; suggest you add a install_github for xmlparsedata in your travis.yml

@russHyde
Copy link
Collaborator

Apologies. That doesn't appear to fix it locally either (and doesn't really explain the R3.6 -> R-devel differences).

There's something wrong with how xmlparsedata handles the "expr_or_assign_or_help" tags returned by getParseData. This seems to be an xmlparsedata problem. But we'd need to make a smaller example before sending it to Gabor et al

@russHyde
Copy link
Collaborator

debug(xml2::read_xml)
cat("a = 123\n", file = "bbb.R")
lint("bbb.R")
... x is the parsed data ...
cat(x, file = "")
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<exprlist>
<expr_or_assign_or_help line1="1" col1="1" line2="1" col2="7" start="9" end="15">
<expr line1="1" col1="1" line2="1" col2="7" start="9" end="15">
<expr line1="1" col1="1" line2="1" col2="1" start="9" end="9">
<SYMBOL line1="1" col1="1" line2="1" col2="1" start="9" end="9">a</SYMBOL>
</expr>
<EQ_ASSIGN line1="1" col1="3" line2="1" col2="3" start="11" end="11">=</EQ_ASSIGN>
<expr line1="1" col1="5" line2="1" col2="7" start="13" end="15">
<NUM_CONST line1="1" col1="5" line2="1" col2="7" start="13" end="15">123</NUM_CONST>
</expr>
</expr_or_assign_or_help>
</expr>
</exprlist>

All the expr tags start after the expr_or_assign_or_help tag; but one of them is closed after the expr_or_assign_or_help tag is closed

@russHyde
Copy link
Collaborator

But, when you extract xml from the parsed code without going through lintr, it seems to parse OK.

cat(
  xmlparsedata::xml_parse_data(getParseData(parse("bbb.R"))), 
  file = ""
)
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<exprlist>
<expr_or_assign_or_help line1="1" col1="1" line2="1" col2="7" start="9" end="15">
<expr line1="1" col1="1" line2="1" col2="1" start="9" end="9">
<SYMBOL line1="1" col1="1" line2="1" col2="1" start="9" end="9">a</SYMBOL>
</expr>
<EQ_ASSIGN line1="1" col1="3" line2="1" col2="3" start="11" end="11">=</EQ_ASSIGN>
<expr line1="1" col1="5" line2="1" col2="7" start="13" end="15">
<NUM_CONST line1="1" col1="5" line2="1" col2="7" start="13" end="15">123</NUM_CONST>
</expr>
</expr_or_assign_or_help>
</exprlist>

@russHyde russHyde reopened this Feb 11, 2020
@russHyde
Copy link
Collaborator

Reopened this issue, although it seems slightly different from the original issue.

@jimhester
Copy link
Member

This should be fixed by #455 as well

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

No branches or pull requests

4 participants