Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Critic CPAN distribution.

Report information
The Basics
Id: 38646
Status: open
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: CodeLayout::ProhibitParensWithBuiltins exception when in ?:
MIME-Version: 1.0
X-Mailer: MIME-tools 5.426 (Entity 5.426)
Content-Type: text/plain
Charset: utf8
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 368
Download (untitled) / with headers
text/plain 368b
CodeLayout::ProhibitParensWithBuiltins does not make an exception for built-ins used inside a ternary op. The code below illustrates: #!/usr/bin/perl -w sub foo { return @_ ? gmtime($_[0]) : gmtime(); } sub bar { return @_ ? gmtime $_[0] : gmtime; } Ternary ops are complicated enough that use of parens is certainly not a bad thing to clarify precedence.
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00,SPF_PASS
In-Reply-To: <rt-3.6.HEAD-28914-1219356515-277.38646-4-0 [...] rt.cpan.org>
References: <RT-Ticket-38646 [...] rt.cpan.org> <rt-3.6.HEAD-28914-1219356515-277.38646-4-0 [...] rt.cpan.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
X-RT-Original-Encoding: utf-8
Received: from x1.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id 579684D80C3 for <bug-Perl-Critic [...] rt.cpan.org>; Thu, 21 Aug 2008 18:43:35 -0400 (EDT)
Received: (qmail 1324 invoked from network); 21 Aug 2008 22:43:34 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 21 Aug 2008 22:43:34 -0000
Received: from pendrell.textdrive.com (HELO pendrell.textdrive.com) (207.7.108.149) by 16.mx.develooper.com (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Aug 2008 15:43:32 -0700
Received: from quaquaversal.local (adsl-69-209-193-140.dsl.chcgil.ameritech.net [69.209.193.140]) by pendrell.textdrive.com (Postfix) with ESMTP id 57931BDEE5 for <bug-Perl-Critic [...] rt.cpan.org>; Thu, 21 Aug 2008 22:43:29 +0000 (GMT)
Delivered-To: cpan-bug+Perl-Critic [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #38646] CodeLayout::ProhibitParensWithBuiltins exception when in ?:
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080421 Thunderbird/2.0.0.14 Mnenhy/0.7.5.0
Return-Path: <perl [...] galumph.com>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: bug-Perl-Critic [...] rt.cpan.org
Date: Thu, 21 Aug 2008 17:43:28 -0500
X-Spam-Level: *
Message-Id: <48ADEF90.2020303 [...] galumph.com>
To: bug-Perl-Critic [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Elliot Shank <perl [...] galumph.com>
RT-Message-ID: <rt-3.6.HEAD-28921-1219358620-152.38646-0-0 [...] rt.cpan.org>
Content-Length: 510
Download (untitled) / with headers
text/plain 510b
Michael G Schwern via RT wrote: Show quoted text
> CodeLayout::ProhibitParensWithBuiltins does not make an exception for > built-ins used inside a ternary op. The code below illustrates: > > #!/usr/bin/perl -w > > sub foo { > return @_ ? gmtime($_[0]) : gmtime(); > } > > sub bar { > return @_ ? gmtime $_[0] : gmtime; > } > > Ternary ops are complicated enough that use of parens is certainly not a > bad thing to clarify precedence.
Part of the point of disallowing parens is to get people to learn precedence.
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00,SPF_PASS
In-Reply-To: <rt-3.6.HEAD-28921-1219358620-152.38646-6-0 [...] rt.cpan.org>
References: <RT-Ticket-38646 [...] rt.cpan.org> <rt-3.6.HEAD-28914-1219356515-277.38646-4-0 [...] rt.cpan.org> <48ADEF90.2020303 [...] galumph.com> <rt-3.6.HEAD-28921-1219358620-152.38646-6-0 [...] rt.cpan.org>
X-Pobox-Relay-Id: 3A7AF966-6FD8-11DD-A7F5-B29498D589B0-02258300!a-sasl-fastnet.pobox.com
Content-Type: text/plain; charset=UTF-8
X-RT-Original-Encoding: utf-8
Received: from x1.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id D41034D80C8 for <bug-Perl-Critic [...] rt.cpan.org>; Thu, 21 Aug 2008 19:24:05 -0400 (EDT)
Received: (qmail 14842 invoked from network); 21 Aug 2008 23:24:04 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 21 Aug 2008 23:24:04 -0000
Received: from a-sasl-fastnet.sasl.smtp.pobox.com (HELO sasl.smtp.pobox.com) (207.106.133.19) by 16.mx.develooper.com (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Aug 2008 16:24:00 -0700
Received: from localhost.localdomain (localhost [127.0.0.1]) by a-sasl-fastnet.sasl.smtp.pobox.com (Postfix) with ESMTP id 8F44F6781A for <bug-Perl-Critic [...] rt.cpan.org>; Thu, 21 Aug 2008 19:23:57 -0400 (EDT)
Received: from windhund.schwern.org (069-064-236-003.pdx.net [69.64.236.3]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-sasl-fastnet.sasl.smtp.pobox.com (Postfix) with ESMTPSA id 24D0467819 for <bug-Perl-Critic [...] rt.cpan.org>; Thu, 21 Aug 2008 19:23:56 -0400 (EDT)
Delivered-To: cpan-bug+Perl-Critic [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #38646] CodeLayout::ProhibitParensWithBuiltins exception when in ?:
User-Agent: Thunderbird 2.0.0.16 (Macintosh/20080707)
Return-Path: <schwern [...] pobox.com>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: bug-Perl-Critic [...] rt.cpan.org
Date: Thu, 21 Aug 2008 16:23:20 -0700
X-Spam-Level: *
Message-Id: <48ADF8E8.3010302 [...] pobox.com>
To: bug-Perl-Critic [...] rt.cpan.org
X-Enigmail-Version: 0.95.7
Content-Transfer-Encoding: 7bit
From: Michael G Schwern <schwern [...] pobox.com>
RT-Message-ID: <rt-3.6.HEAD-28907-1219361051-1653.38646-0-0 [...] rt.cpan.org>
Content-Length: 2385
Download (untitled) / with headers
text/plain 2.3k
Elliot Shank via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=38646 > > > Michael G Schwern via RT wrote:
>> CodeLayout::ProhibitParensWithBuiltins does not make an exception for >> built-ins used inside a ternary op. The code below illustrates: >> >> #!/usr/bin/perl -w >> >> sub foo { >> return @_ ? gmtime($_[0]) : gmtime(); >> } >> >> sub bar { >> return @_ ? gmtime $_[0] : gmtime; >> } >> >> Ternary ops are complicated enough that use of parens is certainly not a >> bad thing to clarify precedence.
> > Part of the point of disallowing parens is to get people to learn precedence.
The stated purpose of the policy is to "reduce visual clutter" and "disambiguate built-in functions from user functions". Not to force the user to study every line and puzzle out precedence rules in detail. There are complicated precedence cases where it's not worth the reader puzzling out the precedence rules, and possibly get it wrong. It creates a visual speed bump and a trap. It's much simpler to just throw in some disambiguating parens. Ternary ops are one of them. You can potentially justify using parens to disambiguate in almost any compound expression which is why I dislike this blanket rule. Hell, I couldn't list out the precedence table and I've been programming Perl for 12 years! I would not blink at: open( my $fh, "<", $file ) or die $!; "Reducing visual clutter" varies according to circumstance [1] and thus difficult to encode as a policy. "Disambiguating built-in functions" is of low value and can be overridden by the more important need to clarify the precedence of a complicated expression. I would put in a default exemption for a built-in being used as a condition (ternary op, if statement, etc...), and a configurable exemption for any time a built-in is used in anything but a simple statement. C<< $thing = function @args; >> would be simple. This would allow me to tweak the policy to allow the programmer to decide whether reducing visual clutter or disambiguation is more important while still enforcing the obviously undesirable case. [1] and destroyed if you need to put in a ## no critic on that line -- 24. Must not tell any officer that I am smarter than they are, especially if it's true. -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army http://skippyslist.com/list/
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00,SPF_PASS
In-Reply-To: <rt-3.6.HEAD-28907-1219361051-1653.38646-5-0 [...] rt.cpan.org>
References: <RT-Ticket-38646 [...] rt.cpan.org> <rt-3.6.HEAD-28914-1219356515-277.38646-4-0 [...] rt.cpan.org> <48ADEF90.2020303 [...] galumph.com> <rt-3.6.HEAD-28921-1219358620-152.38646-6-0 [...] rt.cpan.org> <48ADF8E8.3010302 [...] pobox.com> <rt-3.6.HEAD-28907-1219361051-1653.38646-5-0 [...] rt.cpan.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
X-RT-Original-Encoding: utf-8
Received: from x1.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id 59ED24D80C8 for <bug-Perl-Critic [...] rt.cpan.org>; Thu, 21 Aug 2008 19:32:59 -0400 (EDT)
Received: (qmail 17849 invoked from network); 21 Aug 2008 23:32:58 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 21 Aug 2008 23:32:58 -0000
Received: from pendrell.textdrive.com (HELO pendrell.textdrive.com) (207.7.108.149) by 16.mx.develooper.com (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Aug 2008 16:32:55 -0700
Received: from quaquaversal.local (adsl-69-209-193-140.dsl.chcgil.ameritech.net [69.209.193.140]) by pendrell.textdrive.com (Postfix) with ESMTP id D43CFBD907 for <bug-Perl-Critic [...] rt.cpan.org>; Thu, 21 Aug 2008 23:32:52 +0000 (GMT)
Delivered-To: cpan-bug+Perl-Critic [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #38646] CodeLayout::ProhibitParensWithBuiltins exception when in ?:
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080421 Thunderbird/2.0.0.14 Mnenhy/0.7.5.0
Return-Path: <perl [...] galumph.com>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: bug-Perl-Critic [...] rt.cpan.org
Date: Thu, 21 Aug 2008 18:32:51 -0500
X-Spam-Level: *
Message-Id: <48ADFB23.1060509 [...] galumph.com>
To: bug-Perl-Critic [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Elliot Shank <perl [...] galumph.com>
RT-Message-ID: <rt-3.6.HEAD-28907-1219361584-636.38646-0-0 [...] rt.cpan.org>
Content-Length: 418
Download (untitled) / with headers
text/plain 418b
Michael G Schwern via RT wrote: Show quoted text
> "Reducing visual clutter" varies according to circumstance [1] and thus > difficult to encode as a policy. "Disambiguating built-in functions" is of > low value and can be overridden by the more important need to clarify the > precedence of a complicated expression.
Ummm... this is a severity 1 policy and thus most people won't even use it. If you don't like it, why enable it?
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00,SPF_PASS
In-Reply-To: <rt-3.6.HEAD-28907-1219361584-636.38646-6-0 [...] rt.cpan.org>
References: <RT-Ticket-38646 [...] rt.cpan.org> <rt-3.6.HEAD-28914-1219356515-277.38646-4-0 [...] rt.cpan.org> <48ADEF90.2020303 [...] galumph.com> <rt-3.6.HEAD-28921-1219358620-152.38646-6-0 [...] rt.cpan.org> <48ADF8E8.3010302 [...] pobox.com> <rt-3.6.HEAD-28907-1219361051-1653.38646-5-0 [...] rt.cpan.org> <48ADFB23.1060509 [...] galumph.com> <rt-3.6.HEAD-28907-1219361584-636.38646-6-0 [...] rt.cpan.org>
X-Pobox-Relay-Id: DE43580E-6FE2-11DD-AD9A-B29498D589B0-02258300!a-sasl-fastnet.pobox.com
Content-Type: text/plain; charset=UTF-8
X-RT-Original-Encoding: utf-8
Received: from x1.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id 2D6B94D80A8 for <bug-Perl-Critic [...] rt.cpan.org>; Thu, 21 Aug 2008 20:40:15 -0400 (EDT)
Received: (qmail 6977 invoked from network); 22 Aug 2008 00:40:14 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 22 Aug 2008 00:40:14 -0000
Received: from a-sasl-fastnet.sasl.smtp.pobox.com (HELO sasl.smtp.pobox.com) (207.106.133.19) by 16.mx.develooper.com (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Aug 2008 17:40:10 -0700
Received: from localhost.localdomain (localhost [127.0.0.1]) by a-sasl-fastnet.sasl.smtp.pobox.com (Postfix) with ESMTP id 51FE867E0F for <bug-Perl-Critic [...] rt.cpan.org>; Thu, 21 Aug 2008 20:40:07 -0400 (EDT)
Received: from windhund.schwern.org (069-064-236-003.pdx.net [69.64.236.3]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-sasl-fastnet.sasl.smtp.pobox.com (Postfix) with ESMTPSA id D28B967E0E for <bug-Perl-Critic [...] rt.cpan.org>; Thu, 21 Aug 2008 20:40:06 -0400 (EDT)
Delivered-To: cpan-bug+Perl-Critic [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #38646] CodeLayout::ProhibitParensWithBuiltins exception when in ?:
User-Agent: Thunderbird 2.0.0.16 (Macintosh/20080707)
Return-Path: <schwern [...] pobox.com>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: bug-Perl-Critic [...] rt.cpan.org
Date: Thu, 21 Aug 2008 17:39:28 -0700
X-Spam-Level: *
Message-Id: <48AE0AC0.9000304 [...] pobox.com>
To: bug-Perl-Critic [...] rt.cpan.org
X-Enigmail-Version: 0.95.7
Content-Transfer-Encoding: 7bit
From: Michael G Schwern <schwern [...] pobox.com>
RT-Message-ID: <rt-3.6.HEAD-28914-1219365626-1101.38646-0-0 [...] rt.cpan.org>
Content-Length: 1235
Download (untitled) / with headers
text/plain 1.2k
Elliot Shank via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=38646 > > > Michael G Schwern via RT wrote:
>> "Reducing visual clutter" varies according to circumstance [1] and thus >> difficult to encode as a policy. "Disambiguating built-in functions" is of >> low value and can be overridden by the more important need to clarify the >> precedence of a complicated expression.
> > Ummm... this is a severity 1 policy and thus most people won't even use it. > If you don't like it, why enable it?
There are elements of this policy that I like. I agree with the general sense of the policy, that parens on built-ins are not necessary. I disagree that this should override using parens for disambiguation. What I would like is the ability to tweak policies to my project's desires. This is under the principle that the perlcritic project does not dictate policy, but allows projects to enforce policy. perlcritic just provides a good default. More config options can only help. This desire generally increases as the severity of the policy decreases, because low severity policies are generally the more debatable ones and thus more in need of tweaking. -- package Outer::Space; use Test::More tests => 9;
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00,SPF_PASS
In-Reply-To: <rt-3.6.HEAD-28914-1219365626-1101.38646-5-0 [...] rt.cpan.org>
References: <RT-Ticket-38646 [...] rt.cpan.org> <rt-3.6.HEAD-28914-1219356515-277.38646-4-0 [...] rt.cpan.org> <48ADEF90.2020303 [...] galumph.com> <rt-3.6.HEAD-28921-1219358620-152.38646-6-0 [...] rt.cpan.org> <48ADF8E8.3010302 [...] pobox.com> <rt-3.6.HEAD-28907-1219361051-1653.38646-5-0 [...] rt.cpan.org> <48ADFB23.1060509 [...] galumph.com> <rt-3.6.HEAD-28907-1219361584-636.38646-6-0 [...] rt.cpan.org> <48AE0AC0.9000304 [...] pobox.com> <rt-3.6.HEAD-28914-1219365626-1101.38646-5-0 [...] rt.cpan.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
X-RT-Original-Encoding: utf-8
Received: from x1.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id 1BDCC4D80C8 for <bug-Perl-Critic [...] rt.cpan.org>; Thu, 21 Aug 2008 21:11:24 -0400 (EDT)
Received: (qmail 16929 invoked from network); 22 Aug 2008 01:11:24 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 22 Aug 2008 01:11:24 -0000
Received: from pendrell.textdrive.com (HELO pendrell.textdrive.com) (207.7.108.149) by 16.mx.develooper.com (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Aug 2008 18:11:21 -0700
Received: from quaquaversal.local (adsl-69-209-193-140.dsl.chcgil.ameritech.net [69.209.193.140]) by pendrell.textdrive.com (Postfix) with ESMTP id 3CE51BED8F for <bug-Perl-Critic [...] rt.cpan.org>; Fri, 22 Aug 2008 01:11:16 +0000 (GMT)
Delivered-To: cpan-bug+Perl-Critic [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #38646] CodeLayout::ProhibitParensWithBuiltins exception when in ?:
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080421 Thunderbird/2.0.0.14 Mnenhy/0.7.5.0
Return-Path: <perl [...] galumph.com>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: bug-Perl-Critic [...] rt.cpan.org
Date: Thu, 21 Aug 2008 20:11:15 -0500
X-Spam-Level: *
Message-Id: <48AE1233.70707 [...] galumph.com>
To: bug-Perl-Critic [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Elliot Shank <perl [...] galumph.com>
RT-Message-ID: <rt-3.6.HEAD-28914-1219367511-537.38646-0-0 [...] rt.cpan.org>
Content-Length: 234
Download (untitled) / with headers
text/plain 234b
Michael G Schwern via RT wrote: Show quoted text
> This desire generally increases as the severity of the policy decreases, > because low severity policies are generally the more debatable ones and thus > more in need of tweaking.
Sounds reasonable.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.