Lines 96-105
sub check_forbidden_patterns {
Link Here
|
96 |
: 1; |
96 |
: 1; |
97 |
} |
97 |
} |
98 |
|
98 |
|
|
|
99 |
sub codespell_has_L_option { |
100 |
my $cmd = q{codespell --help | grep "\-L" | wc -l}; |
101 |
my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 ); |
102 |
my $result = $full_buf->[0]; |
103 |
return $result + 0; |
104 |
} |
105 |
|
106 |
sub remove_codespell { |
107 |
my $cmd = q{sudo apt remove -y codespell}; |
108 |
my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 ); |
109 |
$cmd = q{sudo -H pip uninstall -y codespell}; |
110 |
( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 ); |
111 |
} |
112 |
|
113 |
sub install_codespell { |
114 |
my $cmd = q{sudo -H pip install codespell}; |
115 |
my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 ); |
116 |
} |
117 |
|
118 |
sub tell_bash_to_unhash_codespell { |
119 |
my $cmd = q{hash -d codespell}; |
120 |
my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 ); |
121 |
} |
122 |
|
99 |
sub check_spelling { |
123 |
sub check_spelling { |
100 |
my ($self) = @_; |
124 |
my ($self) = @_; |
101 |
|
125 |
|
102 |
my $cmd = q{codespell -L Sheat -d } . $self->path; |
126 |
if (! codespell_has_L_option()) { |
|
|
127 |
print STDERR "\nCodespell missing required -L option!\n"; |
128 |
remove_codespell; |
129 |
install_codespell; |
130 |
tell_bash_to_unhash_codespell; |
131 |
} |
132 |
my $cmd = q{codespell -L sheat -d } . $self->path; |
103 |
my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 ); |
133 |
my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run( command => $cmd, verbose => 0 ); |
104 |
|
134 |
|
105 |
return 0 unless @$full_buf; |
135 |
return 0 unless @$full_buf; |