Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #40543] [NEW] Test for space after curly braces

7 views
Skip to first unread message

Paul Cochrane

unread,
Oct 16, 2006, 5:00:27 AM10/16/06
to bugs-bi...@rt.perl.org
# New Ticket Created by "Paul Cochrane"
# Please include the string: [perl #40543]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=40543 >


Hi,

This patch adds a test to the coding standards which checks for space
or tab characters after a curly brace when the curly is the last
printable character on the line. The pumpking hasn't explicitly
declared that this should be a coding standard, but particle mentioned
that it was a pet peeve, and I thought I might as well write a test
:-)

Regards,

Paul

curly_space_t.patch

Chromatic

unread,
Oct 16, 2006, 12:48:39 PM10/16/06
to perl6-i...@perl.org, Paul Cochrane
On Monday 16 October 2006 02:00, Paul Cochrane wrote:

> This patch adds a test to the coding standards which checks for space
> or tab characters after a curly brace when the curly is the last
> printable character on the line. The pumpking hasn't explicitly
> declared that this should be a coding standard, but particle mentioned
> that it was a pet peeve, and I thought I might as well write a test

Is there any reason not to generalize this to report *any* whitespace
character at the end of a line before the newline?

-- c

Jerry Gay

unread,
Oct 16, 2006, 1:05:20 PM10/16/06
to chromatic, perl6-i...@perl.org, via RT Paul Cochrane
i see no reason to keep this specific to curlies.
i hate all useless trailing whitespace equally :)
~jerry

Mark J. Reed

unread,
Oct 16, 2006, 1:08:13 PM10/16/06
to chromatic, perl6-i...@perl.org, via RT Paul Cochrane
On 10/16/06, chromatic <chro...@wgz.org> wrote:

That was exactly my thought when I read Paul's message Death to
trailing whitespace!

--
Mark J. Reed <mark...@mail.com>

Jerry Gay

unread,
Oct 16, 2006, 1:13:57 PM10/16/06
to chromatic, perl6-i...@perl.org, via RT Paul Cochrane
On 10/16/06, jerry gay <jerr...@gmail.com> wrote:
> i see no reason to keep this specific to curlies.
> i hate all useless trailing whitespace equally :)
>
for vim users, these settings may help find trailing spaces and leading tabs:

set list
set listchars=trail:-,tab:\.\

note in this case, the trailing space on the second line is intentional.
~jerry

Leopold Toetsch

unread,
Oct 16, 2006, 1:33:12 PM10/16/06
to perl6-i...@perl.org
Am Montag, 16. Oktober 2006 19:05 schrieb jerry gay:
> i see no reason to keep this specific to curlies.
> i hate all useless trailing whitespace equally :)

s/useless//

Me too, but there are still some test files with ws at the end, e.g.
t/op/sprintf_tests

You can stare at test result compares in vain, until you use od or such, to
actually get the reason for a failing test.

> ~jerry

leo

Mark J. Reed

unread,
Oct 16, 2006, 1:38:23 PM10/16/06
to jerry gay, chromatic, perl6-i...@perl.org, via RT Paul Cochrane

Note that ":set list" all by itself will reveal tabs and trailing
space with the default settings; the custom listchars are optional.
(Although if you ever do want hard tabs in your files, setting the
tab: listchars setting is is advised, since otherwise the tabs
collapse to ^I. With a custom value for tab:, the width of the
tabstop is maintained in the display.)

In this case, however, hard tabs seem to be taboo according to the
coding standards. (And the crowd goes wild!) So another good thing to
set in vim is 'expandtab', which automatically replaces tabs you type
with however many spaces are needed to get to the next tabstop (whose
spacing you can control with the appropriately-named 'tabstop'
option).
Once expandtab is on, you can issue a ":retab" command to replace any
existing hard tabs with spaces.

Jerry Gay via RT

unread,
Oct 17, 2006, 4:25:37 PM10/17/06
to perl6-i...@perl.org
On Tue Oct 17 07:33:02 2006, paultc...@gmail.com wrote:
> Well, the verdict defnitely seems to be that trailing space and tab
> characters are annoyances that should go away :-) This patch adds a
> new test (in place of the curly-space test I posted earlier) which
> searches for superfluous trailing spaces in source files.
>
> Comments definitely welcome!
>
this is too noisy as ~700 tests. please convert it to one test, like the
other coding standard tests.

also, it should apply to perl files, as well. in fact, it should
probably apply to most files in MANIFEST and MANIFEST.skip, except for a
few where the spaces are required (like some test data files.) however,
i'd accept this patch if it were extended only to cover the perl files.

thanks for your hard work!
~jerry

Will Coleda

unread,
Oct 17, 2006, 5:48:10 PM10/17/06
to parrotbug...@parrotcode.org, perl6-internals List

On Oct 17, 2006, at 4:25 PM, Jerry Gay via RT wrote:

> On Tue Oct 17 07:33:02 2006, paultc...@gmail.com wrote:
>> Well, the verdict defnitely seems to be that trailing space and tab
>> characters are annoyances that should go away :-) This patch adds a
>> new test (in place of the curly-space test I posted earlier) which
>> searches for superfluous trailing spaces in source files.
>>
>> Comments definitely welcome!
>>
> this is too noisy as ~700 tests. please convert it to one test,
> like the
> other coding standard tests.
>

t/codingstd/perlcritic.pl at least, has a test per file.

> also, it should apply to perl files, as well. in fact, it should
> probably apply to most files in MANIFEST and MANIFEST.skip, except
> for a
> few where the spaces are required (like some test data files.)
> however,
> i'd accept this patch if it were extended only to cover the perl
> files.

This is covered by perlcritic already, and if not, should be. I'm
happy to keep this targeted at the c-only files.

These tests already take too long to run, no need to test everything 2x.

> thanks for your hard work!
> ~jerry
>

--
Will "Coke" Coleda
wi...@coleda.com


0 new messages