Skip to content

Implement checks for unnumbered TODOs and FIXMEs #106

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

Merged
merged 1 commit into from
Jun 15, 2015
Merged

Implement checks for unnumbered TODOs and FIXMEs #106

merged 1 commit into from
Jun 15, 2015

Conversation

marcusklaas
Copy link
Contributor

This PR does two things: it saves the errors rustfmt finds in a report instead of immediately printing them, making some progress on https://github.com/nrc/rustfmt/issues/9.

It also adds checks for unnumbered TODOs and FIXMEs in the code. Basically we just check that any line containing a TODO matches the following regex:

/TODO\([^)#]*#\d+[^)]*\)/

But since we go through the results character by character, I implemented a state machine myself.

The output can get quite noisy --especially for rustfmt's own code--, so I added an option to forgo the check.

Note: the check treats all text equally. We're not making sure that we're in a comment. It may happen that we get false positives when there's a FIXME or TODO in a string literal, for example.

@nrc
Copy link
Member

nrc commented Jun 12, 2015

If we want to match make tidy (which I think we should), then we should warn for any TODO (with or without an issue number, but allow any FIXME. However, I would like an option to allow FIXME only if there is an issue number (which we have done in the past for make tidy, but don't atm). As you've already done, we should have the option of not doing the check at all.

// need. Round to the next power of two.
let file_size = f.src.as_ref().unwrap().len();
let power = (file_size as f64).log2().ceil() as u32;
let buffer_cap = 2usize.pow(power);
Copy link
Member

Choose a reason for hiding this comment

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

You can do this far more efficiently with some bit twiddling: http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice! What a great collection of hacks.

@nrc
Copy link
Member

nrc commented Jun 12, 2015

This is a really great PR, thanks!

nrc added a commit that referenced this pull request Jun 15, 2015
Implement checks for unnumbered TODOs and FIXMEs
@nrc nrc merged commit c7ecf74 into rust-lang:master Jun 15, 2015
@marcusklaas marcusklaas deleted the issue-number-check-2 branch September 11, 2015 09:23
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.

2 participants