All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Brian Gernhardt <brian@gernhardtsoftware.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH v2 1/3] send-email: Don't use FQDNs without a '.'
Date: Fri, 9 Apr 2010 18:31:48 +0200	[thread overview]
Message-ID: <201004091831.49066.jnareb@gmail.com> (raw)
In-Reply-To: <1270827746-29229-1-git-send-email-brian@gernhardtsoftware.com>

On Fri, 9 Apr 2010, Brian Gernhardt wrote:
 
> Since the same condition is used twice and getting complex, let's move
> it to a new function.

Good idea.


Note that the comments below are just nitpicking about Perl style.
 
> @@ -863,14 +863,19 @@ sub sanitize_address
>  # This maildomain*() code is based on ideas in Perl library Test::Reporter
>  # /usr/share/perl5/Test/Reporter/Mail/Util.pm ==> sub _maildomain ()
>  
> +sub valid_fqdn
> +{
> +	my $domain = $_[0];
> +	return !($^O eq 'darwin' && $domain =~ /\.local$/) && $domain =~ /\./;
> +}

A matter of style: in Perl it more usual to use

  sub <name> {
  	...
  }

style rather than

  sub <name>
  {
  	...
  }

Unfortunately git-send-email.perl is a bit inconsistent in the style used;
23 subroutines use Perl style, 5 subroutines including previous one i.e.
sanitize_address use C-like style (one of).


Also, the usual way of unrolling @_; is to use either

  my ($par1, $par2, ...) = @_;

or use

  mu $par = shift;

The form $_[0] etc. is used very rarely.  I think it is even against 
Perl Best Practices (see http://www.perlcritic.org and Perl::Critic).


So in my opinion this fragment should be:

+sub valid_fqdn {
+	my $domain = shift;
+	return !($^O eq 'darwin' && $domain =~ /\.local$/) && $domain =~ /\./;
+}


> +
>  sub maildomain_net
>  {
>  	my $maildomain;
>  
>  	if (eval { require Net::Domain; 1 }) {
>  		my $domain = Net::Domain::domainname();
> -		$maildomain = $domain
> -			unless $^O eq 'darwin' && $domain =~ /\.local$/;
> +		$maildomain = $domain if valid_fqdn( $domain );
>  	}
>  
>  	return $maildomain;
> @@ -887,8 +892,7 @@ sub maildomain_mta
>  				my $domain = $smtp->domain;
>  				$smtp->quit;
>  
> -				$maildomain = $domain
> -					unless $^O eq 'darwin' && $domain =~ /\.local$/;
> +				$maildomain = $domain if valid_fqdn( $domain );
>  
>  				last if $maildomain;
>  			}

Style: usually there is no space around function arguments, so 
'valid_fqdn($domain);'.

-- 
Jakub Narebski
Poland

  reply	other threads:[~2010-04-09 16:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-09 15:34 [PATCH v2 0/3] *** SUBJECT HERE *** Brian Gernhardt
2010-04-09 15:34 ` [PATCH] Makefile: Simplify handling of python scripts Brian Gernhardt
2010-04-09 15:39   ` Sverre Rabbelier
2010-04-09 15:57     ` [PATCH v2] " Brian Gernhardt
2010-04-09 16:05       ` Sverre Rabbelier
2010-04-09 15:34 ` [PATCH v2 2/3] Document send-email --smtp-domain Brian Gernhardt
2010-04-09 15:34 ` [PATCH v2 3/3] send-email: Add sendemail.smtpdomain Brian Gernhardt
2010-04-09 18:40   ` Jakub Narebski
2010-04-10 13:51     ` Brian Gernhardt
2010-04-09 15:42 ` [PATCH v2 1/3] send-email: Don't use FQDNs without a '.' Brian Gernhardt
2010-04-09 16:31   ` Jakub Narebski [this message]
2010-04-10 13:44     ` Brian Gernhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201004091831.49066.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=brian@gernhardtsoftware.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.