Commit b929c225 authored by jake%acutex.net's avatar jake%acutex.net

Fix for bug 105365 - Hacker's Guide should be in SGML. This will make it easier…

Fix for bug 105365 - Hacker's Guide should be in SGML. This will make it easier to do other additions to the hacker's guide.
parent 271837ff
...@@ -847,6 +847,20 @@ HREF="#QUICKSEARCH" ...@@ -847,6 +847,20 @@ HREF="#QUICKSEARCH"
HREF="#BZHACKING" HREF="#BZHACKING"
>Hacking Bugzilla</A >Hacking Bugzilla</A
></DT ></DT
><DD
><DL
><DT
>D.5.1. <A
HREF="#AEN2495"
>Things that have caused problems and should be avoided</A
></DT
><DT
>D.5.2. <A
HREF="#AEN2509"
>Coding Style for Bugzilla</A
></DT
></DL
></DD
></DL ></DL
></DD ></DD
><DT ><DT
...@@ -1006,7 +1020,7 @@ HREF="#AEN2439" ...@@ -1006,7 +1020,7 @@ HREF="#AEN2439"
></DT ></DT
><DT ><DT
>1. <A >1. <A
HREF="#AEN2685" HREF="#AEN2736"
>A Sample Product</A >A Sample Product</A
></DT ></DT
></DL ></DL
...@@ -15987,101 +16001,285 @@ NAME="BZHACKING" ...@@ -15987,101 +16001,285 @@ NAME="BZHACKING"
>D.5. Hacking Bugzilla</A >D.5. Hacking Bugzilla</A
></H1 ></H1
><P ><P
> What follows are some general guidelines for changing Bugzilla, and adhering to good coding practice while doing so. We've had some checkins in the past which ruined Bugzilla installations because of disregard for these conventions. Sorry for the lack of formatting; I got this info into the Guide on the day of 2.14 release and haven't formatted it yet. > The following is a guide for reviewers when checking code into Bugzilla's
CVS repostory at mozilla.org. If you wish to submit patches to Bugzilla,
you should follow the rules and style conventions below. Any code that
does not adhere to these basic rules will not be added to Bugzilla's
codebase.
</P </P
><DIV
CLASS="SECTION"
><HR><H2
CLASS="SECTION"
><A
NAME="AEN2495"
>D.5.1. Things that have caused problems and should be avoided</A
></H2
><P ><P
CLASS="LITERALLAYOUT" ></P
><br> ><OL
The&nbsp;following&nbsp;is&nbsp;a&nbsp;guide&nbsp;for&nbsp;reviewers&nbsp;when&nbsp;checking&nbsp;code&nbsp;into&nbsp;Bugzilla's<br> TYPE="1"
CVS&nbsp;repostory&nbsp;at&nbsp;mozilla.org.&nbsp;&nbsp;If&nbsp;you&nbsp;wish&nbsp;to&nbsp;submit&nbsp;patches&nbsp;to&nbsp;Bugzilla,<br> ><LI
you&nbsp;should&nbsp;follow&nbsp;the&nbsp;rules&nbsp;and&nbsp;style&nbsp;conventions&nbsp;below.&nbsp;&nbsp;Any&nbsp;code&nbsp;that<br> ><P
does&nbsp;not&nbsp;adhere&nbsp;to&nbsp;these&nbsp;basic&nbsp;rules&nbsp;will&nbsp;not&nbsp;be&nbsp;added&nbsp;to&nbsp;Bugzilla's<br> > Usage of variables in Regular Expressions
codebase.<br> </P
<br> ><P
&nbsp;1.&nbsp;Usage&nbsp;of&nbsp;variables&nbsp;in&nbsp;Regular&nbsp;Expressions<br> > It is very important that you don't use a variable in a regular
<br> expression unless that variable is supposed to contain an expression.
&nbsp;&nbsp;&nbsp;&nbsp;It&nbsp;is&nbsp;very&nbsp;important&nbsp;that&nbsp;you&nbsp;don't&nbsp;use&nbsp;a&nbsp;variable&nbsp;in&nbsp;a&nbsp;regular<br> This especially applies when using grep. You should use:
&nbsp;&nbsp;&nbsp;&nbsp;expression&nbsp;unless&nbsp;that&nbsp;variable&nbsp;is&nbsp;supposed&nbsp;to&nbsp;contain&nbsp;an&nbsp;expression.<br> </P
&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;especially&nbsp;applies&nbsp;when&nbsp;using&nbsp;grep.&nbsp;&nbsp;You&nbsp;should&nbsp;use:<br> ><P
<br> > <TABLE
&nbsp;&nbsp;&nbsp;&nbsp;grep&nbsp;($_&nbsp;eq&nbsp;$value,&nbsp;@array);<br> BORDER="0"
<br> BGCOLOR="#E0E0E0"
&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;NOT&nbsp;-<br> WIDTH="90%"
<br> ><TR
&nbsp;&nbsp;&nbsp;&nbsp;grep&nbsp;(/$value/,&nbsp;@array);<br> ><TD
<br> ><FONT
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;you&nbsp;need&nbsp;to&nbsp;use&nbsp;a&nbsp;non-expression&nbsp;variable&nbsp;inside&nbsp;of&nbsp;an&nbsp;expression,&nbsp;be<br> COLOR="#000000"
&nbsp;&nbsp;&nbsp;&nbsp;sure&nbsp;to&nbsp;quote&nbsp;it&nbsp;properly&nbsp;(using&nbsp;\Q..\E).<br> ><PRE
<br> CLASS="PROGRAMLISTING"
Coding&nbsp;Style&nbsp;for&nbsp;Bugzilla<br> >grep ($_ eq $value, @array);
-------------------------<br> </PRE
<br> ></FONT
While&nbsp;it's&nbsp;true&nbsp;that&nbsp;not&nbsp;all&nbsp;of&nbsp;the&nbsp;code&nbsp;currently&nbsp;in&nbsp;Bugzilla&nbsp;adheres&nbsp;to<br> ></TD
this&nbsp;styleguide,&nbsp;it&nbsp;is&nbsp;something&nbsp;that&nbsp;is&nbsp;being&nbsp;worked&nbsp;toward.&nbsp;&nbsp;Therefore,<br> ></TR
we&nbsp;ask&nbsp;that&nbsp;all&nbsp;new&nbsp;code&nbsp;(submitted&nbsp;patches&nbsp;and&nbsp;new&nbsp;files)&nbsp;follow&nbsp;this&nbsp;guide<br> ></TABLE
as&nbsp;closely&nbsp;as&nbsp;possible&nbsp;(if&nbsp;you're&nbsp;only&nbsp;changing&nbsp;1&nbsp;or&nbsp;2&nbsp;lines,&nbsp;you&nbsp;don't&nbsp;have<br> >
to&nbsp;reformat&nbsp;the&nbsp;entire&nbsp;file&nbsp;:).<br> </P
<br> ><P
&nbsp;1.&nbsp;Whitespace<br> > -- NOT THIS --
<br> </P
&nbsp;&nbsp;&nbsp;&nbsp;Bugzilla's&nbsp;prefered&nbsp;indentation&nbsp;is&nbsp;4&nbsp;spaces&nbsp;(no&nbsp;tabs,&nbsp;please).<br> ><P
<br> > <TABLE
&nbsp;2.&nbsp;Curly&nbsp;braces.<br> BORDER="0"
<br> BGCOLOR="#E0E0E0"
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;opening&nbsp;brace&nbsp;of&nbsp;a&nbsp;block&nbsp;should&nbsp;be&nbsp;on&nbsp;the&nbsp;same&nbsp;line&nbsp;as&nbsp;the&nbsp;statement<br> WIDTH="90%"
&nbsp;&nbsp;&nbsp;&nbsp;that&nbsp;is&nbsp;causing&nbsp;the&nbsp;block&nbsp;and&nbsp;the&nbsp;closing&nbsp;brace&nbsp;should&nbsp;be&nbsp;at&nbsp;the&nbsp;same<br> ><TR
&nbsp;&nbsp;&nbsp;&nbsp;indentation&nbsp;level&nbsp;as&nbsp;that&nbsp;statement,&nbsp;for&nbsp;example:<br> ><TD
<br> ><FONT
&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($var)&nbsp;{<br> COLOR="#000000"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;"The&nbsp;variable&nbsp;is&nbsp;true";<br> ><PRE
&nbsp;&nbsp;&nbsp;&nbsp;}<br> CLASS="PROGRAMLISTING"
&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;{<br> >grep (/$value/, @array);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;"Try&nbsp;again";<br> </PRE
&nbsp;&nbsp;&nbsp;&nbsp;}<br> ></FONT
<br> ></TD
&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;NOT&nbsp;-<br> ></TR
<br> ></TABLE
&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($var)<br> >
&nbsp;&nbsp;&nbsp;&nbsp;{<br> </P
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;"The&nbsp;variable&nbsp;is&nbsp;true";<br> ><DIV
&nbsp;&nbsp;&nbsp;&nbsp;}<br> CLASS="NOTE"
&nbsp;&nbsp;&nbsp;&nbsp;else<br> ><P
&nbsp;&nbsp;&nbsp;&nbsp;{<br> ></P
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;"Try&nbsp;again";<br> ><TABLE
&nbsp;&nbsp;&nbsp;&nbsp;}<br> CLASS="NOTE"
<br> WIDTH="90%"
&nbsp;3.&nbsp;File&nbsp;Names<br> BORDER="0"
<br> ><TR
&nbsp;&nbsp;&nbsp;&nbsp;File&nbsp;names&nbsp;for&nbsp;bugzilla&nbsp;code&nbsp;and&nbsp;support&nbsp;documention&nbsp;should&nbsp;be&nbsp;legal&nbsp;across<br> ><TD
&nbsp;&nbsp;&nbsp;&nbsp;multiple&nbsp;platforms.&nbsp;&nbsp;\&nbsp;/&nbsp;:&nbsp;*&nbsp;?&nbsp;"&nbsp;&#60;&nbsp;&#62;&nbsp;and&nbsp;|&nbsp;are&nbsp;all&nbsp;illegal&nbsp;characters&nbsp;for<br> WIDTH="25"
&nbsp;&nbsp;&nbsp;&nbsp;filenames&nbsp;on&nbsp;various&nbsp;platforms.&nbsp;&nbsp;Also,&nbsp;file&nbsp;names&nbsp;should&nbsp;not&nbsp;have&nbsp;spaces&nbsp;in<br> ALIGN="CENTER"
&nbsp;&nbsp;&nbsp;&nbsp;them&nbsp;as&nbsp;they&nbsp;can&nbsp;cause&nbsp;confusion&nbsp;in&nbsp;CVS&nbsp;and&nbsp;other&nbsp;mozilla.org&nbsp;utilities.<br> VALIGN="TOP"
<br> ><IMG
&nbsp;4.&nbsp;Variable&nbsp;Names<br> SRC="../images/note.gif"
<br> HSPACE="5"
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;a&nbsp;variable&nbsp;is&nbsp;scoped&nbsp;globally&nbsp;($::variable)&nbsp;its&nbsp;name&nbsp;should&nbsp;be&nbsp;descriptive<br> ALT="Note"></TD
&nbsp;&nbsp;&nbsp;&nbsp;of&nbsp;what&nbsp;it&nbsp;contains.&nbsp;&nbsp;Local&nbsp;variables&nbsp;can&nbsp;be&nbsp;named&nbsp;a&nbsp;bit&nbsp;looser,&nbsp;provided&nbsp;the<br> ><TD
&nbsp;&nbsp;&nbsp;&nbsp;context&nbsp;makes&nbsp;their&nbsp;content&nbsp;obvious.&nbsp;&nbsp;For&nbsp;example,&nbsp;$ret&nbsp;could&nbsp;be&nbsp;used&nbsp;as&nbsp;a<br> ALIGN="LEFT"
&nbsp;&nbsp;&nbsp;&nbsp;staging&nbsp;variable&nbsp;for&nbsp;a&nbsp;routine's&nbsp;return&nbsp;value&nbsp;as&nbsp;the&nbsp;line&nbsp;|return&nbsp;$ret;|&nbsp;will<br> VALIGN="TOP"
&nbsp;&nbsp;&nbsp;&nbsp;make&nbsp;it&nbsp;blatently&nbsp;obvious&nbsp;what&nbsp;the&nbsp;variable&nbsp;holds&nbsp;and&nbsp;most&nbsp;likely&nbsp;be&nbsp;shown<br> ><P
&nbsp;&nbsp;&nbsp;&nbsp;on&nbsp;the&nbsp;same&nbsp;screen&nbsp;as&nbsp;|my&nbsp;$ret&nbsp;=&nbsp;"";|.<br> > If you need to use a non-expression variable inside of an expression, be
<br> sure to quote it properly (using <TT
&nbsp;5.&nbsp;Cross&nbsp;Database&nbsp;Compatability<br> CLASS="FUNCTION"
<br> >\Q..\E</TT
&nbsp;&nbsp;&nbsp;&nbsp;Bugzilla&nbsp;was&nbsp;originally&nbsp;written&nbsp;to&nbsp;work&nbsp;with&nbsp;MySQL&nbsp;and&nbsp;therefore&nbsp;took&nbsp;advantage<br> >).
&nbsp;&nbsp;&nbsp;&nbsp;of&nbsp;some&nbsp;of&nbsp;its&nbsp;features&nbsp;that&nbsp;aren't&nbsp;contained&nbsp;in&nbsp;other&nbsp;RDBMS&nbsp;software.&nbsp;&nbsp;These<br> </P
&nbsp;&nbsp;&nbsp;&nbsp;should&nbsp;be&nbsp;avoided&nbsp;in&nbsp;all&nbsp;new&nbsp;code.&nbsp;&nbsp;Examples&nbsp;of&nbsp;these&nbsp;features&nbsp;are&nbsp;enums&nbsp;and<br> ></TD
&nbsp;&nbsp;&nbsp;&nbsp;encrypt().<br> ></TR
<br> ></TABLE
&nbsp;6.&nbsp;Cross&nbsp;Platform&nbsp;Compatability<br> ></DIV
<br> ></LI
&nbsp;&nbsp;&nbsp;&nbsp;While&nbsp;Bugzilla&nbsp;was&nbsp;written&nbsp;to&nbsp;be&nbsp;used&nbsp;on&nbsp;Unix&nbsp;based&nbsp;systems&nbsp;(and&nbsp;Unix/Linux&nbsp;is<br> ></OL
&nbsp;&nbsp;&nbsp;&nbsp;still&nbsp;the&nbsp;only&nbsp;officially&nbsp;supported&nbsp;platform)&nbsp;there&nbsp;are&nbsp;many&nbsp;who&nbsp;desire/need&nbsp;to<br> ></DIV
&nbsp;&nbsp;&nbsp;&nbsp;run&nbsp;Bugzilla&nbsp;on&nbsp;Microsoft&nbsp;Windows&nbsp;boxes.&nbsp;&nbsp;Whenever&nbsp;possible,&nbsp;we&nbsp;should&nbsp;strive<br> ><DIV
&nbsp;&nbsp;&nbsp;&nbsp;not&nbsp;to&nbsp;make&nbsp;the&nbsp;lives&nbsp;of&nbsp;these&nbsp;people&nbsp;any&nbsp;more&nbsp;complicated&nbsp;and&nbsp;avoid&nbsp;doing&nbsp;things<br> CLASS="SECTION"
&nbsp;&nbsp;&nbsp;&nbsp;that&nbsp;break&nbsp;Bugzilla's&nbsp;ability&nbsp;to&nbsp;run&nbsp;on&nbsp;multiple&nbsp;operating&nbsp;systems.<br> ><HR><H2
<br> CLASS="SECTION"
&nbsp;&nbsp;&nbsp;&nbsp;</P ><A
NAME="AEN2509"
>D.5.2. Coding Style for Bugzilla</A
></H2
><P
> While it's true that not all of the code currently in Bugzilla adheres to
this (or any) styleguide, it is something that is being worked toward. Therefore,
we ask that all new code (submitted patches and new files) follow this guide
as closely as possible (if you're only changing 1 or 2 lines, you don't have
to reformat the entire file :).
</P
><P
> The Bugzilla development team has decided to adopt the perl style guide as
published by Larry Wall. This giude can be found in <SPAN
CLASS="QUOTE"
>"Programming
Perl"</SPAN
> (the camel book) or by typing <B
CLASS="COMMAND"
>man perlstyle</B
> at
your favorite shell prompt.
</P
><P
> What appears below if a brief summary, please refer to the perl style
guide if you don't see your question covered here.
</P
><P
></P
><UL
><LI
><P
> Whitespace
</P
><P
> Bugzilla's prefered indentation is 4 spaces (no tabs, please).
</P
></LI
><LI
><P
> Curly braces.
</P
><P
> The opening brace of a block should be on the same line as the statement
that is causing the block and the closing brace should be at the same
indentation level as that statement, for example:
</P
><P
> <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="PROGRAMLISTING"
>if ($var) {
print "The variable is true";
}
else {
print "Try again";
}
</PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
> -- NOT THIS --
</P
><P
> <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="PROGRAMLISTING"
>if ($var)
{
print "The variable is true";
}
else
{
print "Try again";
}
</PRE
></FONT
></TD
></TR
></TABLE
>
</P
></LI
><LI
><P
> File Names
</P
><P
> File names for bugzilla code and support documention should be legal across
multiple platforms. <TT
CLASS="COMPUTEROUTPUT"
>\ / : * ? " &#60; &#62;</TT
>
and <TT
CLASS="COMPUTEROUTPUT"
>|</TT
> are all illegal characters for filenames
on various platforms. Also, file names should not have spaces in them as they
can cause confusion in CVS and other mozilla.org utilities.
</P
></LI
><LI
><P
> Variable Names
</P
><P
> If a variable is scoped globally (<TT
CLASS="COMPUTEROUTPUT"
>$::variable</TT
>)
its name should be descriptive of what it contains. Local variables can be named
a bit looser, provided the context makes their content obvious. For example,
<TT
CLASS="COMPUTEROUTPUT"
>$ret</TT
> could be used as a staging variable for a
routine's return value as the line <TT
CLASS="COMPUTEROUTPUT"
>return $ret;</TT
>
will make it blatantly obvious what the variable holds and most likely be shown
on the same screen as <TT
CLASS="COMPUTEROUTPUT"
>my $ret = "";</TT
>.
</P
></LI
><LI
><P
> Cross Database Compatability
</P
><P
> Bugzilla was originally written to work with MySQL and therefore took advantage
of some of its features that aren't contained in other RDBMS software. These
should be avoided in all new code. Examples of these features are enums and
<TT
CLASS="FUNCTION"
>encrypt()</TT
>.
</P
></LI
><LI
><P
> Cross Platform Compatability
</P
><P
> While Bugzilla was written to be used on Unix based systems (and Unix/Linux is
still the only officially supported platform) there are many who desire/need to
run Bugzilla on Microsoft Windows boxes. Whenever possible, we should strive
not to make the lives of these people any more complicated and avoid doing things
that break Bugzilla's ability to run on multiple operating systems.
</P
></LI
></UL
></DIV
></DIV ></DIV
></DIV ></DIV
><DIV ><DIV
...@@ -16094,7 +16292,7 @@ NAME="GFDL" ...@@ -16094,7 +16292,7 @@ NAME="GFDL"
><P ><P
>Version 1.1, March 2000</P >Version 1.1, March 2000</P
><A ><A
NAME="AEN2499" NAME="AEN2550"
></A ></A
><BLOCKQUOTE ><BLOCKQUOTE
CLASS="BLOCKQUOTE" CLASS="BLOCKQUOTE"
...@@ -16593,7 +16791,7 @@ NAME="GFDL_HOWTO" ...@@ -16593,7 +16791,7 @@ NAME="GFDL_HOWTO"
a copy of the License in the document and put the following a copy of the License in the document and put the following
copyright and license notices just after the title page:</P copyright and license notices just after the title page:</P
><A ><A
NAME="AEN2589" NAME="AEN2640"
></A ></A
><BLOCKQUOTE ><BLOCKQUOTE
CLASS="BLOCKQUOTE" CLASS="BLOCKQUOTE"
...@@ -16632,7 +16830,7 @@ CLASS="GLOSSDIV" ...@@ -16632,7 +16830,7 @@ CLASS="GLOSSDIV"
><H1 ><H1
CLASS="GLOSSDIV" CLASS="GLOSSDIV"
><A ><A
NAME="AEN2594" NAME="AEN2645"
>0-9, high ascii</A >0-9, high ascii</A
></H1 ></H1
><DL ><DL
...@@ -16966,7 +17164,7 @@ NAME="GLOSS_P" ...@@ -16966,7 +17164,7 @@ NAME="GLOSS_P"
><DIV ><DIV
CLASS="EXAMPLE" CLASS="EXAMPLE"
><A ><A
NAME="AEN2685" NAME="AEN2736"
></A ></A
><P ><P
><B ><B
......
...@@ -74,101 +74,285 @@ NAME="BZHACKING" ...@@ -74,101 +74,285 @@ NAME="BZHACKING"
>D.5. Hacking Bugzilla</A >D.5. Hacking Bugzilla</A
></H1 ></H1
><P ><P
> What follows are some general guidelines for changing Bugzilla, and adhering to good coding practice while doing so. We've had some checkins in the past which ruined Bugzilla installations because of disregard for these conventions. Sorry for the lack of formatting; I got this info into the Guide on the day of 2.14 release and haven't formatted it yet. > The following is a guide for reviewers when checking code into Bugzilla's
</P CVS repostory at mozilla.org. If you wish to submit patches to Bugzilla,
><P you should follow the rules and style conventions below. Any code that
CLASS="LITERALLAYOUT" does not adhere to these basic rules will not be added to Bugzilla's
><br> codebase.
The&nbsp;following&nbsp;is&nbsp;a&nbsp;guide&nbsp;for&nbsp;reviewers&nbsp;when&nbsp;checking&nbsp;code&nbsp;into&nbsp;Bugzilla's<br> </P
CVS&nbsp;repostory&nbsp;at&nbsp;mozilla.org.&nbsp;&nbsp;If&nbsp;you&nbsp;wish&nbsp;to&nbsp;submit&nbsp;patches&nbsp;to&nbsp;Bugzilla,<br> ><DIV
you&nbsp;should&nbsp;follow&nbsp;the&nbsp;rules&nbsp;and&nbsp;style&nbsp;conventions&nbsp;below.&nbsp;&nbsp;Any&nbsp;code&nbsp;that<br> CLASS="SECTION"
does&nbsp;not&nbsp;adhere&nbsp;to&nbsp;these&nbsp;basic&nbsp;rules&nbsp;will&nbsp;not&nbsp;be&nbsp;added&nbsp;to&nbsp;Bugzilla's<br> ><H2
codebase.<br> CLASS="SECTION"
<br> ><A
&nbsp;1.&nbsp;Usage&nbsp;of&nbsp;variables&nbsp;in&nbsp;Regular&nbsp;Expressions<br> NAME="AEN2495"
<br> >D.5.1. Things that have caused problems and should be avoided</A
&nbsp;&nbsp;&nbsp;&nbsp;It&nbsp;is&nbsp;very&nbsp;important&nbsp;that&nbsp;you&nbsp;don't&nbsp;use&nbsp;a&nbsp;variable&nbsp;in&nbsp;a&nbsp;regular<br> ></H2
&nbsp;&nbsp;&nbsp;&nbsp;expression&nbsp;unless&nbsp;that&nbsp;variable&nbsp;is&nbsp;supposed&nbsp;to&nbsp;contain&nbsp;an&nbsp;expression.<br> ><P
&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;especially&nbsp;applies&nbsp;when&nbsp;using&nbsp;grep.&nbsp;&nbsp;You&nbsp;should&nbsp;use:<br> ></P
<br> ><OL
&nbsp;&nbsp;&nbsp;&nbsp;grep&nbsp;($_&nbsp;eq&nbsp;$value,&nbsp;@array);<br> TYPE="1"
<br> ><LI
&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;NOT&nbsp;-<br> ><P
<br> > Usage of variables in Regular Expressions
&nbsp;&nbsp;&nbsp;&nbsp;grep&nbsp;(/$value/,&nbsp;@array);<br> </P
<br> ><P
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;you&nbsp;need&nbsp;to&nbsp;use&nbsp;a&nbsp;non-expression&nbsp;variable&nbsp;inside&nbsp;of&nbsp;an&nbsp;expression,&nbsp;be<br> > It is very important that you don't use a variable in a regular
&nbsp;&nbsp;&nbsp;&nbsp;sure&nbsp;to&nbsp;quote&nbsp;it&nbsp;properly&nbsp;(using&nbsp;\Q..\E).<br> expression unless that variable is supposed to contain an expression.
<br> This especially applies when using grep. You should use:
Coding&nbsp;Style&nbsp;for&nbsp;Bugzilla<br> </P
-------------------------<br> ><P
<br> > <TABLE
While&nbsp;it's&nbsp;true&nbsp;that&nbsp;not&nbsp;all&nbsp;of&nbsp;the&nbsp;code&nbsp;currently&nbsp;in&nbsp;Bugzilla&nbsp;adheres&nbsp;to<br> BORDER="0"
this&nbsp;styleguide,&nbsp;it&nbsp;is&nbsp;something&nbsp;that&nbsp;is&nbsp;being&nbsp;worked&nbsp;toward.&nbsp;&nbsp;Therefore,<br> BGCOLOR="#E0E0E0"
we&nbsp;ask&nbsp;that&nbsp;all&nbsp;new&nbsp;code&nbsp;(submitted&nbsp;patches&nbsp;and&nbsp;new&nbsp;files)&nbsp;follow&nbsp;this&nbsp;guide<br> WIDTH="90%"
as&nbsp;closely&nbsp;as&nbsp;possible&nbsp;(if&nbsp;you're&nbsp;only&nbsp;changing&nbsp;1&nbsp;or&nbsp;2&nbsp;lines,&nbsp;you&nbsp;don't&nbsp;have<br> ><TR
to&nbsp;reformat&nbsp;the&nbsp;entire&nbsp;file&nbsp;:).<br> ><TD
<br> ><FONT
&nbsp;1.&nbsp;Whitespace<br> COLOR="#000000"
<br> ><PRE
&nbsp;&nbsp;&nbsp;&nbsp;Bugzilla's&nbsp;prefered&nbsp;indentation&nbsp;is&nbsp;4&nbsp;spaces&nbsp;(no&nbsp;tabs,&nbsp;please).<br> CLASS="PROGRAMLISTING"
<br> >grep ($_ eq $value, @array);
&nbsp;2.&nbsp;Curly&nbsp;braces.<br> </PRE
<br> ></FONT
&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;opening&nbsp;brace&nbsp;of&nbsp;a&nbsp;block&nbsp;should&nbsp;be&nbsp;on&nbsp;the&nbsp;same&nbsp;line&nbsp;as&nbsp;the&nbsp;statement<br> ></TD
&nbsp;&nbsp;&nbsp;&nbsp;that&nbsp;is&nbsp;causing&nbsp;the&nbsp;block&nbsp;and&nbsp;the&nbsp;closing&nbsp;brace&nbsp;should&nbsp;be&nbsp;at&nbsp;the&nbsp;same<br> ></TR
&nbsp;&nbsp;&nbsp;&nbsp;indentation&nbsp;level&nbsp;as&nbsp;that&nbsp;statement,&nbsp;for&nbsp;example:<br> ></TABLE
<br> >
&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($var)&nbsp;{<br> </P
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;"The&nbsp;variable&nbsp;is&nbsp;true";<br> ><P
&nbsp;&nbsp;&nbsp;&nbsp;}<br> > -- NOT THIS --
&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;{<br> </P
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;"Try&nbsp;again";<br> ><P
&nbsp;&nbsp;&nbsp;&nbsp;}<br> > <TABLE
<br> BORDER="0"
&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;NOT&nbsp;-<br> BGCOLOR="#E0E0E0"
<br> WIDTH="90%"
&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($var)<br> ><TR
&nbsp;&nbsp;&nbsp;&nbsp;{<br> ><TD
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;"The&nbsp;variable&nbsp;is&nbsp;true";<br> ><FONT
&nbsp;&nbsp;&nbsp;&nbsp;}<br> COLOR="#000000"
&nbsp;&nbsp;&nbsp;&nbsp;else<br> ><PRE
&nbsp;&nbsp;&nbsp;&nbsp;{<br> CLASS="PROGRAMLISTING"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;"Try&nbsp;again";<br> >grep (/$value/, @array);
&nbsp;&nbsp;&nbsp;&nbsp;}<br> </PRE
<br> ></FONT
&nbsp;3.&nbsp;File&nbsp;Names<br> ></TD
<br> ></TR
&nbsp;&nbsp;&nbsp;&nbsp;File&nbsp;names&nbsp;for&nbsp;bugzilla&nbsp;code&nbsp;and&nbsp;support&nbsp;documention&nbsp;should&nbsp;be&nbsp;legal&nbsp;across<br> ></TABLE
&nbsp;&nbsp;&nbsp;&nbsp;multiple&nbsp;platforms.&nbsp;&nbsp;\&nbsp;/&nbsp;:&nbsp;*&nbsp;?&nbsp;"&nbsp;&#60;&nbsp;&#62;&nbsp;and&nbsp;|&nbsp;are&nbsp;all&nbsp;illegal&nbsp;characters&nbsp;for<br> >
&nbsp;&nbsp;&nbsp;&nbsp;filenames&nbsp;on&nbsp;various&nbsp;platforms.&nbsp;&nbsp;Also,&nbsp;file&nbsp;names&nbsp;should&nbsp;not&nbsp;have&nbsp;spaces&nbsp;in<br> </P
&nbsp;&nbsp;&nbsp;&nbsp;them&nbsp;as&nbsp;they&nbsp;can&nbsp;cause&nbsp;confusion&nbsp;in&nbsp;CVS&nbsp;and&nbsp;other&nbsp;mozilla.org&nbsp;utilities.<br> ><DIV
<br> CLASS="NOTE"
&nbsp;4.&nbsp;Variable&nbsp;Names<br> ><P
<br> ></P
&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;a&nbsp;variable&nbsp;is&nbsp;scoped&nbsp;globally&nbsp;($::variable)&nbsp;its&nbsp;name&nbsp;should&nbsp;be&nbsp;descriptive<br> ><TABLE
&nbsp;&nbsp;&nbsp;&nbsp;of&nbsp;what&nbsp;it&nbsp;contains.&nbsp;&nbsp;Local&nbsp;variables&nbsp;can&nbsp;be&nbsp;named&nbsp;a&nbsp;bit&nbsp;looser,&nbsp;provided&nbsp;the<br> CLASS="NOTE"
&nbsp;&nbsp;&nbsp;&nbsp;context&nbsp;makes&nbsp;their&nbsp;content&nbsp;obvious.&nbsp;&nbsp;For&nbsp;example,&nbsp;$ret&nbsp;could&nbsp;be&nbsp;used&nbsp;as&nbsp;a<br> WIDTH="90%"
&nbsp;&nbsp;&nbsp;&nbsp;staging&nbsp;variable&nbsp;for&nbsp;a&nbsp;routine's&nbsp;return&nbsp;value&nbsp;as&nbsp;the&nbsp;line&nbsp;|return&nbsp;$ret;|&nbsp;will<br> BORDER="0"
&nbsp;&nbsp;&nbsp;&nbsp;make&nbsp;it&nbsp;blatently&nbsp;obvious&nbsp;what&nbsp;the&nbsp;variable&nbsp;holds&nbsp;and&nbsp;most&nbsp;likely&nbsp;be&nbsp;shown<br> ><TR
&nbsp;&nbsp;&nbsp;&nbsp;on&nbsp;the&nbsp;same&nbsp;screen&nbsp;as&nbsp;|my&nbsp;$ret&nbsp;=&nbsp;"";|.<br> ><TD
<br> WIDTH="25"
&nbsp;5.&nbsp;Cross&nbsp;Database&nbsp;Compatability<br> ALIGN="CENTER"
<br> VALIGN="TOP"
&nbsp;&nbsp;&nbsp;&nbsp;Bugzilla&nbsp;was&nbsp;originally&nbsp;written&nbsp;to&nbsp;work&nbsp;with&nbsp;MySQL&nbsp;and&nbsp;therefore&nbsp;took&nbsp;advantage<br> ><IMG
&nbsp;&nbsp;&nbsp;&nbsp;of&nbsp;some&nbsp;of&nbsp;its&nbsp;features&nbsp;that&nbsp;aren't&nbsp;contained&nbsp;in&nbsp;other&nbsp;RDBMS&nbsp;software.&nbsp;&nbsp;These<br> SRC="../images/note.gif"
&nbsp;&nbsp;&nbsp;&nbsp;should&nbsp;be&nbsp;avoided&nbsp;in&nbsp;all&nbsp;new&nbsp;code.&nbsp;&nbsp;Examples&nbsp;of&nbsp;these&nbsp;features&nbsp;are&nbsp;enums&nbsp;and<br> HSPACE="5"
&nbsp;&nbsp;&nbsp;&nbsp;encrypt().<br> ALT="Note"></TD
<br> ><TD
&nbsp;6.&nbsp;Cross&nbsp;Platform&nbsp;Compatability<br> ALIGN="LEFT"
<br> VALIGN="TOP"
&nbsp;&nbsp;&nbsp;&nbsp;While&nbsp;Bugzilla&nbsp;was&nbsp;written&nbsp;to&nbsp;be&nbsp;used&nbsp;on&nbsp;Unix&nbsp;based&nbsp;systems&nbsp;(and&nbsp;Unix/Linux&nbsp;is<br> ><P
&nbsp;&nbsp;&nbsp;&nbsp;still&nbsp;the&nbsp;only&nbsp;officially&nbsp;supported&nbsp;platform)&nbsp;there&nbsp;are&nbsp;many&nbsp;who&nbsp;desire/need&nbsp;to<br> > If you need to use a non-expression variable inside of an expression, be
&nbsp;&nbsp;&nbsp;&nbsp;run&nbsp;Bugzilla&nbsp;on&nbsp;Microsoft&nbsp;Windows&nbsp;boxes.&nbsp;&nbsp;Whenever&nbsp;possible,&nbsp;we&nbsp;should&nbsp;strive<br> sure to quote it properly (using <TT
&nbsp;&nbsp;&nbsp;&nbsp;not&nbsp;to&nbsp;make&nbsp;the&nbsp;lives&nbsp;of&nbsp;these&nbsp;people&nbsp;any&nbsp;more&nbsp;complicated&nbsp;and&nbsp;avoid&nbsp;doing&nbsp;things<br> CLASS="FUNCTION"
&nbsp;&nbsp;&nbsp;&nbsp;that&nbsp;break&nbsp;Bugzilla's&nbsp;ability&nbsp;to&nbsp;run&nbsp;on&nbsp;multiple&nbsp;operating&nbsp;systems.<br> >\Q..\E</TT
<br> >).
&nbsp;&nbsp;&nbsp;&nbsp;</P </P
></TD
></TR
></TABLE
></DIV
></LI
></OL
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="AEN2509"
>D.5.2. Coding Style for Bugzilla</A
></H2
><P
> While it's true that not all of the code currently in Bugzilla adheres to
this (or any) styleguide, it is something that is being worked toward. Therefore,
we ask that all new code (submitted patches and new files) follow this guide
as closely as possible (if you're only changing 1 or 2 lines, you don't have
to reformat the entire file :).
</P
><P
> The Bugzilla development team has decided to adopt the perl style guide as
published by Larry Wall. This giude can be found in <SPAN
CLASS="QUOTE"
>"Programming
Perl"</SPAN
> (the camel book) or by typing <B
CLASS="COMMAND"
>man perlstyle</B
> at
your favorite shell prompt.
</P
><P
> What appears below if a brief summary, please refer to the perl style
guide if you don't see your question covered here.
</P
><P
></P
><UL
><LI
><P
> Whitespace
</P
><P
> Bugzilla's prefered indentation is 4 spaces (no tabs, please).
</P
></LI
><LI
><P
> Curly braces.
</P
><P
> The opening brace of a block should be on the same line as the statement
that is causing the block and the closing brace should be at the same
indentation level as that statement, for example:
</P
><P
> <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="PROGRAMLISTING"
>if ($var) {
print "The variable is true";
}
else {
print "Try again";
}
</PRE
></FONT
></TD
></TR
></TABLE
>
</P
><P
> -- NOT THIS --
</P
><P
> <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="PROGRAMLISTING"
>if ($var)
{
print "The variable is true";
}
else
{
print "Try again";
}
</PRE
></FONT
></TD
></TR
></TABLE
>
</P
></LI
><LI
><P
> File Names
</P
><P
> File names for bugzilla code and support documention should be legal across
multiple platforms. <TT
CLASS="COMPUTEROUTPUT"
>\ / : * ? " &#60; &#62;</TT
>
and <TT
CLASS="COMPUTEROUTPUT"
>|</TT
> are all illegal characters for filenames
on various platforms. Also, file names should not have spaces in them as they
can cause confusion in CVS and other mozilla.org utilities.
</P
></LI
><LI
><P
> Variable Names
</P
><P
> If a variable is scoped globally (<TT
CLASS="COMPUTEROUTPUT"
>$::variable</TT
>)
its name should be descriptive of what it contains. Local variables can be named
a bit looser, provided the context makes their content obvious. For example,
<TT
CLASS="COMPUTEROUTPUT"
>$ret</TT
> could be used as a staging variable for a
routine's return value as the line <TT
CLASS="COMPUTEROUTPUT"
>return $ret;</TT
>
will make it blatantly obvious what the variable holds and most likely be shown
on the same screen as <TT
CLASS="COMPUTEROUTPUT"
>my $ret = "";</TT
>.
</P
></LI
><LI
><P
> Cross Database Compatability
</P
><P
> Bugzilla was originally written to work with MySQL and therefore took advantage
of some of its features that aren't contained in other RDBMS software. These
should be avoided in all new code. Examples of these features are enums and
<TT
CLASS="FUNCTION"
>encrypt()</TT
>.
</P
></LI
><LI
><P
> Cross Platform Compatability
</P
><P
> While Bugzilla was written to be used on Unix based systems (and Unix/Linux is
still the only officially supported platform) there are many who desire/need to
run Bugzilla on Microsoft Windows boxes. Whenever possible, we should strive
not to make the lives of these people any more complicated and avoid doing things
that break Bugzilla's ability to run on multiple operating systems.
</P
></LI
></UL
></DIV
></DIV ></DIV
><DIV ><DIV
CLASS="NAVFOOTER" CLASS="NAVFOOTER"
......
...@@ -141,7 +141,7 @@ HREF="gfdl_howto.html" ...@@ -141,7 +141,7 @@ HREF="gfdl_howto.html"
><P ><P
>Version 1.1, March 2000</P >Version 1.1, March 2000</P
><A ><A
NAME="AEN2499" NAME="AEN2550"
></A ></A
><BLOCKQUOTE ><BLOCKQUOTE
CLASS="BLOCKQUOTE" CLASS="BLOCKQUOTE"
......
...@@ -78,7 +78,7 @@ NAME="GFDL_HOWTO" ...@@ -78,7 +78,7 @@ NAME="GFDL_HOWTO"
a copy of the License in the document and put the following a copy of the License in the document and put the following
copyright and license notices just after the title page:</P copyright and license notices just after the title page:</P
><A ><A
NAME="AEN2589" NAME="AEN2640"
></A ></A
><BLOCKQUOTE ><BLOCKQUOTE
CLASS="BLOCKQUOTE" CLASS="BLOCKQUOTE"
......
...@@ -68,7 +68,7 @@ CLASS="GLOSSDIV" ...@@ -68,7 +68,7 @@ CLASS="GLOSSDIV"
><H1 ><H1
CLASS="GLOSSDIV" CLASS="GLOSSDIV"
><A ><A
NAME="AEN2594" NAME="AEN2645"
>0-9, high ascii</A >0-9, high ascii</A
></H1 ></H1
><DL ><DL
...@@ -402,7 +402,7 @@ NAME="GLOSS_P" ...@@ -402,7 +402,7 @@ NAME="GLOSS_P"
><DIV ><DIV
CLASS="EXAMPLE" CLASS="EXAMPLE"
><A ><A
NAME="AEN2685" NAME="AEN2736"
></A ></A
><P ><P
><B ><B
......
...@@ -850,6 +850,20 @@ HREF="quicksearch.html" ...@@ -850,6 +850,20 @@ HREF="quicksearch.html"
HREF="bzhacking.html" HREF="bzhacking.html"
>Hacking Bugzilla</A >Hacking Bugzilla</A
></DT ></DT
><DD
><DL
><DT
>D.5.1. <A
HREF="bzhacking.html#AEN2495"
>Things that have caused problems and should be avoided</A
></DT
><DT
>D.5.2. <A
HREF="bzhacking.html#AEN2509"
>Coding Style for Bugzilla</A
></DT
></DL
></DD
></DL ></DL
></DD ></DD
><DT ><DT
...@@ -1009,7 +1023,7 @@ HREF="setperl.html#AEN2439" ...@@ -1009,7 +1023,7 @@ HREF="setperl.html#AEN2439"
></DT ></DT
><DT ><DT
>1. <A >1. <A
HREF="glossary.html#AEN2685" HREF="glossary.html#AEN2736"
>A Sample Product</A >A Sample Product</A
></DT ></DT
></DL ></DL
......
...@@ -104,6 +104,20 @@ HREF="quicksearch.html" ...@@ -104,6 +104,20 @@ HREF="quicksearch.html"
HREF="bzhacking.html" HREF="bzhacking.html"
>Hacking Bugzilla</A >Hacking Bugzilla</A
></DT ></DT
><DD
><DL
><DT
>D.5.1. <A
HREF="bzhacking.html#AEN2495"
>Things that have caused problems and should be avoided</A
></DT
><DT
>D.5.2. <A
HREF="bzhacking.html#AEN2509"
>Coding Style for Bugzilla</A
></DT
></DL
></DD
></DL ></DL
></DIV ></DIV
><P ><P
......
...@@ -250,100 +250,160 @@ RewriteRule ^/([0-9]+)$ http://foo.bar.com/show_bug.cgi?id=$1 [L,R] ...@@ -250,100 +250,160 @@ RewriteRule ^/([0-9]+)$ http://foo.bar.com/show_bug.cgi?id=$1 [L,R]
<section id="bzhacking"> <section id="bzhacking">
<title>Hacking Bugzilla</title> <title>Hacking Bugzilla</title>
<para> <para>
What follows are some general guidelines for changing Bugzilla, and adhering to good coding practice while doing so. We've had some checkins in the past which ruined Bugzilla installations because of disregard for these conventions. Sorry for the lack of formatting; I got this info into the Guide on the day of 2.14 release and haven't formatted it yet. The following is a guide for reviewers when checking code into Bugzilla's
CVS repostory at mozilla.org. If you wish to submit patches to Bugzilla,
you should follow the rules and style conventions below. Any code that
does not adhere to these basic rules will not be added to Bugzilla's
codebase.
</para> </para>
<literallayout> <section>
<title>Things that have caused problems and should be avoided</title>
The following is a guide for reviewers when checking code into Bugzilla's <orderedlist>
CVS repostory at mozilla.org. If you wish to submit patches to Bugzilla, <listitem>
you should follow the rules and style conventions below. Any code that <para>
does not adhere to these basic rules will not be added to Bugzilla's Usage of variables in Regular Expressions
codebase. </para>
<para>
1. Usage of variables in Regular Expressions
It is very important that you don't use a variable in a regular It is very important that you don't use a variable in a regular
expression unless that variable is supposed to contain an expression. expression unless that variable is supposed to contain an expression.
This especially applies when using grep. You should use: This especially applies when using grep. You should use:
</para>
grep ($_ eq $value, @array); <para>
<programlisting>
- NOT - grep ($_ eq $value, @array);
</programlisting>
grep (/$value/, @array); </para>
<para>
-- NOT THIS --
</para>
<para>
<programlisting>
grep (/$value/, @array);
</programlisting>
</para>
<note>
<para>
If you need to use a non-expression variable inside of an expression, be If you need to use a non-expression variable inside of an expression, be
sure to quote it properly (using \Q..\E). sure to quote it properly (using <function>\Q..\E</function>).
</para>
Coding Style for Bugzilla </note>
------------------------- </listitem>
</orderedlist>
While it's true that not all of the code currently in Bugzilla adheres to </section>
this styleguide, it is something that is being worked toward. Therefore, <section>
we ask that all new code (submitted patches and new files) follow this guide <title>Coding Style for Bugzilla</title>
as closely as possible (if you're only changing 1 or 2 lines, you don't have <para>
to reformat the entire file :). While it's true that not all of the code currently in Bugzilla adheres to
this (or any) styleguide, it is something that is being worked toward. Therefore,
1. Whitespace we ask that all new code (submitted patches and new files) follow this guide
as closely as possible (if you're only changing 1 or 2 lines, you don't have
to reformat the entire file :).
</para>
<para>
The Bugzilla development team has decided to adopt the perl style guide as
published by Larry Wall. This giude can be found in <quote>Programming
Perl</quote> (the camel book) or by typing <command>man perlstyle</command> at
your favorite shell prompt.
</para>
<para>
What appears below if a brief summary, please refer to the perl style
guide if you don't see your question covered here.
</para>
<itemizedlist>
<listitem>
<para>
Whitespace
</para>
<para>
Bugzilla's prefered indentation is 4 spaces (no tabs, please). Bugzilla's prefered indentation is 4 spaces (no tabs, please).
</para>
2. Curly braces. </listitem>
<listitem>
<para>
Curly braces.
</para>
<para>
The opening brace of a block should be on the same line as the statement The opening brace of a block should be on the same line as the statement
that is causing the block and the closing brace should be at the same that is causing the block and the closing brace should be at the same
indentation level as that statement, for example: indentation level as that statement, for example:
</para>
if ($var) { <para>
<programlisting>
if ($var) {
print "The variable is true"; print "The variable is true";
} }
else { else {
print "Try again"; print "Try again";
} }
</programlisting>
- NOT - </para>
<para>
if ($var) -- NOT THIS --
{ </para>
<para>
<programlisting>
if ($var)
{
print "The variable is true"; print "The variable is true";
} }
else else
{ {
print "Try again"; print "Try again";
} }
</programlisting>
3. File Names </para>
</listitem>
<listitem>
<para>
File Names
</para>
<para>
File names for bugzilla code and support documention should be legal across File names for bugzilla code and support documention should be legal across
multiple platforms. \ / : * ? " < > and | are all illegal characters for multiple platforms. <computeroutput>\ / : * ? &quot; &lt; &gt;</computeroutput>
filenames on various platforms. Also, file names should not have spaces in and <computeroutput>|</computeroutput> are all illegal characters for filenames
them as they can cause confusion in CVS and other mozilla.org utilities. on various platforms. Also, file names should not have spaces in them as they
can cause confusion in CVS and other mozilla.org utilities.
4. Variable Names </para>
</listitem>
If a variable is scoped globally ($::variable) its name should be descriptive <listitem>
of what it contains. Local variables can be named a bit looser, provided the <para>
context makes their content obvious. For example, $ret could be used as a Variable Names
staging variable for a routine's return value as the line |return $ret;| will </para>
make it blatently obvious what the variable holds and most likely be shown <para>
on the same screen as |my $ret = "";|. If a variable is scoped globally (<computeroutput>$::variable</computeroutput>)
its name should be descriptive of what it contains. Local variables can be named
5. Cross Database Compatability a bit looser, provided the context makes their content obvious. For example,
<computeroutput>$ret</computeroutput> could be used as a staging variable for a
routine's return value as the line <computeroutput>return $ret;</computeroutput>
will make it blatantly obvious what the variable holds and most likely be shown
on the same screen as <computeroutput>my $ret = "";</computeroutput>.
</para>
</listitem>
<listitem>
<para>
Cross Database Compatability
</para>
<para>
Bugzilla was originally written to work with MySQL and therefore took advantage Bugzilla was originally written to work with MySQL and therefore took advantage
of some of its features that aren't contained in other RDBMS software. These of some of its features that aren't contained in other RDBMS software. These
should be avoided in all new code. Examples of these features are enums and should be avoided in all new code. Examples of these features are enums and
encrypt(). <function>encrypt()</function>.
</para>
6. Cross Platform Compatability </listitem>
<listitem>
<para>
Cross Platform Compatability
</para>
<para>
While Bugzilla was written to be used on Unix based systems (and Unix/Linux is While Bugzilla was written to be used on Unix based systems (and Unix/Linux is
still the only officially supported platform) there are many who desire/need to still the only officially supported platform) there are many who desire/need to
run Bugzilla on Microsoft Windows boxes. Whenever possible, we should strive run Bugzilla on Microsoft Windows boxes. Whenever possible, we should strive
not to make the lives of these people any more complicated and avoid doing things not to make the lives of these people any more complicated and avoid doing things
that break Bugzilla's ability to run on multiple operating systems. that break Bugzilla's ability to run on multiple operating systems.
</para>
</literallayout> </listitem>
</itemizedlist>
</section>
</section> </section>
</appendix> </appendix>
......
...@@ -200,6 +200,11 @@ Matthew P. Barnson ...@@ -200,6 +200,11 @@ Matthew P. Barnson
D.4. The Quicksearch Utility D.4. The Quicksearch Utility
D.5. Hacking Bugzilla D.5. Hacking Bugzilla
D.5.1. Things that have caused problems and should be
avoided
D.5.2. Coding Style for Bugzilla
E. GNU Free Documentation License E. GNU Free Documentation License
0. PREAMBLE 0. PREAMBLE
...@@ -5851,106 +5856,104 @@ D.4. The Quicksearch Utility ...@@ -5851,106 +5856,104 @@ D.4. The Quicksearch Utility
D.5. Hacking Bugzilla D.5. Hacking Bugzilla
What follows are some general guidelines for changing Bugzilla, and The following is a guide for reviewers when checking code into
adhering to good coding practice while doing so. We've had some Bugzilla's CVS repostory at mozilla.org. If you wish to submit patches
checkins in the past which ruined Bugzilla installations because of to Bugzilla, you should follow the rules and style conventions below.
disregard for these conventions. Sorry for the lack of formatting; I Any code that does not adhere to these basic rules will not be added
got this info into the Guide on the day of 2.14 release and haven't to Bugzilla's codebase.
formatted it yet. _________________________________________________________________
The following is a guide for reviewers when checking code into Bugzill D.5.1. Things that have caused problems and should be avoided
a's
CVS repostory at mozilla.org. If you wish to submit patches to Bugzil
la,
you should follow the rules and style conventions below. Any code tha
t
does not adhere to these basic rules will not be added to Bugzilla's
codebase.
1. Usage of variables in Regular Expressions 1. Usage of variables in Regular Expressions
It is very important that you don't use a variable in a regular It is very important that you don't use a variable in a regular
expression unless that variable is supposed to contain an expressi expression unless that variable is supposed to contain an
on. expression. This especially applies when using grep. You should
This especially applies when using grep. You should use: use:
grep ($_ eq $value, @array);
- NOT - grep ($_ eq $value, @array);
grep (/$value/, @array);
If you need to use a non-expression variable inside of an expressi
on, be -- NOT THIS --
sure to quote it properly (using \Q..\E).
Coding Style for Bugzilla grep (/$value/, @array);
-------------------------
Note
If you need to use a non-expression variable inside of an expression,
be sure to quote it properly (using \Q..\E).
_________________________________________________________________
D.5.2. Coding Style for Bugzilla
While it's true that not all of the code currently in Bugzilla adheres While it's true that not all of the code currently in Bugzilla adheres
to to this (or any) styleguide, it is something that is being worked
this styleguide, it is something that is being worked toward. Therefo toward. Therefore, we ask that all new code (submitted patches and new
re, files) follow this guide as closely as possible (if you're only
we ask that all new code (submitted patches and new files) follow this changing 1 or 2 lines, you don't have to reformat the entire file :).
guide
as closely as possible (if you're only changing 1 or 2 lines, you don' The Bugzilla development team has decided to adopt the perl style
t have guide as published by Larry Wall. This giude can be found in
to reformat the entire file :). "Programming Perl" (the camel book) or by typing man perlstyle at your
1. Whitespace favorite shell prompt.
What appears below if a brief summary, please refer to the perl style
guide if you don't see your question covered here.
* Whitespace
Bugzilla's prefered indentation is 4 spaces (no tabs, please). Bugzilla's prefered indentation is 4 spaces (no tabs, please).
2. Curly braces. * Curly braces.
The opening brace of a block should be on the same line as the sta The opening brace of a block should be on the same line as the
tement statement that is causing the block and the closing brace should
that is causing the block and the closing brace should be at the s be at the same indentation level as that statement, for example:
ame
indentation level as that statement, for example: if ($var) {
if ($var) {
print "The variable is true"; print "The variable is true";
} }
else { else {
print "Try again"; print "Try again";
} }
- NOT -
if ($var)
{ -- NOT THIS --
if ($var)
{
print "The variable is true"; print "The variable is true";
} }
else else
{ {
print "Try again"; print "Try again";
} }
3. File Names
File names for bugzilla code and support documention should be leg
al across * File Names
multiple platforms. \ / : * ? " < > and | are all illegal charact File names for bugzilla code and support documention should be
ers for legal across multiple platforms. \ / : * ? " < > and | are all
filenames on various platforms. Also, file names should not have illegal characters for filenames on various platforms. Also, file
spaces in names should not have spaces in them as they can cause confusion
them as they can cause confusion in CVS and other mozilla.org util in CVS and other mozilla.org utilities.
ities. * Variable Names
4. Variable Names
If a variable is scoped globally ($::variable) its name should be If a variable is scoped globally ($::variable) its name should be
descriptive descriptive of what it contains. Local variables can be named a
of what it contains. Local variables can be named a bit looser, p bit looser, provided the context makes their content obvious. For
rovided the example, $ret could be used as a staging variable for a routine's
context makes their content obvious. For example, $ret could be u return value as the line return $ret; will make it blatantly
sed as a obvious what the variable holds and most likely be shown on the
staging variable for a routine's return value as the line |return same screen as my $ret = "";.
$ret;| will * Cross Database Compatability
make it blatently obvious what the variable holds and most likely Bugzilla was originally written to work with MySQL and therefore
be shown took advantage of some of its features that aren't contained in
on the same screen as |my $ret = "";|. other RDBMS software. These should be avoided in all new code.
5. Cross Database Compatability Examples of these features are enums and encrypt().
Bugzilla was originally written to work with MySQL and therefore t * Cross Platform Compatability
ook advantage While Bugzilla was written to be used on Unix based systems (and
of some of its features that aren't contained in other RDBMS softw Unix/Linux is still the only officially supported platform) there
are. These are many who desire/need to run Bugzilla on Microsoft Windows
should be avoided in all new code. Examples of these features are boxes. Whenever possible, we should strive not to make the lives
enums and of these people any more complicated and avoid doing things that
encrypt(). break Bugzilla's ability to run on multiple operating systems.
6. Cross Platform Compatability
While Bugzilla was written to be used on Unix based systems (and U
nix/Linux is
still the only officially supported platform) there are many who d
esire/need to
run Bugzilla on Microsoft Windows boxes. Whenever possible, we sh
ould strive
not to make the lives of these people any more complicated and avo
id doing things
that break Bugzilla's ability to run on multiple operating systems
.
_________________________________________________________________ _________________________________________________________________
Appendix E. GNU Free Documentation License Appendix E. GNU Free Documentation License
......
...@@ -250,100 +250,160 @@ RewriteRule ^/([0-9]+)$ http://foo.bar.com/show_bug.cgi?id=$1 [L,R] ...@@ -250,100 +250,160 @@ RewriteRule ^/([0-9]+)$ http://foo.bar.com/show_bug.cgi?id=$1 [L,R]
<section id="bzhacking"> <section id="bzhacking">
<title>Hacking Bugzilla</title> <title>Hacking Bugzilla</title>
<para> <para>
What follows are some general guidelines for changing Bugzilla, and adhering to good coding practice while doing so. We've had some checkins in the past which ruined Bugzilla installations because of disregard for these conventions. Sorry for the lack of formatting; I got this info into the Guide on the day of 2.14 release and haven't formatted it yet. The following is a guide for reviewers when checking code into Bugzilla's
CVS repostory at mozilla.org. If you wish to submit patches to Bugzilla,
you should follow the rules and style conventions below. Any code that
does not adhere to these basic rules will not be added to Bugzilla's
codebase.
</para> </para>
<literallayout> <section>
<title>Things that have caused problems and should be avoided</title>
The following is a guide for reviewers when checking code into Bugzilla's <orderedlist>
CVS repostory at mozilla.org. If you wish to submit patches to Bugzilla, <listitem>
you should follow the rules and style conventions below. Any code that <para>
does not adhere to these basic rules will not be added to Bugzilla's Usage of variables in Regular Expressions
codebase. </para>
<para>
1. Usage of variables in Regular Expressions
It is very important that you don't use a variable in a regular It is very important that you don't use a variable in a regular
expression unless that variable is supposed to contain an expression. expression unless that variable is supposed to contain an expression.
This especially applies when using grep. You should use: This especially applies when using grep. You should use:
</para>
grep ($_ eq $value, @array); <para>
<programlisting>
- NOT - grep ($_ eq $value, @array);
</programlisting>
grep (/$value/, @array); </para>
<para>
-- NOT THIS --
</para>
<para>
<programlisting>
grep (/$value/, @array);
</programlisting>
</para>
<note>
<para>
If you need to use a non-expression variable inside of an expression, be If you need to use a non-expression variable inside of an expression, be
sure to quote it properly (using \Q..\E). sure to quote it properly (using <function>\Q..\E</function>).
</para>
Coding Style for Bugzilla </note>
------------------------- </listitem>
</orderedlist>
While it's true that not all of the code currently in Bugzilla adheres to </section>
this styleguide, it is something that is being worked toward. Therefore, <section>
we ask that all new code (submitted patches and new files) follow this guide <title>Coding Style for Bugzilla</title>
as closely as possible (if you're only changing 1 or 2 lines, you don't have <para>
to reformat the entire file :). While it's true that not all of the code currently in Bugzilla adheres to
this (or any) styleguide, it is something that is being worked toward. Therefore,
1. Whitespace we ask that all new code (submitted patches and new files) follow this guide
as closely as possible (if you're only changing 1 or 2 lines, you don't have
to reformat the entire file :).
</para>
<para>
The Bugzilla development team has decided to adopt the perl style guide as
published by Larry Wall. This giude can be found in <quote>Programming
Perl</quote> (the camel book) or by typing <command>man perlstyle</command> at
your favorite shell prompt.
</para>
<para>
What appears below if a brief summary, please refer to the perl style
guide if you don't see your question covered here.
</para>
<itemizedlist>
<listitem>
<para>
Whitespace
</para>
<para>
Bugzilla's prefered indentation is 4 spaces (no tabs, please). Bugzilla's prefered indentation is 4 spaces (no tabs, please).
</para>
2. Curly braces. </listitem>
<listitem>
<para>
Curly braces.
</para>
<para>
The opening brace of a block should be on the same line as the statement The opening brace of a block should be on the same line as the statement
that is causing the block and the closing brace should be at the same that is causing the block and the closing brace should be at the same
indentation level as that statement, for example: indentation level as that statement, for example:
</para>
if ($var) { <para>
<programlisting>
if ($var) {
print "The variable is true"; print "The variable is true";
} }
else { else {
print "Try again"; print "Try again";
} }
</programlisting>
- NOT - </para>
<para>
if ($var) -- NOT THIS --
{ </para>
<para>
<programlisting>
if ($var)
{
print "The variable is true"; print "The variable is true";
} }
else else
{ {
print "Try again"; print "Try again";
} }
</programlisting>
3. File Names </para>
</listitem>
<listitem>
<para>
File Names
</para>
<para>
File names for bugzilla code and support documention should be legal across File names for bugzilla code and support documention should be legal across
multiple platforms. \ / : * ? " < > and | are all illegal characters for multiple platforms. <computeroutput>\ / : * ? &quot; &lt; &gt;</computeroutput>
filenames on various platforms. Also, file names should not have spaces in and <computeroutput>|</computeroutput> are all illegal characters for filenames
them as they can cause confusion in CVS and other mozilla.org utilities. on various platforms. Also, file names should not have spaces in them as they
can cause confusion in CVS and other mozilla.org utilities.
4. Variable Names </para>
</listitem>
If a variable is scoped globally ($::variable) its name should be descriptive <listitem>
of what it contains. Local variables can be named a bit looser, provided the <para>
context makes their content obvious. For example, $ret could be used as a Variable Names
staging variable for a routine's return value as the line |return $ret;| will </para>
make it blatently obvious what the variable holds and most likely be shown <para>
on the same screen as |my $ret = "";|. If a variable is scoped globally (<computeroutput>$::variable</computeroutput>)
its name should be descriptive of what it contains. Local variables can be named
5. Cross Database Compatability a bit looser, provided the context makes their content obvious. For example,
<computeroutput>$ret</computeroutput> could be used as a staging variable for a
routine's return value as the line <computeroutput>return $ret;</computeroutput>
will make it blatantly obvious what the variable holds and most likely be shown
on the same screen as <computeroutput>my $ret = "";</computeroutput>.
</para>
</listitem>
<listitem>
<para>
Cross Database Compatability
</para>
<para>
Bugzilla was originally written to work with MySQL and therefore took advantage Bugzilla was originally written to work with MySQL and therefore took advantage
of some of its features that aren't contained in other RDBMS software. These of some of its features that aren't contained in other RDBMS software. These
should be avoided in all new code. Examples of these features are enums and should be avoided in all new code. Examples of these features are enums and
encrypt(). <function>encrypt()</function>.
</para>
6. Cross Platform Compatability </listitem>
<listitem>
<para>
Cross Platform Compatability
</para>
<para>
While Bugzilla was written to be used on Unix based systems (and Unix/Linux is While Bugzilla was written to be used on Unix based systems (and Unix/Linux is
still the only officially supported platform) there are many who desire/need to still the only officially supported platform) there are many who desire/need to
run Bugzilla on Microsoft Windows boxes. Whenever possible, we should strive run Bugzilla on Microsoft Windows boxes. Whenever possible, we should strive
not to make the lives of these people any more complicated and avoid doing things not to make the lives of these people any more complicated and avoid doing things
that break Bugzilla's ability to run on multiple operating systems. that break Bugzilla's ability to run on multiple operating systems.
</para>
</literallayout> </listitem>
</itemizedlist>
</section>
</section> </section>
</appendix> </appendix>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment