Skip to content

Commit

Permalink
Remove dependency on Email::Address.
Browse files Browse the repository at this point in the history
  • Loading branch information
petdance committed May 20, 2018
1 parent 3798661 commit 9f3457c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 13 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ NEXT
positives on _build_xxxx() subroutines.
Thanks, Dave Cross. (GH #811, #812)

[Dependencies]
Perl::Critic now no longer relies on the deprecated Email::Address.

1.131_02 Tue Feb 20 17:18:03 CST 2018
[New Features]
Perl::Critic now assumes that .psgi files are Perl, too. Thanks, Tom
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ You are free to invent new themes that suit your needs.
certrule Policies that CERT considers rules
maintenance Policies that affect the long-term health of the code
cosmetic Policies that only have a superficial effect
complexity Policies that specificaly relate to code complexity
complexity Policies that specifically relate to code complexity
security Policies that relate to security issues
tests Policies that are specific to test programs

Expand Down Expand Up @@ -585,8 +585,6 @@ Perl::Critic requires the following modules:

[Config::Tiny](https://metacpan.org/pod/Config::Tiny)

[Email::Address](https://metacpan.org/pod/Email::Address)

[Exception::Class](https://metacpan.org/pod/Exception::Class)

[File::HomeDir](https://metacpan.org/pod/File::HomeDir)
Expand Down Expand Up @@ -700,7 +698,7 @@ Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>

# COPYRIGHT

Copyright (c) 2005-2013 Imaginative Software Systems. All rights reserved.
Copyright (c) 2005-2018 Imaginative Software Systems. All rights reserved.

This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself. The full text of this license can be found in
Expand Down
1 change: 0 additions & 1 deletion inc/Perl/Critic/BuildUtilities.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ sub required_module_versions {
'B::Keywords' => 1.05,
'Carp' => 0,
'Config::Tiny' => 2,
'Email::Address' => 1.889,
'English' => 0,
'Exception::Class' => 1.23,
'Exporter' => 5.63,
Expand Down
2 changes: 0 additions & 2 deletions lib/Perl/Critic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,6 @@ L<B::Keywords>
L<Config::Tiny>
L<Email::Address>
L<Exception::Class>
L<File::HomeDir>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use warnings;

use Readonly;

use Email::Address;

use Perl::Critic::Utils qw< :booleans :characters :severities >;
use base 'Perl::Critic::Policy';

Expand Down Expand Up @@ -93,14 +91,45 @@ sub _needs_interpolation {

#-----------------------------------------------------------------------------

# Stolen from Email::Address, which is deprecated. Since we are not modifying
# the original code at all, we are less stringent in being Critic-compliant.

## no critic ( RegularExpressions::RequireDotMatchAnything )
## no critic ( RegularExpressions::RequireExtendedFormatting )
## no critic ( RegularExpressions::RequireLineBoundaryMatching )
## no critic ( RegularExpressions::ProhibitEscapedMetacharacters )

my $CTL = q{\x00-\x1F\x7F}; ## no critic ( ValuesAndExpressions::RequireInterpolationOfMetachars )
my $special = q{()<>\\[\\]:;@\\\\,."}; ## no critic ( ValuesAndExpressions::RequireInterpolationOfMetachars )

my $text = qr/[^\x0A\x0D]/x;
my $quoted_pair = qr/\\$text/x;
my $ctext = qr/(?>[^()\\]+)/x;
my $ccontent = qr/$ctext|$quoted_pair/x;
my $comment = qr/\s*\((?:\s*$ccontent)*\s*\)\s*/x;
my $cfws = qr/$comment|\s+/xx;
my $atext = qq/[^$CTL$special\\s]/;
my $atom = qr/$cfws*$atext+$cfws*/x;
my $dot_atom_text = qr/$atext+(?:\.$atext+)*/x;
my $dot_atom = qr/$cfws*$dot_atom_text$cfws*/x;
my $qtext = qr/[^\\"]/x;
my $qcontent = qr/$qtext|$quoted_pair/x;
my $quoted_string = qr/$cfws*"$qcontent*"$cfws*/x;
my $local_part = qr/$dot_atom|$quoted_string/x;
my $dtext = qr/[^\[\]\\]/x;
my $dcontent = qr/$dtext|$quoted_pair/x;
my $domain_literal = qr/$cfws*\[(?:\s*$dcontent)*\s*\]$cfws*/x;
my $domain = qr/$dot_atom|$domain_literal/x;
my $addr_spec = qr/$local_part\@$domain/x;

sub _looks_like_email_address {
my ($string) = @_;

return if index ($string, q<@>) < 0;
return if $string =~ m< \W \@ >xms;
return if $string =~ m< \A \@ \w+ \b >xms;

return $string =~ $Email::Address::addr_spec;
return $string =~ $addr_spec;
}

#-----------------------------------------------------------------------------
Expand Down
3 changes: 0 additions & 3 deletions xt/40_perlcriticrc-code
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,3 @@ allow = _get_behavior_values _get_description_with_trailing_period

[Subroutines::ProtectPrivateSubs]
private_name_regex = _(?!_)\w+

[Variables::ProhibitPackageVars]
add_packages = Email::Address

0 comments on commit 9f3457c

Please sign in to comment.