From d83901363a9992a0a81b0580e809b30fa5ac3962 Mon Sep 17 00:00:00 2001 From: Paul Howarth Date: Fri, 21 Jul 2017 11:50:35 +0100 Subject: [PATCH] Change default spell check tool from aspell to hunspell This is on the basis that most downstream users are already doing or have migrated from aspell to hunspell due to hunspell being actively maintained, unlike aspell. https://wiki.ubuntu.com/ConsolidateSpellingLibs https://wiki.gnome.org/Initiatives/SpellChecking https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=860895 https://fedoraproject.org/wiki/Releases/FeatureDictionary Unfortunately, hunspell prior to about version 1.2.12 (2010) had problems with ASCII apostrophes, thus flagging errors for words like "doesn't", "isn't" etc., which makes 1.2.12 pretty much a minimum version requirement if incorporating this change. --- .travis.yml | 4 ++-- .../Policy/BuiltinFunctions/ProhibitLvalueSubstr.pm | 2 +- lib/Perl/Critic/Policy/Documentation/PodSpelling.pm | 20 ++++++++++---------- .../RequireCheckingReturnValueOfEval.pm | 2 +- .../Critic/Policy/Modules/RequireBarewordIncludes.pm | 2 ++ .../RegularExpressions/ProhibitComplexRegexes.pm | 2 +- .../Policy/Variables/RequireLexicalLoopIterators.pm | 2 +- t/20_policy_pod_spelling.t | 4 ++-- xt/40_perlcriticrc-code | 2 +- 9 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6eeb384..c068d44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,8 +30,8 @@ notifications: addons: apt: packages: - - aspell - - aspell-en + - hunspell + - hunspell-en-us install: diff --git a/lib/Perl/Critic/Policy/BuiltinFunctions/ProhibitLvalueSubstr.pm b/lib/Perl/Critic/Policy/BuiltinFunctions/ProhibitLvalueSubstr.pm index dccaab0..1270780 100644 --- a/lib/Perl/Critic/Policy/BuiltinFunctions/ProhibitLvalueSubstr.pm +++ b/lib/Perl/Critic/Policy/BuiltinFunctions/ProhibitLvalueSubstr.pm @@ -64,7 +64,7 @@ __END__ =pod -=for stopwords perlfunc substr 4th +=for stopwords perl5005delta perlfunc substr 4th =head1 NAME diff --git a/lib/Perl/Critic/Policy/Documentation/PodSpelling.pm b/lib/Perl/Critic/Policy/Documentation/PodSpelling.pm index 8049d89..de609ed 100644 --- a/lib/Perl/Critic/Policy/Documentation/PodSpelling.pm +++ b/lib/Perl/Critic/Policy/Documentation/PodSpelling.pm @@ -39,7 +39,7 @@ sub supported_parameters { { name => 'spell_command', description => 'The command to invoke to check spelling.', - default_string => 'aspell list', + default_string => 'hunspell -l', behavior => 'string', }, { @@ -200,11 +200,11 @@ sub _run_spell_command { # run spell command and fetch output local $SIG{PIPE} = sub { $got_sigpipe = 1; }; my $command_line = join $SPACE, @{$self->_get_spell_command_line()}; - open my $aspell_out_fh, q{-|}, "$command_line < $outfile" ## Is this portable?? + open my $speller_out_fh, q{-|}, "$command_line < $outfile" ## Is this portable?? or throw_generic "Failed to open handle to spelling program: $OS_ERROR"; - @words = uniq( <$aspell_out_fh> ); - close $aspell_out_fh + @words = uniq( <$speller_out_fh> ); + close $speller_out_fh or throw_generic "Failed to close handle to spelling program: $OS_ERROR"; for (@words) { @@ -324,11 +324,11 @@ set a global list of spelling exceptions. To do this, put entries in a F<.perlcriticrc> file like this: [Documentation::PodSpelling] - spell_command = aspell list + spell_command = hunspell -l stop_words = gibbles foobar stop_words_file = some/path/with/stop/words.txt -The default spell command is C and it is interpreted as a +The default spell command is C and it is interpreted as a shell command. We parse the individual arguments via L so feel free to use quotes around your arguments. If the executable path is an absolute file name, it @@ -358,13 +358,13 @@ together into a single list of exemptions. A spell checking program is not included with Perl::Critic. -The results of failures for this policy can be confusing when F +The results of failures for this policy can be confusing when F complains about words containing punctuation such as hyphens and apostrophes. -In this situation F will often only emit part of the word that it -thinks is misspelled. For example, if you ask F to check +In this situation F will often only emit part of the word that it +thinks is misspelled. For example, if you ask F to check "foobie-bletch", the output only complains about "foobie". Unfortunately, you'll have to look through your POD to figure out what the real word that -F is complaining about is. One thing to try is looking at the output +F is complaining about is. One thing to try is looking at the output of C<< perl -MPod::Spell -e 'print Pod::Spell->new()->parse_from_file("lib/Your/Module.pm")' >> to see what is actually being checked for spelling. diff --git a/lib/Perl/Critic/Policy/ErrorHandling/RequireCheckingReturnValueOfEval.pm b/lib/Perl/Critic/Policy/ErrorHandling/RequireCheckingReturnValueOfEval.pm index 6865003..6845573 100644 --- a/lib/Perl/Critic/Policy/ErrorHandling/RequireCheckingReturnValueOfEval.pm +++ b/lib/Perl/Critic/Policy/ErrorHandling/RequireCheckingReturnValueOfEval.pm @@ -299,7 +299,7 @@ __END__ =pod -=for stopwords destructors +=for stopwords destructors perl5 =head1 NAME diff --git a/lib/Perl/Critic/Policy/Modules/RequireBarewordIncludes.pm b/lib/Perl/Critic/Policy/Modules/RequireBarewordIncludes.pm index 5ad8768..b084dac 100644 --- a/lib/Perl/Critic/Policy/Modules/RequireBarewordIncludes.pm +++ b/lib/Perl/Critic/Policy/Modules/RequireBarewordIncludes.pm @@ -46,6 +46,8 @@ __END__ =pod +=for stopwords Perl4 + =head1 NAME Perl::Critic::Policy::Modules::RequireBarewordIncludes - Write C instead of C. diff --git a/lib/Perl/Critic/Policy/RegularExpressions/ProhibitComplexRegexes.pm b/lib/Perl/Critic/Policy/RegularExpressions/ProhibitComplexRegexes.pm index 46aa649..30316e3 100644 --- a/lib/Perl/Critic/Policy/RegularExpressions/ProhibitComplexRegexes.pm +++ b/lib/Perl/Critic/Policy/RegularExpressions/ProhibitComplexRegexes.pm @@ -99,7 +99,7 @@ __END__ =pod -=for stopwords BNF Tatsuhiko Miyagawa +=for stopwords BNF RFC822 Tatsuhiko Miyagawa =head1 NAME diff --git a/lib/Perl/Critic/Policy/Variables/RequireLexicalLoopIterators.pm b/lib/Perl/Critic/Policy/Variables/RequireLexicalLoopIterators.pm index 4690658..8185dd9 100644 --- a/lib/Perl/Critic/Policy/Variables/RequireLexicalLoopIterators.pm +++ b/lib/Perl/Critic/Policy/Variables/RequireLexicalLoopIterators.pm @@ -66,7 +66,7 @@ __END__ =pod -=for stopwords foreach perlsyn +=for stopwords foreach perl5004delta perlsyn =head1 NAME diff --git a/t/20_policy_pod_spelling.t b/t/20_policy_pod_spelling.t index f41a5c6..7b37030 100644 --- a/t/20_policy_pod_spelling.t +++ b/t/20_policy_pod_spelling.t @@ -58,10 +58,10 @@ $code = <<'END_PERL'; =cut END_PERL -# Sorry about the double negative. The idea is that if aspell fails (say, +# Sorry about the double negative. The idea is that if hunspell fails (say, # because it can not find the right dictionary) or pcritique returns a # non-zero number we want to skip. We have to negate the eval to catch the -# aspell failure, and then negate pcritique because we negated the eval. +# hunspell failure, and then negate pcritique because we negated the eval. # Clearer code welcome. if ( ! eval { ! pcritique($policy, \$code) } ) { skip 'Test environment is not English', $NUMBER_OF_TESTS; diff --git a/xt/40_perlcriticrc-code b/xt/40_perlcriticrc-code index c37fede..253d15c 100644 --- a/xt/40_perlcriticrc-code +++ b/xt/40_perlcriticrc-code @@ -18,7 +18,7 @@ strict = 1 [-Documentation::RequirePodLinksIncludeText] [Documentation::PodSpelling] -spell_command = aspell list -l en_US +spell_command = hunspell -l -d en_US stop_words_file = xt/40_stop_words [Documentation::RequirePodSections] -- 2.9.4