]> git.donarmstrong.com Git - perltidy.git/blobdiff - CHANGES.md
release 20230309-1
[perltidy.git] / CHANGES.md
index 8c36f5997a42b2fd8612550b0b66727147d5ed4b..eb36279f03e10d8d857390db3a2dc55610e1dfbd 100644 (file)
@@ -1,5 +1,508 @@
 # Perltidy Change Log
 
+## 2023 03 09
+
+    - No significant bugs have been found since the last release to CPAN.
+      Several minor issues have been fixed, and some new parameters have been
+      added, as follows:
+
+    - Added parameter --one-line-block-exclusion-list=s, or -olbxl=s, where
+      s is a list of block types which should not automatically be turned
+      into one-line blocks.  This implements the issue raised in PR #111.
+      The list s may include any of the words 'sort map grep eval', or
+      it may be '*' to indicate all of these.  So for example to prevent
+      multi-line 'eval' blocks from becoming one-line blocks, the command
+      would be -olbxl='eval'.
+
+    - For the -b (--backup-and-modify-in-place) option, the file timestamps
+      are changing (git #113, rt#145999).  First, if there are no formatting
+      changes to an input file, it will keep its original modification time.
+      Second, any backup file will keep its original modification time.  This
+      was previously true for --backup-method=move but not for the default
+      --backup-method=copy.  The purpose of these changes is to avoid
+      triggering Makefile operations when there are no actual file changes.
+      If this causes a problem please open an issue for discussion on github.
+
+    - A change was made to the way line breaks are made at the '.'
+      operator when the user sets -wba='.' to requests breaks after a '.'
+      ( this setting is not recommended because it can be hard to read ).
+      The goal of the change is to make switching from breaks before '.'s
+      to breaks after '.'s just move the dots from the end of
+      lines to the beginning of lines.  For example:
+
+            # default and recommended (--want-break-before='.'):
+            $output_rules .=
+              (     'class'
+                  . $dir
+                  . '.stamp: $('
+                  . $dir
+                  . '_JAVA)' . "\n" . "\t"
+                  . '$(CLASSPATH_ENV) $(JAVAC) -d $(JAVAROOT) '
+                  . '$(JAVACFLAGS) $?' . "\n" . "\t"
+                  . 'echo timestamp > class'
+                  . $dir
+                  . '.stamp'
+                  . "\n" );
+
+            # perltidy --want-break-after='.'
+            $output_rules .=
+              ( 'class' .
+                  $dir .
+                  '.stamp: $(' .
+                  $dir .
+                  '_JAVA)' . "\n" . "\t" .
+                  '$(CLASSPATH_ENV) $(JAVAC) -d $(JAVAROOT) ' .
+                  '$(JAVACFLAGS) $?' . "\n" . "\t" .
+                  'echo timestamp > class' .
+                  $dir .
+                  '.stamp' .
+                  "\n" );
+
+      For existing code formatted with -wba='.', this may cause some
+      changes in the formatting of code with long concatenation chains.
+
+    - Added option --use-feature=class, or -uf=class, for issue rt #145706.
+      This adds keywords 'class', 'method', 'field', and 'ADJUST' in support of
+      this feature which is being tested for future inclusion in Perl.
+      An effort has been made to avoid conflicts with past uses of these
+      words, especially 'method' and 'class'. The default setting
+      is --use-feature=class. If this causes a conflict, this option can
+      be turned off by entering -uf=' '.
+
+      In other words, perltidy should work for both old and new uses of
+      these keywords with the default settings, but this flag is available
+      if a conflict arises.
+
+    - Added option -bfvt=n, or --brace-follower-vertical-tightness=n,
+      for part of issue git #110.  For n=2, this option looks for lines
+      which would otherwise be, by default,
+
+      }
+        or ..
+
+      and joins them into a single line
+
+      } or ..
+
+      where the or can be one of a number of logical operators or if unless.
+      The default is not to do this and can be indicated with n=1.
+
+    - Added option -cpb, or --cuddled-paren-brace, for issue git #110.
+      This option will cause perltidy to join two lines which
+      otherwise would be, by default,
+
+        )
+      {
+
+      into a single line
+
+      ) {
+
+    - Some minor changes to existing formatted output may occur as a result
+      of fixing minor formatting issues with edge cases.  This is especially
+      true for code which uses the -lp or -xlp styles.
+
+    - Added option -dbs, or --dump-block-summary, to dump summary
+      information about code blocks in a file to standard output.
+      The basic command is:
+
+          perltidy -dbs somefile.pl >blocks.csv
+
+      Instead of formatting ``somefile.pl``, this dumps the following
+      comma-separated items describing its blocks to the standard output:
+
+       filename     - the name of the file
+       line         - the line number of the opening brace of this block
+       line_count   - the number of lines between opening and closing braces
+       code_lines   - the number of lines excluding blanks, comments, and pod
+       type         - the block type (sub, for, foreach, ...)
+       name         - the block name if applicable (sub name, label, asub name)
+       depth        - the nesting depth of the opening block brace
+       max_change   - the change in depth to the most deeply nested code block
+       block_count  - the total number of code blocks nested in this block
+       mccabe_count - the McCabe complexity measure of this code block
+
+      This can be useful for code restructuring. The man page for perltidy
+      has more information and describes controls for selecting block types.
+
+    - This version was stress-tested for over 100 cpu hours with random
+      input parameters. No failures to converge, internal fault checks,
+      undefined variable references or other irregularities were seen.
+
+    - This version runs a few percent faster than the previous release on
+      large files due to optimizations made with the help of Devel::NYTProf.
+
+## 2022 11 12
+
+    - Fix rt #145095, undef warning in Perl before 5.12. Version 20221112 is
+      identical to 2022111 except for this fix for older versions of Perl.
+
+    - No significant bugs have been found since the last release to CPAN.
+      Several minor issues have been fixed, and some new parameters have been
+      added, as follows:
+
+    - Fixed rare problem with irregular indentation involving --cuddled-else,
+      usually also with the combination -xci and -lp.  Reported in rt #144979.
+
+    - Add option --weld-fat-comma (-wfc) for issue git #108. When -wfc
+      is set, along with -wn, perltidy is allowed to weld an opening paren
+      to an inner opening container when they are separated by a hash key
+      and fat comma (=>).  For example:
+
+        # perltidy -wn
+        elf->call_method(
+            method_name_foo => {
+                some_arg1       => $foo,
+                some_other_arg3 => $bar->{'baz'},
+            }
+        );
+
+        # perltidy -wn -wfc
+        elf->call_method( method_name_foo => {
+            some_arg1       => $foo,
+            some_other_arg3 => $bar->{'baz'},
+        } );
+
+      This flag is off by default.
+
+    - Fix issue git #106. This fixes some edge cases of formatting with the
+      combination -xlp -pt=2, mainly for two-line lists with short function
+      names. One indentation space is removed to improve alignment:
+
+        # OLD: perltidy -xlp -pt=2
+        is($module->VERSION, $expected,
+            "$main_module->VERSION matches $module->VERSION ($expected)");
+
+        # NEW: perltidy -xlp -pt=2
+        is($module->VERSION, $expected,
+           "$main_module->VERSION matches $module->VERSION ($expected)");
+
+    - Fix for issue git #105, incorrect formatting with 5.36 experimental
+      for_list feature.
+
+    - Fix for issue git #103. For parameter -b, or --backup-and-modify-in-place,
+      the default backup method has been changed to preserve the inode value
+      of the file being formatted.  If this causes a problem, the previous
+      method is available and can be used by setting -backup-mode='move', or
+      -bm='move'.  The new default corresponds to -bm='copy'.  The difference
+      between the two methods is as follows.  For the older method,
+      -bm='move', the input file was moved to the backup, and a new file was
+      created for the formatted output.  This caused the inode to change.  For
+      the new default method, -bm='copy', the input is copied to the backup
+      and then the input file is reopened and rewritten. This preserves the
+      file inode.  Tests have not produced any problems with this change, but
+      before using the --backup-and-modify-in-place parameter please verify
+      that it works correctly in your environment and operating system. The
+      initial update for this had an error which was caught and fixed
+      in git #109.
+
+    - Fix undefined value message when perltidy -D is used (git #104)
+
+    - Fixed an inconsistency in html colors near pointers when -html is used.
+      Previously, a '->' at the end of a line got the 'punctuation color', black
+      by default but a '->' before an identifier got the color of the following
+      identifier. Now all pointers get the same color, which is black by default.
+      Also, previously a word following a '->' was given the color of a bareword,
+      black by default, but now it is given the color of an identifier.
+
+    - Fixed incorrect indentation of any function named 'err'.  This was
+      due to some old code from when "use feature 'err'" was valid.
+
+            # OLD:
+            my ($curr) = current();
+              err (@_);
+
+            # NEW:
+            my ($curr) = current();
+            err(@_);
+
+    - Added parameter --delete-repeated-commas (-drc) to delete repeated
+      commas. This is off by default. For example, given:
+
+            ignoreSpec( $file, "file",, \%spec, \%Rspec );
+
+      # perltidy -drc:
+            ignoreSpec( $file, "file", \%spec, \%Rspec );
+
+    - Add continuation indentation to long C-style 'for' terms; i.e.
+
+            # OLD
+            for (
+                $j = $i - $shell ;
+                $j >= 0
+                && ++$ncomp
+                && $array->[$j] gt $array->[ $j + $shell ] ;
+                $j -= $shell
+              )
+
+            # NEW
+            for (
+                $j = $i - $shell ;
+                $j >= 0
+                  && ++$ncomp
+                  && $array->[$j] gt $array->[ $j + $shell ] ;
+                $j -= $shell
+              )
+
+      This will change some existing formatting with very long 'for' terms.
+
+    - The following new parameters are available for manipulating
+      trailing commas of lists. They are described in the manual.
+
+           --want-trailing-commas=s, -wtc=s
+           --add-trailing-commas,    -atc
+           --delete-trailing-commas, -dtc
+           --delete-weld-interfering-commas, -dwic
+
+    - Files with errors due to missing, extra or misplaced parens, braces,
+      or square brackets are now written back out verbatim, without any
+      attempt at formatting.
+
+    - This version runs 10 to 15 percent faster than the previous
+      release on large files due to optimizations made with the help of
+      Devel::NYTProf.
+
+    - This version was stress-tested for over 200 cpu hours with random
+      input parameters. No failures to converge, internal fault checks,
+      undefined variable references or other irregularities were seen.
+
+## 2022 06 13
+
+    - No significant bugs have been found since the last release but users
+      of programs which call the Perl::Tidy module should note the first
+      item below, which changes a default setting.  The main change to
+      existing formatting is the second item below, which adds vertical
+      alignment to 'use' statements.
+
+    - The flag --encode-output-strings, or -eos, is now set 'on' by default.
+      This has no effect on the use of the 'perltidy' binary script, but could
+      change the behavior of some programs which use the Perl::Tidy module on
+      files encoded in UTF-8.  If any problems are noticed, an emergency fix
+      can be made by reverting to the old default by setting -neos.  For
+      an explanation of why this change needs to be made see:
+
+      https://github.com/perltidy/perltidy/issues/92
+
+      https://github.com/perltidy/perltidy/blob/master/docs/eos_flag.md
+
+    - Added vertical alignment for qw quotes and empty parens in 'use'
+      statements (see issue #git 93).  This new alignment is 'on' by default
+      and will change formatting as shown below. If this is not wanted it can
+      be turned off with the parameter -vxl='q' (--valign-exclusion-list='q').
+
+        # old default, or -vxl='q'
+        use Getopt::Long qw(GetOptions);
+        use Fcntl qw(O_RDONLY O_WRONLY O_EXCL O_CREAT);
+        use Symbol qw(gensym);
+        use Exporter ();
+
+        # new default
+        use Getopt::Long qw(GetOptions);
+        use Fcntl        qw(O_RDONLY O_WRONLY O_EXCL O_CREAT);
+        use Symbol       qw(gensym);
+        use Exporter     ();
+
+    - The parameter -kbb (--keep-break-before) now ignores a request to break
+      before an opening token, such as '('.  Likewise, -kba (--keep-break-after)
+      now ignores a request to break after a closing token, such as ')'. This
+      change was made to avoid a rare instability discovered in random testing.
+
+    - Previously, if a -dsc command was used to delete all side comments,
+      then any special side comments for controlling non-indenting braces got
+      deleted too. Now, these control side comments are retained when -dsc is
+      set unless a -nnib (--nonon-indenting-braces) flag is also set to
+      deactivate them.
+
+    - This version runs about 10 percent faster on large files than the previous
+      release due to optimizations made with the help of Devel::NYTProf.  Much
+      of the gain came from faster processing of blank tokens and comments.
+
+    - This version of perltidy was stress-tested for many cpu hours with
+      random input parameters. No failures to converge, internal fault checks,
+      undefined variable references or other irregularities were seen.
+
+## 2022 02 17
+
+    - A new flag, --encode-output-strings, or -eos, has been added to resolve
+      issue git #83. This issue involves the interface between Perl::Tidy and
+      calling programs, and Code::TidyAll (tidyall) in particular.  The problem
+      is that perltidy by default returns decoded character strings, but
+      tidyall expects encoded strings.  This flag provides a fix for that.
+
+      So, tidyall users who process encoded (utf8) files should update to this
+      version of Perl::Tidy and use -eos for tidyall.  For further info see:
+
+      https://github.com/houseabsolute/perl-code-tidyall/issues/84, and
+      https://github.com/perltidy/perltidy/issues/83
+
+      If there are other applications having utf8 problems at the interface
+      with Perl::Tidy, this flag probably may need to be set.
+
+    - The default value of the new flag, --encode-output-strings, -eos, is currently
+      -neos BUT THIS MAY CHANGE in a future release because the current
+      default is inconvenient.  So authors of programs which receive character
+      strings back from Perl::Tidy should set this flag, if necessary,
+      to avoid any problems when the default changes.  For more information see the
+      above links and the Perl::Tidy man pages for example coding.
+
+    - The possible values of the string 's' for the flag '--character-encoding=s'
+      have been limited to 'utf8' (or UTF-8), 'none', or 'guess'.  Previously an
+      arbitrary encoding could also be specified, but as a result of discussions
+      regarding git #83 it became clear that this could cause trouble
+      since the output encoding was still restricted to UTF-8. Users
+      who need to work in other encodings can write a short program calling
+      Perl::Tidy with pre- and post-processing to handle encoding/decoding.
+
+    - A new flag --break-after-labels=i, or -bal=i, was added for git #86.  This
+      controls line breaks after labels, to provide a uniform style, as follows:
+
+            -bal=0 follows the input line breaks [DEFAULT]
+            -bal=1 always break after a label
+            -bal=2 never break after a label
+
+      For example:
+
+          # perltidy -bal=1
+          INIT:
+            {
+                $xx = 1.234;
+            }
+
+          # perltidy -bal=2
+          INIT: {
+                $xx = 1.234;
+            }
+
+    - Fix issue git #82, an error handling something like ${bareword} in a
+      possible indirect object location. Perl allows this, now perltidy does too.
+
+    - The flags -kbb=s or --keep-old-breakpoints-before=s, and its counterpart
+      -kba=s or --keep-old-breakpoints-after=s have expanded functionality
+      for the container tokens: { [ ( } ] ).  The updated man pages have
+      details.
+
+    - Two new flags have been added to provide finer vertical alignment control,
+      --valign-exclusion-list=s (-vxl=s) and  --valign-inclusion-list=s (-vil=s).
+      This has been requested several times, most recently in git #79, and it
+      finally got done.  For example, -vil='=>' means just align on '=>'.
+
+    - A new flag -gal=s, --grep-alias-list=s, has been added as suggested in
+      git #77.  This allows code blocks passed to list operator functions to
+      be formatted in the same way as a code block passed to grep, map, or sort.
+      By default, the following list operators in List::Util are included:
+
+        all any first none notall reduce reductions
+
+      They can be changed with the flag -gaxl=s, -grep-alias-exclusion-list=s
+
+    - A new flag -xlp has been added which can be set to avoid most of the
+      limitations of the -lp flag regarding side comments, blank lines, and
+      code blocks.  See the man pages for more info. This fixes git #64 and git #74.
+      The older -lp flag still works.
+
+    - A new flag -lpil=s, --line-up-parentheses-inclusion-list=s, has been added
+      as an alternative to -lpxl=s, --line-up-parentheses-exclusion-list=s.
+      It supplies equivalent information but is much easier to describe and use.
+      It works for both the older -lp version and the newer -xlp.
+
+    - The coding for the older -lp flag has been updated to avoid some problems
+      and limitations.  The new coding allows the -lp indentation style to
+      mix smoothly with the standard indentation in a single file.  Some problems
+      where -lp and -xci flags were not working well together have been fixed, such
+      as happened in issue rt140025.  As a result of these updates some minor
+      changes in existing code using the -lp style may occur.
+
+    - This version of perltidy was stress-tested for many cpu hours with
+      random input parameters. No failures to converge, internal fault checks,
+      undefined variable references or other irregularities were seen.
+
+    - Numerous minor fixes have been made, mostly very rare formatting
+      instabilities found in random testing.
+
+## 2021 10 29
+
+    - No significant bugs have been found since the last release, but several
+      minor issues have been fixed.  Vertical alignment has been improved for
+      lists of call args which are not contained within parens (next item).
+
+    - Vertical alignment of function calls without parens has been improved with
+      the goal of making vertical alignment essentially the same with or
+      without parens around the call args.  Some examples:
+
+        # OLD
+        mkTextConfig $c, $x, $y, -anchor => 'se', $color;
+        mkTextConfig $c, $x + 30, $y, -anchor => 's',  $color;
+        mkTextConfig $c, $x + 60, $y, -anchor => 'sw', $color;
+        mkTextConfig $c, $x, $y + 30, -anchor => 'e', $color;
+
+        # NEW
+        mkTextConfig $c, $x,      $y,      -anchor => 'se', $color;
+        mkTextConfig $c, $x + 30, $y,      -anchor => 's',  $color;
+        mkTextConfig $c, $x + 60, $y,      -anchor => 'sw', $color;
+        mkTextConfig $c, $x,      $y + 30, -anchor => 'e',  $color;
+
+        # OLD
+        is id_2obj($id), undef, "unregistered object not retrieved";
+        is scalar keys %$ob_reg, 0, "object registry empty";
+        is register($obj), $obj, "object returned by register";
+        is scalar keys %$ob_reg, 1, "object registry nonempty";
+        is id_2obj($id), $obj, "registered object retrieved";
+
+        # NEW
+        is id_2obj($id),         undef, "unregistered object not retrieved";
+        is scalar keys %$ob_reg, 0,     "object registry empty";
+        is register($obj),       $obj,  "object returned by register";
+        is scalar keys %$ob_reg, 1,     "object registry nonempty";
+        is id_2obj($id),         $obj,  "registered object retrieved";
+
+      This will cause some changes in alignment, hopefully for the better,
+      particularly in test code which often uses numerous parenless function
+      calls with functions like 'ok', 'is', 'is_deeply', ....
+
+    - Two new parameters were added to control the block types to which the
+      -bl (--opening-brace-on-new-line) flag applies.  The new parameters are
+      -block-left-list=s, or -bll=s, and --block-left-exclusion-list=s,
+      or -blxl=s.  Previously the -bl flag was 'hardwired' to apply to
+      nearly all blocks. The default values of the new parameters
+      retain the the old default behavior but allow it to be changed.
+
+    - The default behavior of the -bli (-brace-left-and-indent) flag has changed
+      slightly.  Previously, if you set -bli, then the -bl flag would also
+      automatically be set.  Consequently, block types which were not included
+      in the default list for -bli would get -bl formatting.  This is no longer done,
+      and these two styles are now controlled independently.  The manual describes
+      the controls.  If you want to recover the exact previous default behavior of
+      the -bli then add the -bl flag.
+
+    - A partial fix was made for issue for git #74. The -lp formatting style was
+      being lost when a one-line anonymous sub was followed by a closing brace.
+
+    - Fixed issue git #73, in which the -nfpva flag was not working correctly.
+      Some unwanted vertical alignments of spaced function perens
+      were being made.
+
+    - Updated the man pages to clarify the flags -valign and -novalign
+      for turning vertical alignment on and off (issue git #72).
+      Added parameters -vc -vsc -vbc for separately turning off vertical
+      alignment of code, side comments and block comments.
+
+    - Fixed issue git #68, where a blank line following a closing code-skipping
+      comment, '#>>V', could be lost.
+
+    - This version runs 10 to 15 percent faster on large files than the
+      previous release due to optimizations made with the help of NYTProf.
+
+    - This version of perltidy was stress-tested for many cpu hours with
+      random input parameters. No instabilities,  internal fault checks,
+      undefined variable references or other irregularities were seen.
+
+    - Numerous minor fixes have been made, mostly very rare formatting instabilities
+      found in random testing. An effort has been made to minimize changes to
+      existing formatting that these fixes produce, but occasional changes
+      may occur. Many of these updates are listed at:
+
+           https://github.com/perltidy/perltidy/blob/master/local-docs/BugLog.pod
+
 ## 2021 07 17
 
     - This release is being made mainly because of the next item, in which an
       comment '#<<V' which is not terminated with a closing comment '#>>V'. This
       makes code-skipping and format-skipping behave in a similar way: an
       opening comment without a corresponding closing comment will cause
-      the rest of a file to be skipped.  If there is a question about which lines 
-      are skipped, a .LOG file can be produced with the -g flag and it will have 
+      the rest of a file to be skipped.  If there is a question about which lines
+      are skipped, a .LOG file can be produced with the -g flag and it will have
       this information.
 
     - Removed the limit on -ci=n when -xci is set, reference: rt #136415.
     flags and the --line-up-parens flag.
 
     - Fixed issue git #54 regarding irregular application of the --break-before-paren
-    and similar --break-before-xxx flags, in which lists without commas were not 
+    and similar --break-before-xxx flags, in which lists without commas were not
     being formatted according to these flags.
 
-    - Fixed issue git #53. A flag was added to turn off alignment of spaced function 
+    - Fixed issue git #53. A flag was added to turn off alignment of spaced function
     parens.  If the --space-function-paren, -sfp flag is set, a side-effect is that the
     spaced function parens may get vertically aligned.  This can be undesirable,
     so a new parameter '--function-paren-vertical-alignment', or '-fpva', has been
-    added to turn this vertical alignment off. The default is '-fpva', so that 
+    added to turn this vertical alignment off. The default is '-fpva', so that
     existing formatting is not changed.  Use '-nfpva' to turn off unwanted
     vertical alignment.  To illustrate the possibilities:
 
         # perltidy -sfp
         myfun     ( $aaa, $b, $cc );
         mylongfun ( $a, $b, $c );
-    
+
         # perltidy -sfp -nfpva
         myfun ( $aaa, $b, $cc );
         mylongfun ( $a, $b, $c );
 
 ## 2020 12 01
 
-    - This release is being made primarily to make available a several new formatting 
-      parameters, in particular -xci, -kbb=s, -kba=s, and -wnxl=s. No significant 
-      bugs have been found since the previous release, but numerous minor issues have 
+    - This release is being made primarily to make available a several new formatting
+      parameters, in particular -xci, -kbb=s, -kba=s, and -wnxl=s. No significant
+      bugs have been found since the previous release, but numerous minor issues have
       been found and fixed as listed below.
 
     - This version is about 20% faster than the previous version due to optimizations
 
     - Fixed issue git #45, -vtc=n flag was ignored when -wn was set.
 
-    - implement request RT #133649, delete-old-newlines selectively. Two parameters, 
+    - implement request RT #133649, delete-old-newlines selectively. Two parameters,
 
       -kbb=s or --keep-old-breakpoints-before=s, and
       -kba=s or --keep-old-breakpoints-after=s
       were added to request that old breakpoints be kept before or after
       selected token types.  For example, -kbb='=>' means that newlines before
       fat commas should be kept.
-      
     - Fix git #44, fix exit status for assert-tidy/untidy.  The exit status was
       always 0 for --assert-tidy if the user had turned off all error messages with
       the -quiet flag.  This has been fixed.