After a discussion in #drupal, decided to be consistant with trailing newlines in core files. Going to do a search-replace for '\W+\Z' in core and get a patch up.

Comments

webchick’s picture

Issue tags: +Novice
dave reid’s picture

Assigned: dave reid » Unassigned
chx’s picture

Status: Active » Closed (won't fix)

you will get a "no ending newline" from patch if that's missing imo... it does no harm and sometimes you need to fight your editor to not add one.

dave reid’s picture

Title: Coding standards - remove ending newlines » Coding standards for file ending newlines
Status: Closed (won't fix) » Active

Maybe we should consider making sure all core files have an ending newline? Getting the no ending newline patch warning is something that might confuse novices and make them think they had done something wrong (like I had for a while when I first started patching core).

If not, feel free to mark as won't fix again.

JamesAn’s picture

The only file in a clean installation of HEAD matching the pattern '\W+\Z' is misc/jquery.js, but it has a trailing end line. Can we consider this fixed?

JamesAn’s picture

Status: Active » Needs review

While I'm at it, let's set the status to move this issue along.

Does someone want to confirm that all core files have a trailing newline?

mcrittenden’s picture

Status: Needs review » Closed (fixed)

misc/jquery.js is the only one that comes up for me, too.

dave reid’s picture

Status: Closed (fixed) » Active

That's no longer the pattern that needs to be checked. We want to ensure that all files in core end in exactly one new line, which matches several files.

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new32.76 KB
dave reid’s picture

Oops...left a spare part of a contact.module patch in there.

mcrittenden’s picture

Went through the first 15 or so changes and everything checked out. Patch applies cleanly and works fine. Follows standards. Don't really know how to review it except to say that :).

Status: Needs review » Needs work

The last submitted patch failed testing.

JamesAn’s picture

Status: Needs work » Needs review

Let's retest.

Status: Needs review » Needs work

The last submitted patch failed testing.

JamesAn’s picture

Bump..

The patch no longer works due to all the intervening changes to the code. Is there some automated process to pick out all files in core that don't end in one new line and make them end in exactly one new line?

I'd reroll this if I knew how, but I suspect I'm going to waste a lot of time playing around with line endings...

alexanderpas’s picture

Priority: Minor » Critical
Status: Needs work » Needs review
StatusFileSize
new31 KB

rerolled, temporarily critical, due to amount of changes.

this patch was made possible thanks to the song Code Monkey by Jonathan Coulton
http://www.jonathancoulton.com/2006/04/14/thing-a-week-29-code-monkey/

alexanderpas’s picture

Assigned: Unassigned » alexanderpas

Status: Needs review » Needs work

The last submitted patch failed testing.

alexanderpas’s picture

Status: Needs work » Needs review

what happened bot?
- Failed to install HEAD
- WTF??? stupid bot!!!

Status: Needs review » Needs work

The last submitted patch failed testing.

alexanderpas’s picture

Status: Needs work » Needs review

do not trust the bot: http://testing.drupal.org/node/33

Status: Needs review » Needs work

The last submitted patch failed testing.

lilou’s picture

Status: Needs work » Needs review

Setting to previous status - testbot was broken (failed to install).

alexanderpas’s picture

and it passes, testbot is not broken anymore :D

note that there are no new-line warnings in the adds, and all newline removals were duplicate newlines at the end of the file.

JamesAn’s picture

Thanks for that.

How'd you find the files with newline problem? Was it just figuring out the right regex string?

alexanderpas’s picture

did not even used regex ;)

0) remove CVS and binary (images) files!!!
1) append unique identifier to all and every file
2) search and replace magic
3) create intermediate.patch
4) check out CVS again
5) apply intermediate patch to clean CVS checkout
6) no problems :D
7) cvs diff
8) patch ready!

JamesAn’s picture

Oh. I see..

I was hoping for a quick way of doing it. =P Turns out, grep can't search across multiple lines anyway...

Status: Needs review » Needs work

The last submitted patch failed testing.

webchick’s picture

Priority: Critical » Minor

This isn't critical.

I'm also heavily considering "won't fix"ing this. I don't think we'll ever reach a point where everyone's editors aren't (re-)introducing/stripping these trailing whitespaces, so this kind of feels like a fight we're never going to win.

dave reid’s picture

If we can get the core committers to run patches through some kind of automatic coder review, it won't matter anymore. That would be sweet. :) My original point is that newbies creating patches that don't have an ending new line are going to see those wacky lines in their patches and will freak out thinking they did it wrong.

sun’s picture

At least, we should add this to the coding standards.

/me hates missing newline at end of file

webchick’s picture

sun: That sounds reasonable. Want to take care of it?

Dave: I know, but there are obviously editors out there that are stripping out trailing newlines, or this wouldn't come up all the time. And rather than core committers doing this, the testing bot should do this. Then it could be fixed way before it ever hits RTBC. I know there must be an issue for this somewhere but I can't find it.

sun’s picture

Project: Drupal core » Coder
Version: 7.x-dev » 7.x-1.x-dev
Component: other » Review/Rules

Moving to Coder's queue.

dave reid’s picture

@webchick: Oh yeah having it automated by the bot is a way better idea. I love it!

alexanderpas’s picture

Assigned: alexanderpas » Unassigned
rickmanelius’s picture

This issue was marked 'novice' on topic that doesn't have a clear decision made and might be already irrelevant. Shall we mark this closed(won't fix)? Or is there an easy means for a novice to actually fix this :)

solotandem’s picture

Let's not mark this closed (won't fix). However, with the current review code, it may not be a novice item.

rickmanelius’s picture

Status: Needs work » Closed (won't fix)
Issue tags: -Novice

Removing 'novice' tag and setting to "close won't fix" as per #37, #29, and the fact that this might be solvable.... or by some automated solution listed/discussed in #34. But I'm happy to have this reopened if someone feels strongly enough that it should still be done.