1Test::TrailingSpace(3)User Contributed Perl DocumentationTest::TrailingSpace(3)
2
3
4
6 Test::TrailingSpace - test for trailing space in source files.
7
9 version 0.0601
10
12 use Test::TrailingSpace;
13
14 my $finder = Test::TrailingSpace->new(
15 {
16 root => '.',
17 filename_regex => qr/\.(?:t|pm|pl)\z/,
18 },
19 );
20
21 # TEST
22 $finder->no_trailing_space(
23 "No trailing space was found."
24 );
25
26 Or, if you want the test to be optional:
27
28 use Test::More;
29
30 eval "use Test::TrailingSpace";
31 if ($@)
32 {
33 plan skip_all => "Test::TrailingSpace required for trailing space test.";
34 }
35 else
36 {
37 plan tests => 1;
38 }
39
40 my $finder = Test::TrailingSpace->new(
41 {
42 root => '.',
43 filename_regex => qr/\.(?:t|pm|pl)\z/,
44 },
45 );
46
47 # TEST
48 $finder->no_trailing_space(
49 "No trailing space was found."
50 );
51
53 This module is used to test for lack of trailing space. See the
54 synopsis for more details.
55
56 NOTE: there is an older CPAN distribution titled Test::EOL that also
57 supports testing for trailing space / trailing whitespace, although it
58 has some limitations that Test::TrailingSpace does not have, and also
59 only calls it "trailing whitespace", rather than "trailing space".
60 Whenever possible, one should prefer to use it, instead of this module.
61
63 new({ root => ".", filename_regex => qr/\. ... \z/,})
64 Constructs a new object with the root (that defaults to "." and the
65 filename matching regular expression. All the files under root matching
66 the pattern will be searched (excpet for those under version control
67 directories, "blib", "_build", etc.).
68
69 The 'abs_path_prune_re' parameter can be used to specify a regular
70 expression to prune the absolute path based on, so as to ignore what is
71 under there.
72
73 The 'find_tabs' option, if set to a true value, detects and reports for
74 the presence of hard tabs ('\t'). (Added in version 0.0400)
75
76 The 'find_cr' option, if set to a true value, detects and reports for
77 the presence of carriage returns at the end of lines. (DOS-style line
78 endings.) It was added in version 0.0400. So
79
80 my $finder = Test::TrailingSpace->new(
81 {
82 root => '.',
83 filename_regex => qr/\.(?:t|pm|pl)\z/,
84 abs_path_prune_re => qr#\Alib/sample-data#,
85 }
86 );
87
88 Will ignore everything under "lib/sample-data" . Note that as of
89 Test::TrailingSpace version 0.0300 it can also be used to skip files
90 with these filenames (e.g: "abs_path_prune_re => qr#\.patch\z#").
91
92 $finder->no_trailing_space($blurb)
93 Determines if there is no trailing space in the source files. Returns
94 true if no trailing space was found, and false if trailing space was
95 found. It is equivalent to Test::More::ok(), with diagnostics to
96 report if there is trailing space.
97
99 Shlomi Fish, <http://www.shlomifish.org/> .
100
102 • Test::EOL
103
104 Test::EOL
105
106 • Test::NoTabs
107
108 Test::NoTabs
109
111 Copyright 2012 Shlomi Fish.
112
113 This program is distributed under the MIT (X11) License:
114 <http://www.opensource.org/licenses/mit-license.php>
115
116 Permission is hereby granted, free of charge, to any person obtaining a
117 copy of this software and associated documentation files (the
118 "Software"), to deal in the Software without restriction, including
119 without limitation the rights to use, copy, modify, merge, publish,
120 distribute, sublicense, and/or sell copies of the Software, and to
121 permit persons to whom the Software is furnished to do so, subject to
122 the following conditions:
123
124 The above copyright notice and this permission notice shall be included
125 in all copies or substantial portions of the Software.
126
127 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
128 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
129 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
130 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
131 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
132 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
133 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
134
136 Websites
137 The following websites have more information about this module, and may
138 be of help to you. As always, in addition to those websites please use
139 your favorite search engine to discover more resources.
140
141 • MetaCPAN
142
143 A modern, open-source CPAN search engine, useful to view POD in
144 HTML format.
145
146 <https://metacpan.org/release/Test-TrailingSpace>
147
148 • RT: CPAN's Bug Tracker
149
150 The RT ( Request Tracker ) website is the default bug/issue
151 tracking system for CPAN.
152
153 <https://rt.cpan.org/Public/Dist/Display.html?Name=Test-TrailingSpace>
154
155 • CPANTS
156
157 The CPANTS is a website that analyzes the Kwalitee ( code metrics )
158 of a distribution.
159
160 <http://cpants.cpanauthors.org/dist/Test-TrailingSpace>
161
162 • CPAN Testers
163
164 The CPAN Testers is a network of smoke testers who run automated
165 tests on uploaded CPAN distributions.
166
167 <http://www.cpantesters.org/distro/T/Test-TrailingSpace>
168
169 • CPAN Testers Matrix
170
171 The CPAN Testers Matrix is a website that provides a visual
172 overview of the test results for a distribution on various
173 Perls/platforms.
174
175 <http://matrix.cpantesters.org/?dist=Test-TrailingSpace>
176
177 • CPAN Testers Dependencies
178
179 The CPAN Testers Dependencies is a website that shows a chart of
180 the test results of all dependencies for a distribution.
181
182 <http://deps.cpantesters.org/?module=Test::TrailingSpace>
183
184 Bugs / Feature Requests
185 Please report any bugs or feature requests by email to
186 "bug-test-trailingspace at rt.cpan.org", or through the web interface
187 at
188 <https://rt.cpan.org/Public/Bug/Report.html?Queue=Test-TrailingSpace>.
189 You will be automatically notified of any progress on the request by
190 the system.
191
192 Source Code
193 The code is open to the world, and available for you to hack on. Please
194 feel free to browse it and play with it, or whatever. If you want to
195 contribute patches, please send me a diff or prod me to pull from your
196 repository :)
197
198 <https://github.com/shlomif/perl-test-trailingspace>
199
200 git clone git://github.com/shlomif/perl-test-trailingspace.git
201
203 Shlomi Fish <shlomif@cpan.org>
204
206 Please report any bugs or feature requests on the bugtracker website
207 <https://github.com/shlomif/perl-test-trailingspace/issues>
208
209 When submitting a bug or request, please include a test-file or a patch
210 to an existing test-file that illustrates the bug or desired feature.
211
213 This software is Copyright (c) 2012 by Shlomi Fish.
214
215 This is free software, licensed under:
216
217 The MIT (X11) License
218
219
220
221perl v5.34.0 2021-08-27 Test::TrailingSpace(3)