Dreditor could easily flag the non coding standards compliant trailing whitespaces. Patch attached. I hesitated between red and blue, but went with blue for consistency since red is used for the old lines, and the blue thick squares stand out pretty well on my screen. Middots are used in place of spaces so they can be included when pasting a code snippet.

It took no time to find some examples from the RTBC queue ;)
#524728-98: Refactor install.php to allow Drupal to be installed from the command line
#651902-11: Allow ESI tie in
#623320-2: AJAX 'css' command unimplemented in misc/ajax.js
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | dreditor-HEAD.tabs_.patch | 2.49 KB | sun |
| #22 | detect_trailing_spaces_22.patch | 2.43 KB | scor |
| #18 | detect_trailing_spaces_18.patch | 2.42 KB | scor |
| #17 | detect_trailing_spaces_17_lite.patch | 2.39 KB | scor |
| #16 | detect_trailing_spaces_16.patch | 4.68 KB | scor |
Comments
Comment #1
scor commentedComment #2
sunCoolio! :)
Why don't we simply test for trailing \s+$ ?
If the primary expression cannot be cut down (as questioned above), then we still can skip the trailer variable in here and replace directly. Also, the (\s) does not need to be a subpattern, simply \s is sufficient.
I'm on crack. Are you, too?
Comment #3
sunHaving just commented on #601150-145: Improved UI for contextual links...
I wonder whether we could automate this? I'm a bit sick of writing
or
all over again.
What if Dreditor would auto-add comments for those?
Of course, regarding white-space, only the first occurrence.
Comment #4
scor commentedWe need \S to ensure there is a non whitespace right before we start grouping all the ending whitespaces, hence the \S in the end of the subpattern 1. Then we need the second pattern
\s+because we latter replace every single \s with a middot in the function.I rerolled without the [ and ] which were not necessary as you pointed out.
Comment #5
scor commentedand now without the trailer variable.
Comment #6
sunAside from that question, I also think that the middot will be confusing. Taking your example at #524728-101: Refactor install.php to allow Drupal to be installed from the command line...
If you would have selected multiple, detached code lines for the comment, then the output would have looked like this:
The purpose and meaning of the current "ellipsis" is mostly clear for everyone, I think. But with those middots, I (a) have troubles to distinguish them and (b) have troubles to understand their meaning.
Thoughts?
Comment #7
scor commentedI like the idea of adding a whitespace notice as part of the pasted content. Maybe just a line saying "This patch contains some whitespaces" with a link to the dreditor project page? then it's up to people to use the right tools for the right job ;)
Comment #8
scor commentedre middots, I did a search on wikipedia and that seemed to be the most common way to mark a whitespace in typography. But we're not really doing typography here, we're doing patch review, so maybe something like ◊ would work? is it more understandable?
Comment #9
sunTesting...
Comment #10
scor commentedoriginally I didn't think of the middots and was happy enough with the thick coloring in the patch review, but then I wanted to review a patch and point it out in the comment: that's when I realized we needed some special character. Which is btw the reason for the function to be there, before that I had simple one liner:
Comment #11
scor commentednow with "no newline at end of file" detection.
Comment #12
sunActually, there are chars for this. However, not to be found in typography, but word-processing. ;)
Comment #13
sunoopsie, reverting title.
Comment #14
scor commented@ some of these are more end of line type of chars.
This patch adds a comment to the pasted content when occurrences of whitespaces and/or missing newline at end of file are found. I'm no good at javascript and not familiar with the dreditor code base so let me know if I can improve the patch.
Comment #15
scor commentedcaught myself submitting a patch with whitespaces... arghhh.
Comment #16
scor commentedI agree middots are not so obvious when compared to dots. I like sun's suggestion in #12. However I'm not happy with any of the characters but I cannot come up with a better one. I think the best is probably a character which developers are not used to see in code, like ¶.
The newline detection will give false positives for those lines which are already present in HEAD, but once #606526: [Needs rollback] Remove trailing whitespaces and add newlines at end of files is committed this should not happen. For that reason I don't think it's worth implementing a logic to detect if the no new line of EOF is added or removed. Let's just highlight them regardless.
Comment #17
scor commentedI'm leaving out the automatic report for now and we can follow up in a separate issue, otherwise this discussion will drag for ever. Let's get this committed so people can benefit from the improved patch review interface.
Comment #18
scor commentedrerolling
Comment #19
scor commented@sun: #606526: [Needs rollback] Remove trailing whitespaces and add newlines at end of files got committed - now that we have a clean, whitespace free HEAD, it would be a good time to get this in dreditor :)
Comment #20
webchickIt would make much more sense to me to make this feature part of either Drupal.org module (an auto-validation on issue form submit) or Project issue file test module (to flag it as a testbot failure). Not everyone who posts, reviews, and commits patches uses Dreditor.
Comment #21
scor commentedTrue, and Coder is supposed to be integrated with PIFR 2.x but I'm not sure it's 100% working. At first I thought writing a patch for dreditor was easier than for the whole PIFR system, and easier/quicker to deploy (pending on sun's commit). But I agree with your point webchick ;) and this is probably getting less valuable now that we'll have coder integration on d.o soon.
Comment #22
scor commentedrerolling (and removing unused counter from previous version of the patch).
Comment #23
sunThanks for reporting, reviewing, and testing! Committed http://drupal.org/cvs?commit=337232
A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.
Comment #24
sunQuick follow-up:
http://drupal.org/node/199957#comment-688319
Comment #25
scor commentedThe pinkish background doesn't strike out as much as the blue one, but I tried this patch and it works!
Comment #26
sunThanks for reporting, reviewing, and testing! Committed http://drupal.org/cvs?commit=337374