Perl-Tidy

 view release on metacpan or  search on metacpan

docs/BugLog.html  view on Meta::CPAN

        [0, 1, 2], [3, 4, 5], [6, 7, 8],    # rows
        [0, 3, 6], [1, 4, 7], [2, 5, 8],    # columns
        [0, 4, 8], [2, 4, 6])                                     # diagonals

    NEW: perltidy -sct -act=2
    foreach $line (
        [0, 1, 2], [3, 4, 5], [6, 7, 8],    # rows
        [0, 3, 6], [1, 4, 7], [2, 5, 8],    # columns
        [0, 4, 8], [2, 4, 6])    # diagonals</code></pre>

<p>In the old version the last side comment was aligned before the closing paren was attached to the previous line, causing the final side comment to be far to the right. A patch in the new version just places it at the default location. This is the ...

</dd>
<dt id="Improve-rule-for-forgetting-last-side-comment-location"><b>Improve rule for forgetting last side comment location</b></dt>
<dd>

<p>The code which aligns side comments remembers the most recent side comment and in some cases tries to start aligning at that column for later side comments. Sometimes the old side comment column was being remembered too long, causing occasional po...

<pre><code>        # OLD:
        foreach my $r (@$array) {
            $Dat{Data}{ uc $r-&gt;[0] } = join( &quot;;&quot;, @$r );    # store all info
            my $name = $Dat{GivenName}{ uc $r-&gt;[0] } || $r-&gt;[1];

            # pass array as ad-hoc string, mark missing values
            $Dat{Data}{ uc $r-&gt;[0] } = join(
                &quot;;&quot;,
                (
                    uc $r-&gt;[0], uc $name,                   # symbol, name
                    $r-&gt;[2],    $r-&gt;[3], $r-&gt;[4],           # price, date, time
                    $r-&gt;[5],    $r-&gt;[6],                    # change, %change
                    $r-&gt;[7],    &quot;-&quot;, &quot;-&quot;, &quot;-&quot;,    # vol, avg vol, bid,ask
                    $r-&gt;[8],               $r-&gt;[9],     # previous, open
                    &quot;$r-&gt;[10] - $r-&gt;[11]&quot;, $r-&gt;[12],    # day range,year range,
                    &quot;-&quot;,                   &quot;-&quot;, &quot;-&quot;, &quot;-&quot;, &quot;-&quot;
                )
            );                                          # eps,p/e,div,yld,cap
        }</code></pre>

<p>The second side comment is at a deeper indentation level but was not being forgotten, causing line length limits to interfere with later alignment. The new rule gives a better result:</p>

<pre><code>        # NEW:
        foreach my $r (@$array) {
            $Dat{Data}{ uc $r-&gt;[0] } = join( &quot;;&quot;, @$r );    # store all info
            my $name = $Dat{GivenName}{ uc $r-&gt;[0] } || $r-&gt;[1];

            # pass array as ad-hoc string, mark missing values
            $Dat{Data}{ uc $r-&gt;[0] } = join(
                &quot;;&quot;,
                (
                    uc $r-&gt;[0], uc $name,               # symbol, name
                    $r-&gt;[2],    $r-&gt;[3], $r-&gt;[4],       # price, date, time
                    $r-&gt;[5],    $r-&gt;[6],                # change, %change
                    $r-&gt;[7],    &quot;-&quot;, &quot;-&quot;, &quot;-&quot;,          # vol, avg vol, bid,ask
                    $r-&gt;[8],               $r-&gt;[9],     # previous, open
                    &quot;$r-&gt;[10] - $r-&gt;[11]&quot;, $r-&gt;[12],    # day range,year range,
                    &quot;-&quot;,                   &quot;-&quot;, &quot;-&quot;, &quot;-&quot;, &quot;-&quot;
                )
            );    # eps,p/e,div,yld,cap
        }</code></pre>

<p>The following example shows an unexpected alignment in the cascade of trailing comments which are aligned but slowly separating from their closing containers:</p>

