Menu

#257 New rule: Calling File.append() more than once or in a loop

open
nobody
None
5
2011-04-16
2011-04-16
Chris Mair
No

This is from a Tweet from Tim Yates (tim_yates) – Feb 24, 2011: “There should be a codenarc rule about calling #groovy File.append more than once on the same file or in a loop (use withWriterAppend)”.

It's a good idea, but it will be tricky, I think, to determine that you are calling append() on a File object, given our limited AST level.

Discussion

  • Chris Mair

    Chris Mair - 2011-04-16
    • summary: New rule: Cal;ling File.append() more than once or in a loop --> New rule: Calling File.append() more than once or in a loop
     
  • Chris Mair

    Chris Mair - 2011-07-24

    Also note (from duplicate issue #3370221):

    This opens and closes the file every time. Beware, the << operator is a file append too!

     

Log in to post a comment.