#872432 licensecheck: should support adding (not replacing) ignores

Package:
licensecheck
Source:
licensecheck
Submitter:
IOhannes m zmoelnig
Date:
2025-04-08 10:57:01 UTC
Severity:
wishlist
Tags:
Blocked By:
Bug Title
960695

  4

licensecheck: add usage option, to covermore than current "only look for source code"

wishlist stable testing unstable about 1 year ago

#872432#5
Date:
2017-08-17 10:45:24 UTC
From:
To:
Dear Maintainer,

licensecheck comes with an '--ignore' option that allows to specify a filename
exclusion pattern.
unfortunately, using that option will *override* the built-in ignore patterns,
which are (not very) accurately defined in the help with "some backup and VCS
files".
in most cases, i would like to specify additional ignore patterns, without
having to worry about what "some backup and VCS files" really means and without
having to maintain these files seprately, thus duplicating the work of the
licensecheck upstream.
fwiw, usually i'd like to ignore some binary files.

i therefore would like to suggest to add an(other ?) option that would allow me
to specify an *additional* filename pattern to be ignored.

#872432#10
Date:
2017-10-06 08:29:21 UTC
From:
To:
here's a smallish patch that allows to specify a regex for *additionally*
ignored files when doing a licensecheck, as requested in #872432.

this is kept separately from the original "--ignore|-i" flag to not break any
existing uses of licensecheck. also i think that "-x" is easier to remember than
"--install^Wignore" :-)

since my perl-foo is small, i hope i didn't do any spectacular stupidities.
(but please check)


IOhannes m zmölnig (Debian/GNU) (1):
  New "--extra-ignore" flag to ignore additional files from licensecheck

 bin/licensecheck        | 22 +++++++++++++---------
 lib/App/Licensecheck.pm | 23 +++++++++++++++++++----
 2 files changed, 32 insertions(+), 13 deletions(-)

#872432#15
Date:
2017-10-06 08:29:22 UTC
From:
To:
that's in addition to "some backup and VCS files" which we usually want
to ignore in any case.

Closes: #872432
---
 bin/licensecheck        | 22 +++++++++++++---------
 lib/App/Licensecheck.pm | 23 +++++++++++++++++++----
 2 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/bin/licensecheck b/bin/licensecheck
