Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jPBjq-0007i9-J5 for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Apr 2020 21:07:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jPBjn-0005UL-JC for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Apr 2020 21:07:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jPBjn-0005UD-Aw for pgsql-hackers@lists.postgresql.org; Thu, 16 Apr 2020 21:07:55 +0000 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jPBjf-0001Ng-UP for pgsql-hackers@postgresql.org; Thu, 16 Apr 2020 21:07:53 +0000 Received: by mail-qt1-x844.google.com with SMTP id w29so181578qtv.3 for ; Thu, 16 Apr 2020 14:07:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:cc:references:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=M+gXMayrYKSf0KdzuYq4cHolBeJ/Op3AVMxT0OLDOQc=; b=10JExhkkWMM9p0xSabkOHfnJNCocM4gnFOdHC5/OY8EbT226eBhe75NdcUosANwZZB lW64PZEf49psE1E/Sth3GOXgKfHfzgYEdFxnlKGdEEJH0nnHjgkV5lGDLZSyOSP2JVGl +BdkgPbiOy5ftIEw2q+vkIQy/MXNuV0AO5W9yqjmNsRe2GobgfhFFb77z8YmCMKAYrQp YShkSapZunszktbtR62Tdo+pe/SF/uYTBPNw9EPHhwizCxFai0T++J6Bjg2E63mUOI7J Z9wkkbX7fogmvLuPI7CAn7ErlWn//4rOmfVlE/pU3XliiODEEbnLRggYu5g0MCDtiOFo W60A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding:content-language; bh=M+gXMayrYKSf0KdzuYq4cHolBeJ/Op3AVMxT0OLDOQc=; b=BoKQNi38qeTrvShMDLAJeEENw2nSSVhmd6woNt6IHfa8vLiGAXaNdEe8evOfhh8v5f d7zyD3BNx5vKpLZcVYtZGSuPDBmCR4YNApFYWtZKGlG0Aet99fLbSr472lXSq1+/UXLE iGbTN1xXoz3JlP1fFfLbXm2w/frLbKQQ8IrIfPtzF/pP+f4rYI0w9ibTJwyz2B6he75O IhJmDbGMUnpjlL+tshN1+1CwUP94BRx2NZD7sAOr6gRMVy+QX9bdqnNxvU+i6JIV4J6O kfxsUyO2uJz4lyvl8Uz2y1XzH+E95/EzxqcQBoFiNHyVJ7uoVkAviYlpe+TM/yLOp/H1 7Jxg== X-Gm-Message-State: AGi0PuYVRSFcRj67L9nZsbTQq5wJrpOf/lHSRiz7+C2e2YstpCVZjeXe mi6QEJDImDzsJi2oqbmmRjxGE/8GkVNCxyCuaWrQKtoAdUlvhF3vhGOIOZjcjLF8Zvm2P92Xlkk H3NlnpKozWrK2hZ9ELaS6ldfbbQa9OiTpGRwRMKL4/13AnmYRacLonkRmaQ+kdZYQEqTmUv+N2b QjQJ6Q0OI2xZ5fmbI= X-Google-Smtp-Source: APiQypJNj6nm4WJrPGesb6CgUFJNrtOydo95URwN3Zo3hpzQf+DHEuENerDwy6KBWJ2KB16Uglu8Ag== X-Received: by 2002:aed:3ec2:: with SMTP id o2mr23606489qtf.334.1587071266385; Thu, 16 Apr 2020 14:07:46 -0700 (PDT) Received: from [192.168.10.146] (99-10-92-30.lightspeed.rlghnc.sbcglobal.net. [99.10.92.30]) by smtp.gmail.com with ESMTPSA id b1sm15744277qkf.103.2020.04.16.14.07.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Apr 2020 14:07:45 -0700 (PDT) From: Andrew Dunstan X-Google-Original-From: Andrew Dunstan Subject: Re: cleaning perl code To: Alvaro Herrera , "Hamlin, Garick L" Cc: Noah Misch , PostgreSQL-development References: <20200416151248.GA8282@alvherre.pgsql> Autocrypt: addr=andrew.dunstan@2ndQuadrant.com; prefer-encrypt=mutual; keydata= mQENBE7KWFkBCAClridxur2AIc7eW2AR7izbfp3EnNefie2HbLF0izW5Ik5UjX2HBXBx4syI gY6b0ugohXrr274+baoAlvSbq6cAoQuEVrk5IZFzt20b1Xkx65FwGSEj526yiKLocqkJceSq Xr9xcA5SGY+FZv441chh5SU92v4q6z+6LPpoHOh97ptAVXZYNTtU0LevyvD5lja0TzbvJm6C eFXitJfnm1pLEr0DGJCR/iUOl/N62Kh4855zZC7NHIjQHPOvV5Stz/l5ilDhvGVk+xkXFPys SjZoUr1rXhYLpiyi5sR0X9FHXT0KnGuz1F5ERO7ZTLSSQ6fJwPj6gOk9K+vvoKvoeql5ABEB AAG0L0FuZHJldyBEdW5zdGFuIDxhbmRyZXcuZHVuc3RhbkAybmRRdWFkcmFudC5jb20+iQFY BBMBAgBCAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgBYhBOQ+WEYd/Hy/RGkVpZn6f8tZ /DuBAhkBBQJd1pSYBQkSzqMsAAoJEJn6f8tZ/DuBJmEIAIVFBIC3qGqh+YTPVTkfowwxpHz0 tZSPjZ6GS/5y62kgoZrZOVXw+Rg2ceuMM3a+In/RRjTx4bembgYqRKgzXlDfiNBJeq5ioVuN H1faDKE2lm5a6QkRQ2JU6DKf60fqSJGP5LisCUr1V0wz6EnlO31ArrKtXCNB+yk0KDAS6o6I Ql4pkXpr+vq4iilwJmiJOqTBam0LmQE7ulYCCYU8Z6MkpiSl+dO7QSramcGyxauQRI3a7gcq dpo8Vrv3gFTQDeMYxk7cqZp08pIVH5XR0+LgBz4X84f59rA/VAKlC/r6CyEQk59rvDLxCMyP 2buoj51Z25N3MVghRDGcsU6mT7e5AQ0ETspYWQEIANGc4zQULOxhbqO2dyD51YhqCNRmm9oK Waqf+wmW4tpDe/VVcxAnNizd4LWCHfzpb5cHAtGkOPePMfzWVf6nvdF7d3eglbtf59+zG7O7 llV0xSSoFiieQBsrGvqDInXYX/4mRRXMtyhM353/tixC9RWLs1oofyYmCPPXXY7h9R7en3B8 BoVrRFcdzlIY/NFNhFGW/9dkEiGjgna2Rk6e15kln4ZvFBWUg23p93w/pqXcxY6+k/8TEk+C 4R+M6w7o2PLGOjdZ+kPiUcw5H85zf/yZJwQXzisXaNduwWB6Vads9YC9dj6kPR1c4VGRqAaY L++LAEOqrlvm2TvqQqZRtnEAEQEAAYkBJQQYAQIADwIbDAUCXdaUtAUJEs6jVQAKCRCZ+n/L Wfw7gQi5B/9sHbmRloZNCWWwZGm+O9iG/JGQxS0WWa4GaZqzqSTWOft2/gO0Bgag89r1djq4 PFgSZtzHvKQpqYz/7HkPrWh1jpcS83i/uYY1uyHXUUtpdEmn4buNObEtD0YNaJkGdhASsECq 6akw+u7WJYmAHs/SpR6ok6HqLw7JHDVc2h5dViLfTk0qrgDa7sq/LVMoJje5Ct/Ku3YaWAV6 YSmzoPP5BmPVFqP11OMQkCqurIu9vTLXKFWX623vCmqRDHJ6e5GCDHbH8USU+4wJBfPymZkd cA7NGm/mmWeJiWBFIDyjzYxrjku8ty9TZJVsaRXnS+OFQzXz9Eu2wTpKdHij46uY Message-ID: Date: Thu, 16 Apr 2020 17:07:44 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200416151248.GA8282@alvherre.pgsql> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 4/16/20 11:12 AM, Alvaro Herrera wrote: > On 2020-Apr-16, Hamlin, Garick L wrote: > >> With the old expression 'something;' would be stripped away. >> Is that an issue where this this is used? Why are we parsing >> these headers? > These are files from which bootstrap catalog data is generated, which is > why we parse from Perl; but also where C structs are declared, which is > why they're C. > > I think switching to non-greedy is a win in itself. Non-capturing > parens is probably a wash (this doesn't run often so the performance > argument isn't very interesting). Yeah, I'm inclined to fix this independently of the perlcritic stuff. The change is more readable and more correct as well as being perlcritic friendly. I might take a closer look at Catalog.pm. Meanwhile, the other regex highlighted in the patch, in Solution.pm: if (/^AC_INIT\(\[([^\]]+)\], \[([^\]]+)\], \[([^\]]+)\], \[([^\]]*)\], \[([^\]]+)\]/) is sufficiently horrid that I think we should see if we can rewrite it, maybe as an extended regex. And a better fix here instead of marking the fourth group as non-capturing would be simply to get rid of the parens altogether. The serve no purpose at all. > > An example. This eval in Catalog.pm > > + ## no critic (ProhibitStringyEval) > + ## no critic (RequireCheckingReturnValueOfEval) > + eval '$hash_ref = ' . $_; > > is really weird stuff generally speaking, and the fact that we have to > mark it specially for critic is a good indicator of that -- it serves as > documentation. Catalog.pm is all a huge weird hack, but it's a critically > important hack. Heck, what about RequireCheckingReturnValueOfEval -- > should we instead consider actually checking the return value of eval? > It would seem to make sense, would it not? (Not for this patch, though > -- I would be fine with just adding the nocritic line now, and removing > it later while fixing that). +1 > > All in all, I think it's a positive value in having this code be checked > with a bit more strength -- checks that are pointless in, say, t/00*.pl > prove files. thanks cheers andrew -- Andrew Dunstan https://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services