Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy up all files #353

Merged
merged 2 commits into from Jun 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -66,3 +66,6 @@ Makefile

/.includepath
/.project

# Vim tmp file
*.swp
34 changes: 17 additions & 17 deletions src/lib/Conf.pm
Expand Up @@ -257,7 +257,7 @@ sub load {
'force_reload' => $force_reload
}
)
) {
) {
return undef;
}
##_create_robot_like_config_for_main_robot();
Expand Down Expand Up @@ -290,7 +290,7 @@ sub load_robots {
'force_reload' => $param->{'force_reload'}
}
)
) {
) {
$log->syslog(
'err',
'The config for robot %s contain errors: it could not be correctly loaded',
Expand Down Expand Up @@ -438,7 +438,7 @@ sub get_db_conf {
WHERE robot_conf = ? AND label_conf = ?},
$robot, $label
)
) {
) {
$log->syslog(
'err',
'Unable retrieve value of parameter %s for robot %s from the database',
Expand Down Expand Up @@ -480,7 +480,7 @@ sub set_robot_conf {
WHERE robot_conf = ? AND label_conf = ?},
$robot, $label
)
) {
) {
$log->syslog(
'err',
'Unable to check presence of parameter %s for robot %s in database',
Expand All @@ -501,7 +501,7 @@ sub set_robot_conf {
VALUES (?, ?, ?)},
$robot, $label, $value
)
) {
) {
$log->syslog(
'err',
'Unable add value %s for parameter %s in the robot %s DB conf',
Expand All @@ -520,7 +520,7 @@ sub set_robot_conf {
$robot, $label, $value,
$robot, $label
)
) {
) {
$log->syslog(
'err',
'Unable set parameter %s value to %s in the robot %s DB conf',
Expand Down Expand Up @@ -562,7 +562,7 @@ sub conf_2_db {
. '/robot.conf'
}
)
) {
) {
$config = $result_of_config_loading->{'config'};
}
_remove_unvalid_robot_entry($config);
Expand All @@ -573,7 +573,7 @@ sub conf_2_db {
if (($conf_parameters[$i]->{'vhost'} eq '1')
&& #skip parameters that can't be define by robot so not to be loaded in db at that stage
($config->{$conf_parameters[$i]->{'name'}})
) {
) {
Conf::set_robot_conf(
$robot,
$conf_parameters[$i]->{'name'},
Expand Down Expand Up @@ -642,7 +642,7 @@ sub checkfiles_as_root {
group => Sympa::Constants::GROUP,
mode => 0644,
)
) {
) {
$log->syslog('err', 'Unable to set rights on %s',
$Conf{'db_name'});
return undef;
Expand All @@ -666,7 +666,7 @@ sub checkfiles_as_root {
user => Sympa::Constants::USER,
group => Sympa::Constants::GROUP,
)
) {
) {
$log->syslog('err', 'Unable to set rights on %s',
$Conf{'db_name'});
return undef;
Expand Down Expand Up @@ -781,7 +781,7 @@ sub checkfiles {
user => Sympa::Constants::USER,
group => Sympa::Constants::GROUP,
)
) {
) {
$log->syslog('err', 'Unable to set rights on %s',
$Conf{$qdir});
$config_err++;
Expand Down Expand Up @@ -1060,7 +1060,7 @@ sub _load_auth {
}
unless ($value =~
/^$valid_keywords{$current_paragraph->{'auth_type'}}{$keyword}$/
) {
) {
$log->syslog('err',
'Unknown format "%s" for keyword "%s" in %s line %d',
$value, $keyword, $config_file, $line_num);
Expand Down Expand Up @@ -1263,7 +1263,7 @@ sub lang2charset {
my $locale2charset;
if ($lang and %Conf::Conf # configuration loaded
and $locale2charset = $Conf::Conf{'locale2charset'}
) {
) {
foreach my $l (Sympa::Language::implicated_langs($lang)) {
if (exists $locale2charset->{$l}) {
return $locale2charset->{$l};
Expand Down Expand Up @@ -1323,7 +1323,7 @@ sub load_sql_filter {
'db_user' => {'format' => '.*', 'occurrence' => '0-1',},
'db_passwd' => {'format' => '.*', 'occurrence' => '0-1',},
'db_options' => {'format' => '.*', 'occurrence' => '0-1',},
'db_env' => {'format' => '.*', 'occurrence' => '0-1',},
'db_env' => {'format' => '.*', 'occurrence' => '0-1',},
'db_port' => {'format' => '\d+', 'occurrence' => '0-1',},
'db_timeout' => {'format' => '\d+', 'occurrence' => '0-1',},
}
Expand Down Expand Up @@ -1591,7 +1591,7 @@ sub load_generic_conf_file {

unless ($paragraph[$i] =~
/^\s*$key\s+($structure{$pname}{'format'}{$key}{'format'})\s*$/i
) {
) {
$log->syslog('notice',
'Bad entry "%s" in paragraph "%s" in %s',
$paragraph[$i], $key, $pname, $config_file);
Expand Down Expand Up @@ -1843,7 +1843,7 @@ sub _infer_server_specific_parameter_values {
Sympa::Tools::Data::smart_eq(
$param->{'config_hash'}{'dkim_feature'}, 'on'
)
) {
) {
# dkim_signature_apply_ on nothing if dkim_feature is off
# Sets empty array.
$param->{'config_hash'}{'dkim_signature_apply_on'} = [''];
Expand Down Expand Up @@ -1884,7 +1884,7 @@ sub _infer_server_specific_parameter_values {
foreach my $parameter (
'rfc2369_header_fields', 'anonymous_header_fields',
'remove_headers', 'remove_outgoing_headers'
) {
) {
if ($param->{'config_hash'}{$parameter} eq 'none') {
delete $param->{'config_hash'}{$parameter};
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Sympa/Aliases/CheckSMTP.pm
Expand Up @@ -71,7 +71,7 @@ sub check {
Hello => $smtp_helo,
Timeout => 30
)
) {
) {
$smtp->mail('');
my $conf = 0;
foreach my $address (@addresses) {
Expand Down
8 changes: 4 additions & 4 deletions src/lib/Sympa/Aliases/Template.pm
Expand Up @@ -62,8 +62,8 @@ sub _aliases {
Conf::get_robot_conf($domain, 'return_path_suffix'),

# No longer used by default.
'robot' => $domain,
'default_domain' => $Conf::Conf{'domain'},
'robot' => $domain,
'default_domain' => $Conf::Conf{'domain'},
};

my $aliases_dump;
Expand Down Expand Up @@ -91,7 +91,7 @@ sub add {

return 0
if lc Conf::get_robot_conf($list->{'domain'}, 'sendmail_aliases') eq
'none';
'none';

# Create a lock
my $lock_fh;
Expand Down Expand Up @@ -160,7 +160,7 @@ sub del {

return 0
if lc Conf::get_robot_conf($list->{'domain'}, 'sendmail_aliases') eq
'none';
'none';

# Create a lock
my $lock_fh;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Sympa/Archive.pm
Expand Up @@ -87,7 +87,7 @@ sub _create_spool {
user => Sympa::Constants::USER(),
group => Sympa::Constants::GROUP()
)
) {
) {
die sprintf 'Cannot create %s: %s', $directory, $ERRNO;
}
}
Expand Down Expand Up @@ -767,7 +767,7 @@ sub _clean_archive_directory {
$answer->{'dir_to_rebuild'},
$answer->{'cleaned_dir'}
)
) {
) {
$log->syslog(
'err',
'Unable to create a temporary directory where to store files for HTML escaping (%s). Cancelling',
Expand Down
6 changes: 3 additions & 3 deletions src/lib/Sympa/Bulk.pm
Expand Up @@ -69,7 +69,7 @@ sub _create_spool {
$Conf::Conf{queuebulk}, $self->{msg_directory},
$self->{pct_directory}, $self->{bad_directory},
$self->{bad_msg_directory}, $self->{bad_pct_directory}
) {
) {
unless (-d $directory) {
$log->syslog('info', 'Creating spool %s', $directory);
unless (
Expand All @@ -79,7 +79,7 @@ sub _create_spool {
user => Sympa::Constants::USER(),
group => Sympa::Constants::GROUP()
)
) {
) {
die sprintf 'Cannot create %s: %s', $directory, $ERRNO;
}
}
Expand Down Expand Up @@ -361,7 +361,7 @@ sub _get_recipient_tabs_by_domain {
or
# number of recipients in general
(@sendto and $nrcpt >= Conf::get_robot_conf($robot_id, 'nrcpt'))
) {
) {
undef %rcpt_by_dom;
# do not replace this line by "push @sendtobypacket, \@sendto" !!!
my @tab = @sendto;
Expand Down
21 changes: 11 additions & 10 deletions src/lib/Sympa/ConfDef.pm
Expand Up @@ -569,16 +569,17 @@ our @params = (
'edit' => '1',
'gettext_comment' =>
'Restrict list ownership to addresses in the specified domains. This can be used to reserve list ownership to a group of trusted users from a set of domains associated with an organization, while allowing editors and subscribers from the Internet at large.',
'default' => undef,
'default' => undef,
},
{ 'name' => 'owner_domain_min',
'sample' => '1',
'gettext_id' => 'Minimum number of owners for each list that must match owner_domain restriction',
'file' => 'sympa.conf',
'default' => '0',
'optional' => '1',
'vhost' => '1',
'edit' => '1',
{ 'name' => 'owner_domain_min',
'sample' => '1',
'gettext_id' =>
'Minimum number of owners for each list that must match owner_domain restriction',
'file' => 'sympa.conf',
'default' => '0',
'optional' => '1',
'vhost' => '1',
'edit' => '1',
'gettext_comment' =>
'Minimum number of owners for each list must satisfy the owner_domain restriction. The default of zero (0) means *all* list owners must match. Setting to 1 requires only one list owner to match owner_domain; all other owners can be from any domain. This setting can be used to ensure that there is always at least one known contact point for any mailing list.',
},
Expand Down Expand Up @@ -2061,7 +2062,7 @@ our @params = (
'file' => 'sympa.conf',
'default' => '300',
},
{ 'name' => 'voot_feature', # Not implemented yet.
{ 'name' => 'voot_feature', # Not implemented yet.
'default' => 'off',
'file' => 'sympa.conf',
},
Expand Down
14 changes: 7 additions & 7 deletions src/lib/Sympa/Config.pm
Expand Up @@ -91,7 +91,7 @@ sub _init_schema_item {
my %options = @_;

return undef
unless ref $pitem->{format} ne 'HASH' and exists $pitem->{default};
unless ref $pitem->{format} ne 'HASH' and exists $pitem->{default};

my $default = $pitem->{default};

Expand Down Expand Up @@ -670,13 +670,11 @@ sub _validate_changes {
# review the entire new configuration as a whole
foreach my $validation (CORE::keys %global_validations) {
next unless ref $global_validations{$validation} eq 'CODE';
my ($error, $err_info) = $global_validations{$validation}->($self, $new);
my ($error, $err_info) =
$global_validations{$validation}->($self, $new);
next unless $error;

push @$errors,
[
'user', $error, $err_info
];
push @$errors, ['user', $error, $err_info];
$ret = 'invalid';
}
return '' unless %$new;
Expand Down Expand Up @@ -965,7 +963,9 @@ sub _merge_changes_paragraph {

sub get_id {
my $that = shift->{context};
(ref $that eq 'Sympa::List') ? $that->get_id : (defined $that) ? $that : '';
(ref $that eq 'Sympa::List') ? $that->get_id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird indentation (I tried perltidy-ing again, but this was not fixed). Bug (or feature) of Perl::Tidy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, IMHO, that's not the weirdest indentation that Perl::Tidy asked for. I'm not a big fan of src/lib/Sympa/Database.pm L.77 for ex.

Also, I can't find it anymore (too much changed files), but I remember there's an if that have its closing ) { not on the same level of indentation and that was weird since Perl::Tidy made me change a lot of closing ) { indentation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. How weird perltidy does, it does its best.

: (defined $that) ? $that
: '';
}

1;
Expand Down
8 changes: 4 additions & 4 deletions src/lib/Sympa/Database.pm
Expand Up @@ -73,9 +73,8 @@ sub new {
(exists $params{$_} and defined $params{$_})
? ($_ => $params{$_})
: ()
} (
@{$driver->required_parameters}, @{$driver->optional_parameters}
)
} ( @{$driver->required_parameters}, @{$driver->optional_parameters}
)
);
}

Expand Down Expand Up @@ -155,7 +154,8 @@ sub connect {

unless ($self->ping) {
unless ($persistent_connection_of{$self->{_id}}) {
$log->syslog('err', 'Can\'t connect to Database %s: %s', $self, $DBI::errstr);
$log->syslog('err', 'Can\'t connect to Database %s: %s',
$self, $DBI::errstr);
$self->{_status} = 'failed';
return undef;
}
Expand Down