Bugzilla – Attachment 48864 Details for
Bug 16003
Add spelling exclusion patch to QA Test tools
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 16003: Add exception pattern list for codespell checks
SIGNED-OFF-Bug-16003-Add-exception-pattern-list-fo.patch (text/plain), 3.22 KB, created by
Mark Tompsett
on 2016-03-09 14:31:30 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 16003: Add exception pattern list for codespell checks
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2016-03-09 14:31:30 UTC
Size:
3.22 KB
patch
obsolete
>From ebbb8b38d76ab0a156f103898e709d5bae496f40 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 9 Mar 2016 09:19:59 +0000 >Subject: [PATCH] [SIGNED-OFF] Bug 16003: Add exception pattern list for > codespell checks > >The 'isnt' Test::More subroutine should not be considered as a failure >by the codespell check. >To avoid that this patch introduces the concept of "exception patterns" >for this check. > >NOTE: This is better than introducing a '-x {exception file}', because > it dynamically handles the isnt( issue. If other similar function > name issues arise in the future, modifications to the > i_dont_fail_spelling.pl file and the exception list can be made. > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> >--- > QohA/File.pm | 24 ++++++++++++++++++++---- > t/Perl.t | 8 ++++++++ > t/data/5/perl/i_dont_fail_spelling.pl | 4 ++++ > 3 files changed, 32 insertions(+), 4 deletions(-) > create mode 100644 t/data/5/perl/i_dont_fail_spelling.pl > >diff --git a/QohA/File.pm b/QohA/File.pm >index 420dfbd..0b828b9 100644 >--- a/QohA/File.pm >+++ b/QohA/File.pm >@@ -80,6 +80,9 @@ sub check_spelling { > > return 0 unless @$full_buf; > >+ my @exceptions = ( >+ qr{isnt\(}, >+ ); > # Encapsulate the potential errors > my @errors; > my @lines = split /\n/, $full_buf->[0]; >@@ -88,10 +91,23 @@ sub check_spelling { > > # Remove filepath and line numbers > # my/file/path:xxx: indentifier ==> identifier >- my $re = q|^| . $self->path . q|:\d+:|; >- $line =~ s|$re||; >- >- push @errors, $line; >+ my $re = q|^| . $self->path . q|:(\d+):|; >+ if ( $line =~ $re ) { >+ my $line_number = $1; >+ my $p = $self->path; >+ my $guilty_line = `sed -n '${line_number}p' $p`; >+ my $is_an_exception; >+ for my $e ( @exceptions ) { >+ if ( $guilty_line =~ $e ) { >+ $is_an_exception = 1; >+ last; >+ } >+ } >+ unless ( $is_an_exception ) { >+ $line =~ s|$re||; >+ push @errors, $line; >+ } >+ } > } > > return @errors >diff --git a/t/Perl.t b/t/Perl.t >index 70d8df4..2bac98f 100644 >--- a/t/Perl.t >+++ b/t/Perl.t >@@ -92,6 +92,7 @@ eval { > our $STATUS_OK = "${GREEN}OK${END}"; > my $r_v0_expected = <<EOL; > $STATUS_KO perl/Authority.pm >+ $STATUS_OK perl/i_dont_fail_spelling.pl > $STATUS_KO perl/i_fail_license.pl > $STATUS_KO perl/i_fail_spelling.pl > $STATUS_KO perl/i_fail_template_name.pl >@@ -119,6 +120,13 @@ EOL > $STATUS_OK spelling > $STATUS_OK valid > >+ $STATUS_OK perl/i_dont_fail_spelling.pl >+ $STATUS_OK critic >+ $STATUS_OK forbidden patterns >+ $STATUS_OK pod >+ $STATUS_OK spelling >+ $STATUS_OK valid >+ > $STATUS_KO perl/i_fail_license.pl > $STATUS_OK critic > $STATUS_KO forbidden patterns >diff --git a/t/data/5/perl/i_dont_fail_spelling.pl b/t/data/5/perl/i_dont_fail_spelling.pl >new file mode 100644 >index 0000000..491f410 >--- /dev/null >+++ b/t/data/5/perl/i_dont_fail_spelling.pl >@@ -0,0 +1,4 @@ >+use Modern::Perl; >+use Test::More tests => 1; >+ >+isnt(1, 1, 'This is a correct spelling'); >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16003
:
48765
|
48782
|
48791
|
48839
| 48864