index df8da68..4148eae 100755
--- a/bin/licensecheck
+++ b/bin/licensecheck
@@ -61,6 +61,9 @@ my ( $opt, $usage ) = describe_options(
 	[   'ignore|i=s', 'regular expression of files to skip',
 		{ default => 'some backup and VCS files' }
 	],
+	[   'extra-ignore|x=s', 'regular expression of additional files to skip',
+		{ default => '<none>' }
+	],
 	[ 'recursive|r', 'traverse directories recursively' ],
 	[],
 	[   'lines|l=i',
@@ -128,15 +131,16 @@ print( "$progname: No paths provided.\n", $usage->leader_text ), exit 2
 	unless @ARGV;

 my $app = App::Licensecheck->new(
-	check_regex  => $opt->check,
-	ignore_regex => $opt->ignore,
-	recursive    => $opt->recursive,
-	lines        => $opt->lines,
-	tail         => $opt->tail,
-	verbose      => $opt->verbose,
-	skipped      => $opt->skipped,
-	deb_fmt      => $opt->deb_fmt // $opt->deb_machine,
-	deb_machine  => $opt->deb_machine,
+	check_regex        => $opt->check,
+	ignore_regex       => $opt->ignore,
+	ignore_extra_regex => $opt->extra_ignore,
+	recursive          => $opt->recursive,
+	lines              => $opt->lines,
+	tail               => $opt->tail,
+	verbose            => $opt->verbose,
+	skipped            => $opt->skipped,
+	deb_fmt            => $opt->deb_fmt // $opt->deb_machine,
+	deb_machine        => $opt->deb_machine,
 );

 if ( $opt->deb_machine ) {
diff --git a/lib/App/Licensecheck.pm b/lib/App/Licensecheck.pm
index fa85b30..1639477 100755
--- a/lib/App/Licensecheck.pm
+++ b/lib/App/Licensecheck.pm
@@ -138,6 +138,19 @@ has ignore_regex => (
 	default => sub {qr/$default_ignore_regex/x},
 );

+has ignore_extra_regex => (
+	is     => 'rw',
+	lazy   => 1,
+	coerce => sub {
+		my $value = shift;
+		return qr/^$/x
+			if $value eq '<none>';
+		return $value if ref $value eq 'Regexp';
+		return qr/$value/;
+	},
+	default => sub {qr/^$/x},
+);
+
 has recursive => (
 	is => 'rw',
 );
@@ -181,16 +194,18 @@ sub find
 {
 	my ( $self, @paths ) = @_;

-	my $check_re  = $self->check_regex;
-	my $ignore_re = $self->ignore_regex;
-	my $rule      = Path::Iterator::Rule->new;
-	my %options   = (
+	my $check_re   = $self->check_regex;
+	my $ignore_re  = $self->ignore_regex;
+	my $ignore_rex = $self->ignore_extra_regex;
+	my $rule       = Path::Iterator::Rule->new;
+	my %options    = (
 		follow_symlinks => 0,
 	);

 	$rule->max_depth(1)
 		unless $self->recursive;
 	$rule->not( sub {/$ignore_re/} );
+	$rule->not( sub {/$ignore_rex/} );
 	$rule->file->nonempty;

 	if ( @paths >> 1 ) {

#872432#20
Date:
2017-10-06 08:33:54 UTC
From:
To:
not sure whether "git send-email" is the best way to send a patch to the
BTS.

so here it is again, as an attachment

#872432#25
Date:
2017-11-27 17:49:59 UTC
From:
To:
control: tags -1 patch
thanks.

#872432#32
Date:
2020-05-15 15:12:57 UTC
From:
To:
[ resposting with 7bit headers to please Debian MTAs ]

Quoting IOhannes m zmölnig (2017-10-06 10:29:21)

Thanks (and sorry for several years of silence!).

I dislike adding more options for same functionality, and I dislike that
the option --ignore is a regex.  Instead, I consider adding new option
"--usage" to change behaviour and defaults of other options, treating
current behaviours as --usage=legacy.  See bug#960695 for details.

This is current "licensecheck --help":

 -i STR --ignore STR        regular expression of files to skip
                            (default value: some backup and VCS files)


How do you think about this future "licensecheck --help":

 -i STR --ignore STR        files to skip;
                            with usage=legacy a regular expression
                            replacing previous or default value,
                            with any other usage a comma-separated list
                            adding onto previous and default values
                            except an empty value which clears the list
                            (default value: some backup and VCS files)


 - Jonas

#872432#43
Date:
2023-05-12 14:36:53 UTC
From:
To:
Good morning,

 Attached please find your PDF account statement and invoice as of 05/11/2023. Please notice you have a past due balance  for invoice IN0099203.

 Please provide payment as soon as possible.




 Best Regards,
 Shawneen Chisholm
 Accounts Receivable Coordinator

 UNITED RENTALS, INC.
Branch L02 BONNYVILLE
4920 56TH AVE
BONNYVILLE AB T9N 2N8 CA
780-826-7610


 CONFIDENTIALITY NOTICE: The contents of this email message and any attachments are intended solely for the addressee(s). This may contain confidential and/or privileged information and may be legally protected from disclosure. If you are not the intended recipient of this message, please alert the sender immediately by reply email and then delete this message and any attachments. Any disclosure, reproduction, distribution or other use of this message or any attachments by an individual or entity other than the intended recipient is prohibited

#872432#48
Date:
2023-05-12 14:36:31 UTC
From:
To:
Good morning,

 Attached please find your PDF account statement and invoice as of 05/11/2023. Please notice you have a past due balance  for invoice IN0099203.

 Please provide payment as soon as possible.




 Best Regards,
 Shawneen Chisholm
 Accounts Receivable Coordinator

 UNITED RENTALS, INC.
Branch L02 BONNYVILLE
4920 56TH AVE
BONNYVILLE AB T9N 2N8 CA
780-826-7610


 CONFIDENTIALITY NOTICE: The contents of this email message and any attachments are intended solely for the addressee(s). This may contain confidential and/or privileged information and may be legally protected from disclosure. If you are not the intended recipient of this message, please alert the sender immediately by reply email and then delete this message and any attachments. Any disclosure, reproduction, distribution or other use of this message or any attachments by an individual or entity other than the intended recipient is prohibited