Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sq0Y3-006AJQ-GV for pgsql-committers@arkaria.postgresql.org; Mon, 16 Sep 2024 01:29:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sq0Y2-0094oH-PR for pgsql-committers@arkaria.postgresql.org; Mon, 16 Sep 2024 01:29:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sq0Y2-0094o9-HT for pgsql-committers@lists.postgresql.org; Mon, 16 Sep 2024 01:29:02 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sq0Xz-001N1n-Fy for pgsql-committers@lists.postgresql.org; Mon, 16 Sep 2024 01:29:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2024011501; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=nloQs3ykCIJ9BMLOtR+a2UfJBsVWBGu5xIBfXjL9Q9M=; b=Du25K xD6JborSDv3kCBgRAZEjgWELIsChBOyQQgadPgu3jtlCX0lKZ7v63rWOoUB7j0qYI8lej5HxtCOY7 L2e0f6vk+At/u3WJIquJJ7n9JfFF0heNiSSLC8remqaTylVesES6SF9aujJNZG1ODNnaWvmzxv59a ccGtj6XSa8chqSIEpagnRH6+kjPawWPtnwwklX3025DkGH0A6sXSzr/3fnFA89YrYbYVJBNhdXahP kcUMHgxcvwAB0ODzbppoa3hv4ddh7tqKTjoOvffyz9fmNPIehylbYPITUFSqwnD/lkObc4zGHoGpw WNjWeMNuaQ3QAWCb6WxX3gqKv9cWQ==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1sq0Xy-00EpaF-0P; Sun, 15 Sep 2024 21:28:58 -0400 Date: Sun, 15 Sep 2024 21:28:58 -0400 From: Bruce Momjian To: Andrew Dunstan Cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Perl scripts: eliminate "Useless interpolation" warnings Message-ID: References: <66b5b1d6-3f2a-4944-91a3-7e40a565ccac@dunslane.net> <42f2242a-422b-4aa3-8d60-d67b229c4a52@dunslane.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ITqMpYTPLIKD7KRj" Content-Disposition: inline In-Reply-To: <42f2242a-422b-4aa3-8d60-d67b229c4a52@dunslane.net> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --ITqMpYTPLIKD7KRj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, Sep 15, 2024 at 06:07:21PM -0400, Andrew Dunstan wrote: > > On 2024-09-15 Su 4:36 PM, Bruce Momjian wrote: > > On Sun, Sep 15, 2024 at 04:33:49PM -0400, Andrew Dunstan wrote: > > > I understand perfectly what the warning is about. > > > > > > But the project's perlcritic policy is expressed at src/tools/perlcheck/ > > > perlcriticrc. It's basically severity 5 plus some additions and one exception. > > > We shouldn't be imposing our personal perlcritic policies on the project. > > > > > > The change isn't bad in itself, but there shouldn't be any expectation that we > > > will keep to this policy, as it's not required by project policy. > > > > > > There is a huge mass of perlcritic issues in our perl code at severity 1 (over > > > 13000 by my count). If we're going to clean them up (which I would oppose) we > > > should do it in a systematic way. It's hard to see why this one is special. > > I guess it is special only because my policy is more strict so I wanted > > my new code to match. Should I revert it? > > > Yes I think so. Okay, done. > > Is the very tiny improvement > > not worth the churn in the code? > > > Yeah, I don't think it is. FYI, the line that got me started was: my ($tmpfilename) = $filename . ".tmp"; while I would write that with single quotes. Because mine uses single quotes and version_stamp.pl uses double-quotes, I started to try to unify the style. I agree severity=1 generates many false warnings, and changing code based on them can actually produce errors, but I do think there are some safe ones like the single/double quote item we can improve. Attached is my Perl critic file, where I do use severity=1, but turn off various warnings. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com When a patient asks the doctor, "Am I going to die?", he means "Am I going to die soon?" --ITqMpYTPLIKD7KRj Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=perlcritic # syntax https://github.com/schwern/Perl-Critic/blob/master/examples/perlcriticrc verbose = 7 severity = 1 # list from --profile-proto # --verbose 8 outputs critic labels # Write open $handle, $path instead of open($handle, $path). [-CodeLayout::ProhibitParensWithBuiltins] # Must run code through perltidy. [-CodeLayout::RequireTidyCode] # Write if($condition){ do_something() } instead of do_something() if $condition. [-ControlStructures::ProhibitPostfixControls] # Give every module a $VERSION number. [-Modules::RequireVersionVar] # Write @{ $array_ref } instead of @$array_ref. [-References::ProhibitDoubleSigils] # Always use the /s modifier with regular expressions. [-RegularExpressions::RequireDotMatchAnything] # Always use the /x modifier with regular expressions. [-RegularExpressions::RequireExtendedFormatting] # Always use the /m modifier with regular expressions. [-RegularExpressions::RequireLineBoundaryMatching] # Use character classes for literal meta-characters instead of escapes. [-RegularExpressions::ProhibitEscapedMetacharacters] # Don't write sub my_function (@@) {}. [-Subroutines::ProhibitSubroutinePrototypes] # Write q{} instead of ''. [-ValuesAndExpressions::ProhibitEmptyQuotes] # Don't use values that don't explain themselves. [-ValuesAndExpressions::ProhibitMagicNumbers] --ITqMpYTPLIKD7KRj--