summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.editorconfig6
-rw-r--r--.perltidyrc16
-rwxr-xr-xMakefile.PL1
-rw-r--r--scripts/perl-fmt24
4 files changed, 41 insertions, 6 deletions
diff --git a/.editorconfig b/.editorconfig
index 2d527a250..ddd559494 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -5,10 +5,10 @@ root = true
end_of_line = lf
insert_final_newline = true
-# 4 space indentation for Perl files
-[*.{pl,PL,pm,cgi}]
+# 2 space indentation for Perl files
+[*.{pl,PL,pm,cgi,t}]
indent_style = space
-indent_size = 4
+indent_size = 2
# 2 space indentation for HTML, CSS, JavaScript and YAML files
[.{html,tmpl,css,js,yml}]
diff --git a/.perltidyrc b/.perltidyrc
index 25f9ef626..f15324190 100644
--- a/.perltidyrc
+++ b/.perltidyrc
@@ -1,3 +1,13 @@
---perl-best-practices
---brace-vertical-tightness=0 # always break after {
---maximum-line-length=120 # max line length is 120
+-pbp # Start with Perl Best Practices
+-w # Show all warnings
+-iob # Ignore old breakpoints
+-l=80 # 80 characters per line
+-mbl=2 # No more than 2 blank lines
+-i=2 # Indentation is 2 columns
+-ci=2 # Continuation indentation is 2 columns
+-vt=0 # Less vertical tightness
+-pt=2 # High parenthesis tightness
+-bt=2 # High brace tightness
+-sbt=2 # High square bracket tightness
+-wn # Weld nested containers
+-isbc # Don't indent comments without leading space
diff --git a/Makefile.PL b/Makefile.PL
index 4aa352468..f71b33c75 100755
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -95,6 +95,7 @@ my %test_requires = (
'Capture::Tiny' => 0,
'DBD::SQLite' => '1.29',
'Perl::Critic::Freenode' => 0,
+ 'Perl::Tidy' => '20180220',
'Pod::Coverage' => 0,
'Test::More' => 0,
'Test::Perl::Critic::Progressive' => 0,
diff --git a/scripts/perl-fmt b/scripts/perl-fmt
new file mode 100644
index 000000000..4b5ea3565
--- /dev/null
+++ b/scripts/perl-fmt
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+use 5.10.1;
+use strict;
+use warnings;
+
+use File::Basename qw(dirname);
+use Cwd qw(realpath);
+use File::Spec::Functions qw(catfile catdir);
+use Env qw(@PATH @PERL5LIB);
+
+my $bugzilla_dir = realpath(catdir( dirname(__FILE__), '..' ));
+unshift @PERL5LIB, catdir($bugzilla_dir, 'local', 'lib', 'perl5');
+unshift @PATH, catdir($bugzilla_dir, 'local', 'bin');
+
+my $profile = catfile($bugzilla_dir, ".perltidyrc" );
+warn "formatting @ARGV\n";
+exec( perltidy => "--profile=$profile", '-nst', '-b', '-bext=/', '-conv', @ARGV );