<pre><code>    # OLD:
    {
        $a = [
            Cascade    =&gt; $menu_cb,
            -menuitems =&gt; [
                [ Checkbutton =&gt; &#39;Oil checked&#39;, -variable =&gt; \$OIL ],
                [
                    Button   =&gt; &#39;See current values&#39;,
                    -command =&gt; [
                        \&amp;see_vars, $TOP,

                    ],    # end see_vars
                ],        # end button
            ],            # end checkbutton menuitems
        ];                # end checkbuttons cascade
    }</code></pre>

<p>This was caused by forgetting side comments only across code block changes. The new result is more reasonable:</p>

<pre><code>    # NEW:
    {
        $a = [
            Cascade    =&gt; $menu_cb,
            -menuitems =&gt; [
                [ Checkbutton =&gt; &#39;Oil checked&#39;, -variable =&gt; \$OIL ],
                [
                    Button   =&gt; &#39;See current values&#39;,
                    -command =&gt; [
                        \&amp;see_vars, $TOP,

                    ],    # end see_vars
                ],    # end button
            ],    # end checkbutton menuitems
        ];    # end checkbuttons cascade
    }</code></pre>

<p>This change will cause occasional differences in side comment locations from previous versions but overall it gives fewer unexpected results so it is a worthwhile change. 29-Dec-2020, 76993f4.</p>

</dd>
<dt id="Fixed-very-minor-inconsistency-in-redefining-lists-after-prune-step"><b>Fixed very minor inconsistency in redefining lists after prune step</b></dt>
<dd>

<p>In rare cases it is necessary to update the type of lists, and this influences vertical alignment. This update fixes a minor inconsistency in doing this. In some rare cases with complex list elements vertical alignment can be improved. 27 Dec, 202...

<pre><code>            # OLD
            return join( &#39;&#39;,
                $pre,   &#39;&lt;IMG &#39;,   $iconsizes{$alt} || &#39;&#39;,
                $align, &#39;BORDER=&#39;, $nav_border,
                &#39; ALT=&quot;&#39;, $alt,        &quot;\&quot;\n&quot;,
                &#39; SRC=&quot;&#39;, $ICONSERVER, &quot;/$icon&quot;,
                &#39;&quot;&gt;&#39; );

            # NEW
            return join( &#39;&#39;,
                $pre,     &#39;&lt;IMG &#39;,     $iconsizes{$alt} || &#39;&#39;,
                $align,   &#39;BORDER=&#39;,   $nav_border,
                &#39; ALT=&quot;&#39;, $alt,        &quot;\&quot;\n&quot;,
                &#39; SRC=&quot;&#39;, $ICONSERVER, &quot;/$icon&quot;,
                &#39;&quot;&gt;&#39; );</code></pre>

</dd>
<dt id="Improved-vertical-alignment-of-some-edge-cases"><b>Improved vertical alignment of some edge cases</b></dt>
<dd>

<p>The existing rules for aligning two lines with very different lengths were rejecting some good alignments, such as the first line of numbers in the example below:</p>

<pre><code>    # OLD:
    @gg_3 = (
        [
            0.0, 1.360755E-2, 9.569446E-4, 9.569446E-4,
            1.043498E-3, 1.043498E-3
        ],
        [
            9.569446E-4, 9.569446E-4, 0.0, 7.065964E-5,
            1.422811E-4, 1.422811E-4
        ],
        ...
    );

    # NEW:
    @gg_3 = (
        [
            0.0,         1.360755E-2, 9.569446E-4, 9.569446E-4,
            1.043498E-3, 1.043498E-3
        ],
        [
            9.569446E-4, 9.569446E-4, 0.0, 7.065964E-5,
            1.422811E-4, 1.422811E-4
        ],
        ...
    );</code></pre>

<p>The rule in sub &#39;two_line_pad&#39; was updated to allow alignment of any lists if the patterns match exactly (all numbers in this case). Updated 27-Dec-2020, 035d2b7.</p>



( run in 0.934 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )