]> git.sur5r.net Git - i3/i3/blob - travis/check-spelling.pl
travis: check spelling of binaries and manpages, use docker
[i3/i3] / travis / check-spelling.pl
1 #!/usr/bin/env perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # © 2016 Michael Stapelberg
5 #
6 # Checks for spelling errors in binaries and manpages (to be run by continuous
7 # integration to point out spelling errors before accepting contributions).
8
9 use strict;
10 use warnings;
11 use v5.10;
12 use autodie;
13 use lib 'testcases/lib';
14 use i3test::Util qw(slurp);
15 use Lintian::Check qw(check_spelling);
16
17 # Lintian complains if we don’t set a vendor.
18 use Lintian::Data;
19 use Lintian::Profile;
20 Lintian::Data->set_vendor(
21     Lintian::Profile->new('debian', ['/usr/share/lintian'], {}));
22
23 my $exitcode = 0;
24
25 # Whitelist for spelling errors in manpages, in case the spell checker has
26 # false-positives.
27 my $binary_spelling_exceptions = {
28     #'exmaple' => 1, # Example for how to add entries to this whitelist.
29     'betwen' => 1, # asan_flags.inc contains this spelling error.
30 };
31 my @binaries = qw(
32     i3
33     i3-config-wizard/i3-config-wizard
34     i3-dump-log/i3-dump-log
35     i3-input/i3-input
36     i3-msg/i3-msg
37     i3-nagbar/i3-nagbar
38     i3bar/i3bar
39 );
40 for my $binary (@binaries) {
41     check_spelling(slurp($binary), $binary_spelling_exceptions, sub {
42         my ($current, $fixed) = @_;
43         say STDERR qq|Binary "$binary" contains a spelling error: "$current" should be "$fixed"|;
44         $exitcode = 1;
45     });
46 }
47
48 # Whitelist for spelling errors in manpages, in case the spell checker has
49 # false-positives.
50 my $manpage_spelling_exceptions = {
51 };
52
53 for my $name (glob('man/*.1')) {
54     for my $line (split(/\n/, slurp($name))) {
55         next if $line =~ /^\.\\\"/o;
56         check_spelling($line, $manpage_spelling_exceptions, sub {
57             my ($current, $fixed) = @_;
58             say STDERR qq|Manpage "$name" contains a spelling error: "$current" should be "$fixed"|;
59             $exitcode = 1;
60         });
61     }
62 }
63
64 exit $exitcode;