Skip to content

Handle escaped strings in rust linting, tidy.py - #9889

Merged
bors-servo merged 1 commit into
servo:masterfrom
MichaelRFairhurst:github-bug-9806-tidy-linting-string-contents
Mar 11, 2016
Merged

bors-servo merged 1 commit into
servo:masterfrom
MichaelRFairhurst:github-bug-9806-tidy-linting-string-contents

Conversation

@MichaelRFairhurst

Copy link
Copy Markdown
Contributor

A little annoying to read since we have to escape for python () and
then escape for re (\) and then even at times escape for single
quotes immediately after, (\), but tidy.py now strips strings even
if they have escapes before linting.

Fixes #9806 -- basically the problem is that the PR which first revealed this had an escape in one of its strings which included an = sign. The escape meant the string wasn't escaped before it looked for spaces around spaces.

Review on Reviewable

@highfive

highfive commented Mar 6, 2016

Copy link
Copy Markdown

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @frewsxcv (or someone else) soon.

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Mar 6, 2016
@frewsxcv

frewsxcv commented Mar 6, 2016

Copy link
Copy Markdown
Contributor

You might be able to use a "raw" strings here. Some documentation:

https://docs.python.org/2/reference/lexical_analysis.html#string-literals

Look for the paragraph in that link starting with "When an 'r' or 'R' prefix is present,". As an example:

>>> r"hello\\world" == "hello\\\\world"
True

@MichaelRFairhurst

Copy link
Copy Markdown
Contributor Author

Great suggestion -- implemented

@emilio

emilio commented Mar 7, 2016

Copy link
Copy Markdown
Member

@MichaelRFairhurst

Copy link
Copy Markdown
Contributor Author

I will look into it. My immediate guess is that this is due to the fact
that the regex does not put a value in during replace, something I was
surprised doesn't cause problems I was in there. Either way, will find out.
On Mar 7, 2016 5:37 AM, "Emilio Cobos Álvarez" [email protected]
wrote:

Hrrmm... This makes a lot of tidy failures:
https://travis-ci.org/servo/servo/jobs/114132659

—
Reply to this email directly or view it on GitHub
#9889 (comment).

@MichaelRFairhurst

Copy link
Copy Markdown
Contributor Author

Not my original thought, but thanks to the build I saw how to run tidy across the whole codebase, was able to repro and identify that my regex wasn't letting through any escapes except for escaped string terminators.

Comment thread python/tidy.py Outdated
if not filter_func(match, line):
continue

print line

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

um?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops...this will print every erroneous line. Debugging garbage made it into my branch. amended, force pushed, so that crap isn't even in history.

Thank you for catching that...

@MichaelRFairhurst
MichaelRFairhurst force-pushed the github-bug-9806-tidy-linting-string-contents branch from 8041d2e to e6d99ea Compare March 7, 2016 20:39
@emilio

emilio commented Mar 9, 2016

Copy link
Copy Markdown
Member

This looks good, sorry for the delay. Could you squash your commits? :)

tidy.py now strips strings even if they have escapes before linting.

Use raw strings for regex with lots of backslashes

Handle ALL escape sequences in strings for tidy, not just escaped string terminators
@MichaelRFairhurst
MichaelRFairhurst force-pushed the github-bug-9806-tidy-linting-string-contents branch from e6d99ea to 9b91c7a Compare March 10, 2016 21:21
@MichaelRFairhurst

Copy link
Copy Markdown
Contributor Author

Squashed!

@jdm

jdm commented Mar 10, 2016

Copy link
Copy Markdown
Member

@bors-servo: r=ecoal95

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 9b91c7a has been approved by ecoal95

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Mar 10, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 9b91c7a with merge f1bb0b0...

bors-servo pushed a commit that referenced this pull request Mar 10, 2016
…string-contents, r=ecoal95

Handle escaped strings in rust linting, tidy.py

A little annoying to read since we have to escape for python (\\) and
then escape for re (\\\\) and then even at times escape for single
quotes immediately after, (\\\\\), but tidy.py now strips strings even
if they have escapes before linting.

Fixes #9806 -- basically the problem is that the PR which first revealed this had an escape in one of its strings which included an = sign. The escape meant the string wasn't escaped before it looked for spaces around spaces.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9889)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, status-appveyor

@bors-servo
bors-servo merged commit 9b91c7a into servo:master Mar 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants