3 # Copyright (C) 2017 Genome Research Ltd.
5 # Author: Anders Kaplan
7 # Permission is hereby granted, free of charge, to any person obtaining a copy
8 # of this software and associated documentation files (the "Software"), to deal
9 # in the Software without restriction, including without limitation the rights
10 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 # copies of the Software, and to permit persons to whom the Software is
12 # furnished to do so, subject to the following conditions:
14 # The above copyright notice and this permission notice shall be included in
15 # all copies or substantial portions of the Software.
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 # DEALINGS IN THE SOFTWARE.
27 my $log_message_count = 0;
29 my $failure_count = 0;
33 my ($message, $filename, $line_num) = @_;
36 unless ($message =~ /^\"([A-Z]|%s)/)
38 print "$filename line $line_num:\n";
39 print "Log message should begin with a capital letter: $message.\n";
43 if ($message =~ /\\n\"$/)
45 print "$filename line $line_num:\n";
46 print "Log message should NOT end with a newline: $message.\n";
50 if ($message =~ /\.\"$/)
52 print "$filename line $line_num:\n";
53 print "Log message should NOT end with a full stop: $message.\n";
63 open(my $fh, '<', $filename) or die "Could not open $filename.";
68 if ($line =~ /hts_log_\w+\s*\(\s*(\"[^\"]*\")/)
70 unless ($line =~ /\\n\"\s*$/) # string constant continues on next line
72 check_log_message
($1, $filename, $line_num);
84 foreach my $filename (glob("$path/*.c"))
86 check_file
($filename);
93 print "$file_count files scanned\n";
94 print "$log_message_count log messages checked\n";
95 print "$failure_count errors found\n";
96 exit($failure_count > 0);