You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by km...@apache.org on 2019/11/24 20:31:12 UTC
svn commit: r1870344 - in /spamassassin:
branches/3.4/lib/Mail/SpamAssassin/PerMsgStatus.pm
trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
Author: kmcgrail
Date: Sun Nov 24 20:31:12 2019
New Revision: 1870344
URL: http://svn.apache.org/viewvc?rev=1870344&view=rev
Log:
More polish on the collapsed subtests work
Modified:
spamassassin/branches/3.4/lib/Mail/SpamAssassin/PerMsgStatus.pm
spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
Modified: spamassassin/branches/3.4/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.4/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=1870344&r1=1870343&r2=1870344&view=diff
==============================================================================
--- spamassassin/branches/3.4/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/branches/3.4/lib/Mail/SpamAssassin/PerMsgStatus.pm Sun Nov 24 20:31:12 2019
@@ -198,7 +198,7 @@ BEGIN {
SUBTESTSCOLLAPSED => sub {
my $pms = shift;
my $arg = (shift || ',');
- my ($total_hits, $deduplicated_hits, @subtests) = $pms->get_array_names_of_subtests_hit("dbg");
+ my (@subtests) = $pms->get_names_of_subtests_hit("collapsed");
join($arg, sort @subtests) || "none";
},
@@ -778,7 +778,10 @@ meta-rule sub-tests which were triggered
normally-hidden rules, which score 0 and have names beginning with two
underscores, used in meta rules.
-If a parameter of dbg is passed, the output will be more condensed and
+If a parameter of collapsed or dbg is passed, the output will be a condensed
+array of sub-tests with multiple hits reduced to one entry.
+
+If the parameter of dbg is passed, the output will be a condensed string of
sub-tests with multiple hits reduced to one entry with the number of hits
in parentheses. Some information is also added at the end regarding the
multiple hits.
@@ -788,35 +791,10 @@ multiple hits.
sub get_names_of_subtests_hit {
my ($self, $mode) = @_;
- if (defined $mode && $mode eq 'dbg') {
- # This routine prints only one instance of a subrule hit with a count of how many times it hit if greater than 1
- my ($total_hits, $deduplicated_hits, @result) = $self->get_array_names_of_subtests_hit($mode);
-
- return join(',', @result)." (Total Subtest Hits: $total_hits / Deduplicated Total Hits: $deduplicated_hits)";
- } else {
- # Return the simpler string with duplicates and commas
- return join(',', sort @{$self->{subtest_names_hit}});
- }
-}
-
-=item $list = $status->get_array_names_of_subtests_hit ()
-
-After a mail message has been checked, this method can be called. It will
-return an array, listing all the symbolic test names of the
-meta-rule sub-tests which were triggered by the mail. Sub-tests are the
-normally-hidden rules, which score 0 and have names beginning with two
-underscores, used in meta rules.
-
-=cut
-
-sub get_array_names_of_subtests_hit {
- my ($self, $mode) = @_;
- my @result;
-
- if (defined $mode && $mode eq 'dbg') {
+ if (defined $mode && ($mode eq 'dbg' || $mode eq 'collapsed')) {
# This routine prints only one instance of a subrule hit with a count of how many times it hit if greater than 1
my $total_hits = scalar(@{$self->{subtest_names_hit}});
- return (0,0,@result) if !$total_hits;
+ return '' if !$total_hits;
my %subtest_names_hit;
$subtest_names_hit{$_}++ foreach @{$self->{subtest_names_hit}};
@@ -824,6 +802,7 @@ sub get_array_names_of_subtests_hit {
my @subtests = sort keys %subtest_names_hit;
my $deduplicated_hits = scalar(@subtests);
+ my @result;
foreach my $rule (@subtests) {
if ($subtest_names_hit{$rule} > 1) {
push @result, "$rule($subtest_names_hit{$rule})";
@@ -832,10 +811,14 @@ sub get_array_names_of_subtests_hit {
}
}
- return ($total_hits, $deduplicated_hits, @result);
+ if ($mode eq 'dbg') {
+ return join(',', @result)." (Total Subtest Hits: $total_hits / Deduplicated Total Hits: $deduplicated_hits)";
+ } else {
+ return join(',', @result);
+ }
} else {
# Return the simpler string with duplicates and commas
- return (scalar(@{$self->{subtest_names_hit}}), scalar(@{$self->{subtest_names_hit}}), @{$self->{subtest_names_hit}});
+ return join(',', sort @{$self->{subtest_names_hit}});
}
}
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=1870344&r1=1870343&r2=1870344&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm Sun Nov 24 20:31:12 2019
@@ -201,7 +201,7 @@ BEGIN {
SUBTESTSCOLLAPSED => sub {
my $pms = shift;
my $arg = (shift || ',');
- my ($total_hits, $deduplicated_hits, @subtests) = $pms->get_array_names_of_subtests_hit("dbg");
+ my (@subtests) = $pms->get_names_of_subtests_hit("collapsed");
join($arg, sort @subtests) || "none";
},
@@ -793,7 +793,10 @@ meta-rule sub-tests which were triggered
normally-hidden rules, which score 0 and have names beginning with two
underscores, used in meta rules.
-If a parameter of dbg is passed, the output will be more condensed and
+If a parameter of collapsed or dbg is passed, the output will be a condensed
+array of sub-tests with multiple hits reduced to one entry.
+
+If the parameter of dbg is passed, the output will be a condensed string of
sub-tests with multiple hits reduced to one entry with the number of hits
in parentheses. Some information is also added at the end regarding the
multiple hits.
@@ -803,35 +806,10 @@ multiple hits.
sub get_names_of_subtests_hit {
my ($self, $mode) = @_;
- if (defined $mode && $mode eq 'dbg') {
- # This routine prints only one instance of a subrule hit with a count of how many times it hit if greater than 1
- my ($total_hits, $deduplicated_hits, @result) = $self->get_array_names_of_subtests_hit($mode);
-
- return join(',', @result)." (Total Subtest Hits: $total_hits / Deduplicated Total Hits: $deduplicated_hits)";
- } else {
- # Return the simpler string with duplicates and commas
- return join(',', sort @{$self->{subtest_names_hit}});
- }
-}
-
-=item $list = $status->get_array_names_of_subtests_hit ()
-
-After a mail message has been checked, this method can be called. It will
-return an array, listing all the symbolic test names of the
-meta-rule sub-tests which were triggered by the mail. Sub-tests are the
-normally-hidden rules, which score 0 and have names beginning with two
-underscores, used in meta rules.
-
-=cut
-
-sub get_array_names_of_subtests_hit {
- my ($self, $mode) = @_;
- my @result;
-
- if (defined $mode && $mode eq 'dbg') {
+ if (defined $mode && ($mode eq 'dbg' || $mode eq 'collapsed')) {
# This routine prints only one instance of a subrule hit with a count of how many times it hit if greater than 1
my $total_hits = scalar(@{$self->{subtest_names_hit}});
- return (0,0,@result) if !$total_hits;
+ return '' if !$total_hits;
my %subtest_names_hit;
$subtest_names_hit{$_}++ foreach @{$self->{subtest_names_hit}};
@@ -839,6 +817,7 @@ sub get_array_names_of_subtests_hit {
my @subtests = sort keys %subtest_names_hit;
my $deduplicated_hits = scalar(@subtests);
+ my @result;
foreach my $rule (@subtests) {
if ($subtest_names_hit{$rule} > 1) {
push @result, "$rule($subtest_names_hit{$rule})";
@@ -847,10 +826,14 @@ sub get_array_names_of_subtests_hit {
}
}
- return ($total_hits, $deduplicated_hits, @result);
+ if ($mode eq 'dbg') {
+ return join(',', @result)." (Total Subtest Hits: $total_hits / Deduplicated Total Hits: $deduplicated_hits)";
+ } else {
+ return join(',', @result);
+ }
} else {
# Return the simpler string with duplicates and commas
- return (scalar(@{$self->{subtest_names_hit}}), scalar(@{$self->{subtest_names_hit}}), @{$self->{subtest_names_hit}});
+ return join(',', sort @{$self->{subtest_names_hit}});
}
}