-
Notifications
You must be signed in to change notification settings - Fork 187
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
refactor spaces_inside_linter to use xpath #1169
Conversation
Is it possible to solve with the current implementation of |
Okay, I pondered this for a while, with two observations:
By the way, I have issues with the
|
that means to abandon the xpath approach, or to roll our own conversion from xml match --> Lint? |
I'd use a custom |
I'll test performance out, but i also think the xpath version is a fair amount more readable. |
I agree to that. |
(hopefully the adjustments needed to avoid |
PTAL. I still used both land you where you can delete the whitespace which is what's important. On I think that's fine -- in both cases there's a single key to press on many keyboards (or a key combo to press for forward-delete on laptops). If anything, if we insisted on consistency, I'd say it's better to be to the right in both cases since backwards-delete is usually easier. |
Being to the left also causes the
|
Hmm I see what you mean. OTOH, the source marker is maybe not very nice for a wider expression: This branch is also way faster -- 20x vs. On balance, between (1) the improved message (now says "before" when
benchmarked on tools/R/QC.R, isolating the `get_source_expressions` overhead:
library(lintr)
l = spaces_inside_linter()
f = "~/svn/R-devel/src/library/tools/R/QC.R"
e = get_source_expressions(f)
system.time(lapply(e$expressions, l))
# to check overlap
write.csv(as.data.frame(lint(f, l)), "branch.csv") |
It would be awesome if we modified the ranges to include the entire whitespace and we can add a
The speedup is awesome. We should definitely use XPath then, just fine-tune the locations a bit. |
I think that's a separate PR, WDYT? Now the refactor handles XML logic and fixes the no-match output, with tiny nudge to source markers (in the right direction I think). Follow-up can further improve lint metadata. |
Filed #1205 |
Part of #1160
@AshesITR PTAL -- our column numbers are off again here.
match_after_end
will work for the LHS case ([
or(
) but not the RHS case.Two options:
xml_nodes_to_lints()
again -- maybematch_after_end
➡️match_column = c("center", "after", "before")
, where"before"
works for the]
/)
cases here?xml_nodes_to_lints()
here