Bugzilla – Attachment 179501 Details for
Bug 39325
Run codespell successfully on the whole codebase
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39325: [DO NOT PUSH] script
Bug-39325-DO-NOT-PUSH-script.patch (text/plain), 3.21 KB, created by
Jonathan Druart
on 2025-03-20 10:53:11 UTC
(
hide
)
Description:
Bug 39325: [DO NOT PUSH] script
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-03-20 10:53:11 UTC
Size:
3.21 KB
patch
obsolete
>From 3e47d69d32d6e7ee7cb4f34ed1035d274be5ebf9 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 13 Mar 2025 15:47:02 +0100 >Subject: [PATCH] Bug 39325: [DO NOT PUSH] script > >Script used to generate the "Automatic fix" patch. >I don't think we need this script pushed. >--- > misc/devel/codespell.pl | 71 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 71 insertions(+) > create mode 100755 misc/devel/codespell.pl > >diff --git a/misc/devel/codespell.pl b/misc/devel/codespell.pl >new file mode 100755 >index 00000000000..6d30448b357 >--- /dev/null >+++ b/misc/devel/codespell.pl >@@ -0,0 +1,71 @@ >+#!/usr/bin/perl >+use Modern::Perl; >+use Test::PerlTidy; >+use Test::More; >+use File::Slurp qw(read_file write_file); >+use Parallel::ForkManager; >+ >+my @files; >+push @files, >+ qx{git ls-files '*.pl' '*.PL' '*.pm' '*.t' ':(exclude)installer/data/mysql/updatedatabase.pl' ':(exclude)installer/data/mysql/update22to30.pl' ':(exclude)misc/cronjobs/build_browser_and_cloud.pl'}; >+push @files, qx{git ls-files svc opac/svc}; # Files without extension >+push @files, qx{git ls-files '*.tt' '*.inc'}; >+push @files, >+ qx{git ls-files '*.js' '*.ts' '*.vue' ':(exclude)koha-tmpl/intranet-tmpl/lib' ':(exclude)koha-tmpl/intranet-tmpl/js/Gettext.js' ':(exclude)koha-tmpl/opac-tmpl/lib' ':(exclude)koha-tmpl/opac-tmpl/bootstrap/js/Gettext.js'}; >+ >+my $nproc ||= qx{nproc}; >+my $pm = Parallel::ForkManager->new($nproc); >+ >+my $files_edit; >+$pm->run_on_finish( >+ sub { >+ my ( $pid, $exit_code, $ident, $exit_signal, $core_dump, $data_ref ) = @_; >+ $files_edit->{ $data_ref->{file} } = $data_ref->{edits}; >+ } >+); >+ >+while ( my ( $i, $file ) = each @files ) { >+ chomp $file; >+ $pm->start and next; >+ say sprintf "%s (%s/%s)", $file, $i + 1, scalar @files; >+ my $output = qx{codespell -d --ignore-words .codespell-ignore $file}; >+ chomp $output; >+ my @edits; >+ if ($output) { >+ my @lines = split "\n", $output; >+ for my $line (@lines) { >+ >+ # C4/Auth.pm:144: authentification ==> authentication >+ if ( $line =~ m{(?<file>[^:]*):(?<line>\d+): (?<pattern>\w+) ==> (?<replace>.*)} ) { >+ my $line_number = $+{line} - 1; >+ my $pattern = $+{pattern}; >+ my $replace = $+{replace}; >+ if ( $replace =~ m{,} ) { >+ $replace = "FIXME CODESPELL ($pattern ==> $replace)"; >+ } >+ push @edits, { >+ line_number => $line_number, >+ pattern => $pattern, >+ replace => $replace, >+ }; >+ } else { >+ warn "Unsupported output line: $line"; >+ } >+ } >+ } >+ $pm->finish( 0, { file => $file, edits => \@edits } ); >+} >+$pm->wait_all_children; >+ >+while ( my ( $file, $edits ) = each %$files_edit ) { >+ my @content = read_file($file); >+ for my $edit (@$edits) { >+ my $file = $edit->{file}; >+ my $line_number = $edit->{line_number}; >+ my $pattern = $edit->{pattern}; >+ my $replace = $edit->{replace}; >+ $content[$line_number] =~ s#$pattern#$replace#g; >+ } >+ write_file( $file, @content ); >+} >+ >-- >2.34.1
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 39325
:
179269
|
179270
|
179271
|
179272
|
179501
|
179502
|
179503
|
179504
|
179505
|
179506
|
179507
|
179508
|
179509
|
179510
|
179511
|
179512
|
179517
|
179518
|
179519
|
179522
|
179525
|
179527
|
179528
|
179529
|
179530
|
179531
|
179532
|
179533
|
179534
|
180137
|
180138
|
180139
|
180140
|
180141
|
180142
|
180143
|
180144
|
180145
|
180146
|
180147
|
180148
|
180149
|
180150
|
181510
|
181511
|
181512
|
181513
|
181514
|
181515
|
181516
|
181517
|
181518
|
181519
|
181520
|
181521
|
181522
|
181523
|
181611
|
181612
|
181613
|
181614
|
181615
|
181616
|
181617
|
181618
|
181619
|
181620
|
181621
|
181637
|
181651
|
181983