File Coverage

blib/lib/Code/TidyAll/Plugin/SortLines.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 17 17 100.0


line stmt bran cond sub pod time code
1             package Code::TidyAll::Plugin::SortLines;
2              
3 1     1   558 use strict;
  1         2  
  1         31  
4 1     1   6 use warnings;
  1         2  
  1         26  
5              
6 1     1   4 use Moo;
  1         2  
  1         8  
7              
8             extends 'Code::TidyAll::Plugin';
9              
10             our $VERSION = '0.83';
11              
12             sub transform_source {
13 2     2 1 4 my ( $self, $source ) = @_;
14              
15 2         13 return join( "\n", sort( grep {/\S/} split( /\n/, $source ) ) ) . "\n";
  6         32  
16             }
17              
18             1;
19              
20             # ABSTRACT: Sort the lines in a file
21              
22             __END__
23              
24             =pod
25              
26             =encoding UTF-8
27              
28             =head1 NAME
29              
30             Code::TidyAll::Plugin::SortLines - Sort the lines in a file
31              
32             =head1 VERSION
33              
34             version 0.83
35              
36             =head1 SYNOPSIS
37              
38             # In configuration:
39              
40             [SortLines]
41             select = .ispell* **/.gitignore
42              
43             =head1 DESCRIPTION
44              
45             Sorts the lines of a file; whitespace lines are discarded. Useful for files
46             containing one entry per line, such as C<.svnignore>, C<.gitignore>, and
47             C<.ispell*>.
48              
49             =head1 SUPPORT
50              
51             Bugs may be submitted at L<https://github.com/houseabsolute/perl-code-tidyall/issues>.
52              
53             =head1 SOURCE
54              
55             The source code repository for Code-TidyAll can be found at L<https://github.com/houseabsolute/perl-code-tidyall>.
56              
57             =head1 AUTHORS
58              
59             =over 4
60              
61             =item *
62              
63             Jonathan Swartz <swartz@pobox.com>
64              
65             =item *
66              
67             Dave Rolsky <autarch@urth.org>
68              
69             =back
70              
71             =head1 COPYRIGHT AND LICENSE
72              
73             This software is copyright (c) 2011 - 2022 by Jonathan Swartz.
74              
75             This is free software; you can redistribute it and/or modify it under
76             the same terms as the Perl 5 programming language system itself.
77              
78             The full text of the license can be found in the
79             F<LICENSE> file included with this distribution.
80              
81             =cut