]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
no bug - adopt mojolicious code formatting guidelines (#784)
authorDylan William Hardison <dylan@hardison.net>
Tue, 2 Oct 2018 04:24:25 +0000 (00:24 -0400)
committerGitHub <noreply@github.com>
Tue, 2 Oct 2018 04:24:25 +0000 (00:24 -0400)
@kyoshino likes 2-char indent for all the frontend.
Mojolicious seems to use 2-space too.
Let's just adopt their perltidyrc.

Included in this is a script (in scripts/) that will modify files according to these rules.

.editorconfig
.perltidyrc
Makefile.PL
scripts/perl-fmt [new file with mode: 0644]

index 2d527a2504c36fd96478f6752b6ff6933ba9e882..ddd5594945b98b21b3f337b628a1e49ec27e21ce 100644 (file)
@@ -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}]
index 25f9ef6269ede9349def5dc40c27be9a740f3fab..f15324190a0cf2b3e6337a597db2a7b130ee1b16 100644 (file)
@@ -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
index 4aa352468d92499638ed4a8b44745c115066c499..f71b33c754abd59a07b777eb61095aafef62be0e 100755 (executable)
@@ -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 (file)
index 0000000..4b5ea35
--- /dev/null
@@ -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 );