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
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"
><H2
CLASS="SECTION"
><A
NAME="AEN2495"
>D.5.1. Things that have caused problems and should be avoided</A
></H2
><P
></P
><OL
TYPE="1"
><LI
><P
> Usage of variables in Regular Expressions
</P
><P
> It is very important that you don't use a variable in a regular
expression unless that variable is supposed to contain an expression.
This especially applies when using grep. You should use:
</P
><P
> <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="PROGRAMLISTING"
>grep ($_ eq $value, @array);
</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"
>grep (/$value/, @array);
</PRE
></FONT
></TD
></TR
></TABLE
>
</P
><DIV
CLASS="NOTE"
><P
></P
><TABLE
CLASS="NOTE"
WIDTH="90%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/note.gif"
HSPACE="5"
ALT="Note"></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P ><P
CLASS="LITERALLAYOUT" > If you need to use a non-expression variable inside of an expression, be
><br> sure to quote it properly (using <TT
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> CLASS="FUNCTION"
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> >\Q..\E</TT
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> >).
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> </P
codebase.<br> ></TD
<br> ></TR
&nbsp;1.&nbsp;Usage&nbsp;of&nbsp;variables&nbsp;in&nbsp;Regular&nbsp;Expressions<br> ></TABLE
<br> ></DIV
&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> ></LI
&nbsp;&nbsp;&nbsp;&nbsp;expression&nbsp;unless&nbsp;that&nbsp;variable&nbsp;is&nbsp;supposed&nbsp;to&nbsp;contain&nbsp;an&nbsp;expression.<br> ></OL
&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;especially&nbsp;applies&nbsp;when&nbsp;using&nbsp;grep.&nbsp;&nbsp;You&nbsp;should&nbsp;use:<br> ></DIV
<br> ><DIV
&nbsp;&nbsp;&nbsp;&nbsp;grep&nbsp;($_&nbsp;eq&nbsp;$value,&nbsp;@array);<br> CLASS="SECTION"
<br> ><H2
&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;NOT&nbsp;-<br> CLASS="SECTION"
<br> ><A
&nbsp;&nbsp;&nbsp;&nbsp;grep&nbsp;(/$value/,&nbsp;@array);<br> NAME="AEN2509"
<br> >D.5.2. Coding Style for Bugzilla</A
&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> ></H2
&nbsp;&nbsp;&nbsp;&nbsp;sure&nbsp;to&nbsp;quote&nbsp;it&nbsp;properly&nbsp;(using&nbsp;\Q..\E).<br> ><P
<br> > While it's true that not all of the code currently in Bugzilla adheres to
Coding&nbsp;Style&nbsp;for&nbsp;Bugzilla<br> this (or any) styleguide, it is something that is being worked toward. Therefore,
-------------------------<br> we ask that all new code (submitted patches and new files) follow this guide
<br> as closely as possible (if you're only changing 1 or 2 lines, you don't have
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> to reformat the entire file :).
this&nbsp;styleguide,&nbsp;it&nbsp;is&nbsp;something&nbsp;that&nbsp;is&nbsp;being&nbsp;worked&nbsp;toward.&nbsp;&nbsp;Therefore,<br> </P
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> ><P
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> > The Bugzilla development team has decided to adopt the perl style guide as
to&nbsp;reformat&nbsp;the&nbsp;entire&nbsp;file&nbsp;:).<br> published by Larry Wall. This giude can be found in <SPAN
<br> CLASS="QUOTE"
&nbsp;1.&nbsp;Whitespace<br> >"Programming
<br> Perl"</SPAN
&nbsp;&nbsp;&nbsp;&nbsp;Bugzilla's&nbsp;prefered&nbsp;indentation&nbsp;is&nbsp;4&nbsp;spaces&nbsp;(no&nbsp;tabs,&nbsp;please).<br> > (the camel book) or by typing <B
<br> CLASS="COMMAND"
&nbsp;2.&nbsp;Curly&nbsp;braces.<br> >man perlstyle</B
<br> > at
&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> your favorite shell prompt.
&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> </P
&nbsp;&nbsp;&nbsp;&nbsp;indentation&nbsp;level&nbsp;as&nbsp;that&nbsp;statement,&nbsp;for&nbsp;example:<br> ><P
<br> > What appears below if a brief summary, please refer to the perl style
&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($var)&nbsp;{<br> guide if you don't see your question covered here.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;"The&nbsp;variable&nbsp;is&nbsp;true";<br> </P
&nbsp;&nbsp;&nbsp;&nbsp;}<br> ><P
&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;{<br> ></P
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;"Try&nbsp;again";<br> ><UL
&nbsp;&nbsp;&nbsp;&nbsp;}<br> ><LI
<br> ><P
&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;NOT&nbsp;-<br> > Whitespace
<br> </P
&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($var)<br> ><P
&nbsp;&nbsp;&nbsp;&nbsp;{<br> > Bugzilla's prefered indentation is 4 spaces (no tabs, please).
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;"The&nbsp;variable&nbsp;is&nbsp;true";<br> </P
&nbsp;&nbsp;&nbsp;&nbsp;}<br> ></LI
&nbsp;&nbsp;&nbsp;&nbsp;else<br> ><LI
&nbsp;&nbsp;&nbsp;&nbsp;{<br> ><P
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;"Try&nbsp;again";<br> > Curly braces.
&nbsp;&nbsp;&nbsp;&nbsp;}<br> </P
<br> ><P
&nbsp;3.&nbsp;File&nbsp;Names<br> > The opening brace of a block should be on the same line as the statement
<br> that is causing the block and the closing brace should be at the same
&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> indentation level as that statement, for example:
&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> </P
&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> > <TABLE
<br> BORDER="0"
&nbsp;4.&nbsp;Variable&nbsp;Names<br> BGCOLOR="#E0E0E0"
<br> WIDTH="90%"
&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> ><TR
&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> ><FONT
&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> COLOR="#000000"
&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> ><PRE
&nbsp;&nbsp;&nbsp;&nbsp;on&nbsp;the&nbsp;same&nbsp;screen&nbsp;as&nbsp;|my&nbsp;$ret&nbsp;=&nbsp;"";|.<br> CLASS="PROGRAMLISTING"
<br> >if ($var) {
&nbsp;5.&nbsp;Cross&nbsp;Database&nbsp;Compatability<br> print "The variable is true";
<br> }
&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> else {
&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> print "Try again";
&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> }
&nbsp;&nbsp;&nbsp;&nbsp;encrypt().<br> </PRE
<br> ></FONT
&nbsp;6.&nbsp;Cross&nbsp;Platform&nbsp;Compatability<br> ></TD
<br> ></TR
&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> ></TABLE
&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> >
&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> </P
&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> ><P
&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> > -- NOT THIS --
<br> </P
&nbsp;&nbsp;&nbsp;&nbsp;</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
expression unless that variable is supposed to contain an expression.
It is very important that you don't use a variable in a regular This especially applies when using grep. You should use:
expression unless that variable is supposed to contain an expression. </para>
This especially applies when using grep. You should use: <para>
<programlisting>
grep ($_ eq $value, @array); grep ($_ eq $value, @array);
</programlisting>
- NOT - </para>
<para>
grep (/$value/, @array); -- NOT THIS --
</para>
If you need to use a non-expression variable inside of an expression, be <para>
sure to quote it properly (using \Q..\E). <programlisting>
grep (/$value/, @array);
Coding Style for Bugzilla </programlisting>
------------------------- </para>
<note>
While it's true that not all of the code currently in Bugzilla adheres to <para>
this styleguide, it is something that is being worked toward. Therefore, If you need to use a non-expression variable inside of an expression, be
we ask that all new code (submitted patches and new files) follow this guide sure to quote it properly (using <function>\Q..\E</function>).
as closely as possible (if you're only changing 1 or 2 lines, you don't have </para>
to reformat the entire file :). </note>
</listitem>
1. Whitespace </orderedlist>
</section>
Bugzilla's prefered indentation is 4 spaces (no tabs, please). <section>
<title>Coding Style for Bugzilla</title>
2. Curly braces. <para>
While it's true that not all of the code currently in Bugzilla adheres to
The opening brace of a block should be on the same line as the statement this (or any) styleguide, it is something that is being worked toward. Therefore,
that is causing the block and the closing brace should be at the same we ask that all new code (submitted patches and new files) follow this guide
indentation level as that statement, for example: as closely as possible (if you're only changing 1 or 2 lines, you don't have
to reformat the entire file :).
if ($var) { </para>
print "The variable is true"; <para>
} The Bugzilla development team has decided to adopt the perl style guide as
else { published by Larry Wall. This giude can be found in <quote>Programming
print "Try again"; Perl</quote> (the camel book) or by typing <command>man perlstyle</command> at
} your favorite shell prompt.
</para>
- NOT - <para>
What appears below if a brief summary, please refer to the perl style
if ($var) guide if you don't see your question covered here.
{ </para>
print "The variable is true"; <itemizedlist>
} <listitem>
else <para>
{ Whitespace
print "Try again"; </para>
} <para>
Bugzilla's prefered indentation is 4 spaces (no tabs, please).
3. File Names </para>
</listitem>
File names for bugzilla code and support documention should be legal across <listitem>
multiple platforms. \ / : * ? " < > and | are all illegal characters for <para>
filenames on various platforms. Also, file names should not have spaces in Curly braces.
them as they can cause confusion in CVS and other mozilla.org utilities. </para>
<para>
4. Variable Names 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
If a variable is scoped globally ($::variable) its name should be descriptive indentation level as that statement, for example:
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 <para>
staging variable for a routine's return value as the line |return $ret;| will <programlisting>
make it blatently obvious what the variable holds and most likely be shown if ($var) {
on the same screen as |my $ret = "";|. print "The variable is true";
}
5. Cross Database Compatability else {
print "Try again";
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 </programlisting>
should be avoided in all new code. Examples of these features are enums and </para>
encrypt(). <para>
-- NOT THIS --
6. Cross Platform Compatability </para>
<para>
While Bugzilla was written to be used on Unix based systems (and Unix/Linux is <programlisting>
still the only officially supported platform) there are many who desire/need to if ($var)
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 print "The variable is true";
that break Bugzilla's ability to run on multiple operating systems. }
else
</literallayout> {
print "Try again";
}
</programlisting>
</para>
</listitem>
<listitem>
<para>
File Names
</para>
<para>
File names for bugzilla code and support documention should be legal across
multiple platforms. <computeroutput>\ / : * ? &quot; &lt; &gt;</computeroutput>
and <computeroutput>|</computeroutput> 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.
</para>
</listitem>
<listitem>
<para>
Variable Names
</para>
<para>
If a variable is scoped globally (<computeroutput>$::variable</computeroutput>)
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,
<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
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
<function>encrypt()</function>.
</para>
</listitem>
<listitem>
<para>
Cross Platform Compatability
</para>
<para>
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.
</para>
</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
...@@ -443,7 +448,7 @@ Chapter 1. About This Guide ...@@ -443,7 +448,7 @@ Chapter 1. About This Guide
Chapter 2. Using Bugzilla Chapter 2. Using Bugzilla
What, Why, How, & Where? What, Why, How, & Where?
_________________________________________________________________ _________________________________________________________________
...@@ -501,7 +506,7 @@ Chapter 2. Using Bugzilla ...@@ -501,7 +506,7 @@ Chapter 2. Using Bugzilla
2.2. Why Should We Use Bugzilla? 2.2. Why Should We Use Bugzilla?
No, Who's on first... No, Who's on first...
...@@ -551,7 +556,7 @@ Chapter 2. Using Bugzilla ...@@ -551,7 +556,7 @@ Chapter 2. Using Bugzilla
2.3. How do I use Bugzilla? 2.3. How do I use Bugzilla?
Hey! I'm Woody! Howdy, Howdy, Howdy! Hey! I'm Woody! Howdy, Howdy, Howdy!
...@@ -804,7 +809,7 @@ Chapter 2. Using Bugzilla ...@@ -804,7 +809,7 @@ Chapter 2. Using Bugzilla
2.3.3. Creating and Managing Bug Reports 2.3.3. Creating and Managing Bug Reports
And all this time, I thought we were taking bugs out... And all this time, I thought we were taking bugs out...
_________________________________________________________________ _________________________________________________________________
...@@ -904,7 +909,7 @@ Chapter 2. Using Bugzilla ...@@ -904,7 +909,7 @@ Chapter 2. Using Bugzilla
2.4. Where can I find my user preferences? 2.4. Where can I find my user preferences?
Indiana, it feels like we walking on fortune cookies! Indiana, it feels like we walking on fortune cookies!
...@@ -1490,7 +1495,7 @@ perl -pi -e 's@#!/usr/bonsaitools/bin/perl@#!/usr/bin/perl@' *cgi *pl Bug.pm ...@@ -1490,7 +1495,7 @@ perl -pi -e 's@#!/usr/bonsaitools/bin/perl@#!/usr/bin/perl@' *cgi *pl Bug.pm
bash# mysql -u root mysql bash# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD ('new_password') WHERE mysql> UPDATE user SET Password=PASSWORD ('new_password') WHERE
user='root'; user='root';
mysql> FLUSH PRIVILEGES; mysql> FLUSH PRIVILEGES;
From this point on, if you need to access MySQL as the MySQL root From this point on, if you need to access MySQL as the MySQL root
...@@ -1510,7 +1515,7 @@ perl -pi -e 's@#!/usr/bonsaitools/bin/perl@#!/usr/bin/perl@' *cgi *pl Bug.pm ...@@ -1510,7 +1515,7 @@ perl -pi -e 's@#!/usr/bonsaitools/bin/perl@#!/usr/bin/perl@' *cgi *pl Bug.pm
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,INDEX, mysql> GRANT SELECT,INSERT,UPDATE,DELETE,INDEX,
ALTER,CREATE,DROP,REFERENCES ON bugs.* TO bugs@localhost IDENTIFIED BY ALTER,CREATE,DROP,REFERENCES ON bugs.* TO bugs@localhost IDENTIFIED BY
'bugs_password'; 'bugs_password';
mysql> FLUSH PRIVILEGES; mysql> FLUSH PRIVILEGES;
Next, run the magic checksetup.pl script. (Many thanks to Holger Next, run the magic checksetup.pl script. (Many thanks to Holger
Schurig <holgerschurig@nikocity.de> for writing this script!) It will Schurig <holgerschurig@nikocity.de> for writing this script!) It will
...@@ -2463,7 +2468,7 @@ Chapter 4. Administering Bugzilla ...@@ -2463,7 +2468,7 @@ Chapter 4. Administering Bugzilla
interface. Run "mysql" from the command line, and use these commands interface. Run "mysql" from the command line, and use these commands
("mysql>" denotes the mysql prompt, not something you should type in): ("mysql>" denotes the mysql prompt, not something you should type in):
mysql> use bugs; mysql> update profiles set groupset=0x7ffffffffffffff mysql> use bugs; mysql> update profiles set groupset=0x7ffffffffffffff
where login_name = "(user's login name)"; where login_name = "(user's login name)";
Yes, that is fourteen "f"'s. A whole lot of f-ing going on if you want Yes, that is fourteen "f"'s. A whole lot of f-ing going on if you want
to create a new administator. to create a new administator.
...@@ -2635,7 +2640,7 @@ Chapter 4. Administering Bugzilla ...@@ -2635,7 +2640,7 @@ Chapter 4. Administering Bugzilla
4.3. Product, Component, Milestone, and Version Administration 4.3. Product, Component, Milestone, and Version Administration
Dear Lord, we have to get our users to do WHAT? Dear Lord, we have to get our users to do WHAT?
_________________________________________________________________ _________________________________________________________________
...@@ -3061,7 +3066,7 @@ Chapter 4. Administering Bugzilla ...@@ -3061,7 +3066,7 @@ Chapter 4. Administering Bugzilla
4.4. Bugzilla Security 4.4. Bugzilla Security
Putting your money in a wall safe is better protection than depending Putting your money in a wall safe is better protection than depending
on the fact that no one knows that you hide your money in a mayonnaise on the fact that no one knows that you hide your money in a mayonnaise
...@@ -3886,238 +3891,238 @@ Appendix A. The Bugzilla FAQ ...@@ -3886,238 +3891,238 @@ Appendix A. The Bugzilla FAQ
1. General Questions 1. General Questions
A.1.1. Where can I find information about Bugzilla? A.1.1. Where can I find information about Bugzilla?
A.1.2. What license is Bugzilla distributed under? A.1.2. What license is Bugzilla distributed under?
A.1.3. How do I get commercial support for Bugzilla? A.1.3. How do I get commercial support for Bugzilla?
A.1.4. What major companies or projects are currently using A.1.4. What major companies or projects are currently using
Bugzilla for bug-tracking? Bugzilla for bug-tracking?
A.1.5. Who maintains Bugzilla? A.1.5. Who maintains Bugzilla?
A.1.6. How does Bugzilla stack up against other bug-tracking A.1.6. How does Bugzilla stack up against other bug-tracking
databases? databases?
A.1.7. How do I change my user name in Bugzilla? A.1.7. How do I change my user name in Bugzilla?
A.1.8. Why doesn't Bugzilla offer this or that feature or A.1.8. Why doesn't Bugzilla offer this or that feature or
compatability with this other tracking software? compatability with this other tracking software?
A.1.9. Why MySQL? I'm interested in seeing Bugzilla run on A.1.9. Why MySQL? I'm interested in seeing Bugzilla run on
Oracle/Sybase/Msql/PostgreSQL/MSSQL? Oracle/Sybase/Msql/PostgreSQL/MSSQL?
A.1.10. Why do the scripts say "/usr/bonsaitools/bin/perl" A.1.10. Why do the scripts say "/usr/bonsaitools/bin/perl"
instead of "/usr/bin/perl" or something else? instead of "/usr/bin/perl" or something else?
2. Red Hat Bugzilla 2. Red Hat Bugzilla
A.2.1. What about Red Hat Bugzilla? A.2.1. What about Red Hat Bugzilla?
A.2.2. What are the primary benefits of Red Hat Bugzilla? A.2.2. What are the primary benefits of Red Hat Bugzilla?
A.2.3. What's the current status of Red Hat Bugzilla? A.2.3. What's the current status of Red Hat Bugzilla?
3. Loki Bugzilla (AKA Fenris) 3. Loki Bugzilla (AKA Fenris)
A.3.1. What is Loki Bugzilla (Fenris)? A.3.1. What is Loki Bugzilla (Fenris)?
4. Pointy-Haired-Boss Questions 4. Pointy-Haired-Boss Questions
A.4.1. Is Bugzilla web-based or do you have to have specific A.4.1. Is Bugzilla web-based or do you have to have specific
software or specific operating system on your machine? software or specific operating system on your machine?
A.4.2. Has anyone you know of already done any Bugzilla A.4.2. Has anyone you know of already done any Bugzilla
integration with Perforce (SCM software)? integration with Perforce (SCM software)?
A.4.3. Does Bugzilla allow the user to track multiple projects? A.4.3. Does Bugzilla allow the user to track multiple projects?
A.4.4. If I am on many projects, and search for all bugs assigned A.4.4. If I am on many projects, and search for all bugs assigned
to me, will Bugzilla list them for me and allow me to to me, will Bugzilla list them for me and allow me to
sort by project, severity etc? sort by project, severity etc?
A.4.5. Does Bugzilla allow attachments (text, screenshots, urls A.4.5. Does Bugzilla allow attachments (text, screenshots, urls
etc)? If yes, are there any that are NOT allowed? etc)? If yes, are there any that are NOT allowed?
A.4.6. Does Bugzilla allow us to define our own priorities and A.4.6. Does Bugzilla allow us to define our own priorities and
levels? Do we have complete freedom to change the labels levels? Do we have complete freedom to change the labels
of fields and format of them, and the choice of of fields and format of them, and the choice of
acceptable values? acceptable values?
A.4.7. The index.html page doesn't show the footer. It's really A.4.7. The index.html page doesn't show the footer. It's really
annoying to have to go to the querypage just to check my annoying to have to go to the querypage just to check my
"my bugs" link. How do I get a footer on static HTML "my bugs" link. How do I get a footer on static HTML
pages? pages?
A.4.8. Does Bugzilla provide any reporting features, metrics, A.4.8. Does Bugzilla provide any reporting features, metrics,
graphs, etc? You know, the type of stuff that management graphs, etc? You know, the type of stuff that management
likes to see. :) likes to see. :)
A.4.9. Is there email notification and if so, what do you see A.4.9. Is there email notification and if so, what do you see
when you get an email? Do you see bug number and title or when you get an email? Do you see bug number and title or
is it only the number? is it only the number?
A.4.10. Can email notification be set up to send to multiple A.4.10. Can email notification be set up to send to multiple
people, some on the To List, CC List, BCC List etc? people, some on the To List, CC List, BCC List etc?
A.4.11. If there is email notification, do users have to have any A.4.11. If there is email notification, do users have to have any
particular type of email application? particular type of email application?
A.4.12. If I just wanted to track certain bugs, as they go A.4.12. If I just wanted to track certain bugs, as they go
through life, can I set it up to alert me via email through life, can I set it up to alert me via email
whenever that bug changes, whether it be owner, status or whenever that bug changes, whether it be owner, status or
description etc.? description etc.?
A.4.13. Does Bugzilla allow data to be imported and exported? If A.4.13. Does Bugzilla allow data to be imported and exported? If
I had outsiders write up a bug report using a MS Word bug I had outsiders write up a bug report using a MS Word bug
template, could that template be imported into "matching" template, could that template be imported into "matching"
fields? If I wanted to take the results of a query and fields? If I wanted to take the results of a query and
export that data to MS Excel, could I do that? export that data to MS Excel, could I do that?
A.4.14. Has anyone converted Bugzilla to another language to be A.4.14. Has anyone converted Bugzilla to another language to be
used in other countries? Is it localizable? used in other countries? Is it localizable?
A.4.15. Can a user create and save reports? Can they do this in A.4.15. Can a user create and save reports? Can they do this in
Word format? Excel format? Word format? Excel format?
A.4.16. Can a user re-run a report with a new project, same A.4.16. Can a user re-run a report with a new project, same
query? query?
A.4.17. Can a user modify an existing report and then save it A.4.17. Can a user modify an existing report and then save it
into another name? into another name?
A.4.18. Does Bugzilla have the ability to search by word, phrase, A.4.18. Does Bugzilla have the ability to search by word, phrase,
compound search? compound search?
A.4.19. Can the admin person establish separate group and A.4.19. Can the admin person establish separate group and
individual user privileges? individual user privileges?
A.4.20. Does Bugzilla provide record locking when there is A.4.20. Does Bugzilla provide record locking when there is
simultaneous access to the same bug? Does the second simultaneous access to the same bug? Does the second
person get a notice that the bug is in use or how are person get a notice that the bug is in use or how are
they notified? they notified?
A.4.21. Are there any backup features provided? A.4.21. Are there any backup features provided?
A.4.22. Can users be on the system while a backup is in progress? A.4.22. Can users be on the system while a backup is in progress?
A.4.23. What type of human resources are needed to be on staff to A.4.23. What type of human resources are needed to be on staff to
install and maintain Bugzilla? Specifically, what type of install and maintain Bugzilla? Specifically, what type of
skills does the person need to have? I need to find out skills does the person need to have? I need to find out
if we were to go with Bugzilla, what types of individuals if we were to go with Bugzilla, what types of individuals
would we need to hire and how much would that cost vs would we need to hire and how much would that cost vs
buying an "Out-of-the-Box" solution. buying an "Out-of-the-Box" solution.
A.4.24. What time frame are we looking at if we decide to hire A.4.24. What time frame are we looking at if we decide to hire
people to install and maintain the Bugzilla? Is this people to install and maintain the Bugzilla? Is this
something that takes hours or weeks to install and a something that takes hours or weeks to install and a
couple of hours per week to maintain and customize or is couple of hours per week to maintain and customize or is
this a multi-week install process, plus a full time job this a multi-week install process, plus a full time job
for 1 person, 2 people, etc? for 1 person, 2 people, etc?
A.4.25. Is there any licensing fee or other fees for using A.4.25. Is there any licensing fee or other fees for using
Bugzilla? Any out-of-pocket cost other than the bodies Bugzilla? Any out-of-pocket cost other than the bodies
needed as identified above? needed as identified above?
5. Bugzilla Installation 5. Bugzilla Installation
A.5.1. How do I download and install Bugzilla? A.5.1. How do I download and install Bugzilla?
A.5.2. How do I install Bugzilla on Windows NT? A.5.2. How do I install Bugzilla on Windows NT?
A.5.3. Is there an easy way to change the Bugzilla cookie name? A.5.3. Is there an easy way to change the Bugzilla cookie name?
6. Bugzilla Security 6. Bugzilla Security
A.6.1. How do I completely disable MySQL security if it's giving A.6.1. How do I completely disable MySQL security if it's giving
me problems (I've followed the instructions in the me problems (I've followed the instructions in the
installation section of this guide!)? installation section of this guide!)?
A.6.2. Are there any security problems with Bugzilla? A.6.2. Are there any security problems with Bugzilla?
A.6.3. I've implemented the security fixes mentioned in Chris A.6.3. I've implemented the security fixes mentioned in Chris
Yeh's security advisory of 5/10/2000 advising not to run Yeh's security advisory of 5/10/2000 advising not to run
MySQL as root, and am running into problems with MySQL no MySQL as root, and am running into problems with MySQL no
longer working correctly. longer working correctly.
7. Bugzilla Email 7. Bugzilla Email
A.7.1. I have a user who doesn't want to receive any more email A.7.1. I have a user who doesn't want to receive any more email
from Bugzilla. How do I stop it entirely for this user? from Bugzilla. How do I stop it entirely for this user?
A.7.2. I'm evaluating/testing Bugzilla, and don't want it to send A.7.2. I'm evaluating/testing Bugzilla, and don't want it to send
email to anyone but me. How do I do it? email to anyone but me. How do I do it?
A.7.3. I want whineatnews.pl to whine at something more, or other A.7.3. I want whineatnews.pl to whine at something more, or other
than, only new bugs. How do I do it? than, only new bugs. How do I do it?
A.7.4. I don't like/want to use Procmail to hand mail off to A.7.4. I don't like/want to use Procmail to hand mail off to
bug_email.pl. What alternatives do I have? bug_email.pl. What alternatives do I have?
A.7.5. How do I set up the email interface to submit/change bugs A.7.5. How do I set up the email interface to submit/change bugs
via email? via email?
A.7.6. Email takes FOREVER to reach me from bugzilla -- it's A.7.6. Email takes FOREVER to reach me from bugzilla -- it's
extremely slow. What gives? extremely slow. What gives?
A.7.7. How come email never reaches me from bugzilla changes? A.7.7. How come email never reaches me from bugzilla changes?
8. Bugzilla Database 8. Bugzilla Database
A.8.1. I've heard Bugzilla can be used with Oracle? A.8.1. I've heard Bugzilla can be used with Oracle?
A.8.2. Bugs are missing from queries, but exist in the database A.8.2. Bugs are missing from queries, but exist in the database
(and I can pull them up by specifying the bug ID). What's (and I can pull them up by specifying the bug ID). What's
wrong? wrong?
A.8.3. I think my database might be corrupted, or contain invalid A.8.3. I think my database might be corrupted, or contain invalid
entries. What do I do? entries. What do I do?
A.8.4. I want to manually edit some entries in my database. How? A.8.4. I want to manually edit some entries in my database. How?
A.8.5. I try to add myself as a user, but Bugzilla always tells A.8.5. I try to add myself as a user, but Bugzilla always tells
me my password is wrong. me my password is wrong.
A.8.6. I think I've set up MySQL permissions correctly, but A.8.6. I think I've set up MySQL permissions correctly, but
bugzilla still can't connect. bugzilla still can't connect.
A.8.7. How do I synchronize bug information among multiple A.8.7. How do I synchronize bug information among multiple
different Bugzilla databases? different Bugzilla databases?
A.8.8. Why do I get bizarre errors when trying to submit data, A.8.8. Why do I get bizarre errors when trying to submit data,
particularly problems with "groupset"? particularly problems with "groupset"?
A.8.9. How come even after I delete bugs, the long descriptions A.8.9. How come even after I delete bugs, the long descriptions
show up? show up?
9. Bugzilla and Win32 9. Bugzilla and Win32
A.9.1. What is the easiest way to run Bugzilla on Win32 A.9.1. What is the easiest way to run Bugzilla on Win32
(Win98+/NT/2K)? (Win98+/NT/2K)?
A.9.2. Is there a "Bundle::Bugzilla" equivalent for Win32? A.9.2. Is there a "Bundle::Bugzilla" equivalent for Win32?
A.9.3. CGI's are failing with a "something.cgi is not a valid A.9.3. CGI's are failing with a "something.cgi is not a valid
Windows NT application" error. Why? Windows NT application" error. Why?
A.9.4. Can I have some general instructions on how to make A.9.4. Can I have some general instructions on how to make
Bugzilla on Win32 work? Bugzilla on Win32 work?
A.9.5. I'm having trouble with the perl modules for NT not being A.9.5. I'm having trouble with the perl modules for NT not being
able to talk to to the database. able to talk to to the database.
10. Bugzilla Usage 10. Bugzilla Usage
A.10.1. The query page is very confusing. Isn't there a simpler A.10.1. The query page is very confusing. Isn't there a simpler
way to query? way to query?
A.10.2. I'm confused by the behavior of the "accept" button in A.10.2. I'm confused by the behavior of the "accept" button in
the Show Bug form. Why doesn't it assign the bug to me the Show Bug form. Why doesn't it assign the bug to me
when I accept it? when I accept it?
A.10.3. I can't upload anything into the database via the "Create A.10.3. I can't upload anything into the database via the "Create
Attachment" link. What am I doing wrong? Attachment" link. What am I doing wrong?
A.10.4. Email submissions to Bugzilla that have attachments end A.10.4. Email submissions to Bugzilla that have attachments end
up asking me to save it as a "cgi" file. up asking me to save it as a "cgi" file.
A.10.5. How do I change a keyword in Bugzilla, once some bugs are A.10.5. How do I change a keyword in Bugzilla, once some bugs are
using it? using it?
11. Bugzilla Hacking 11. Bugzilla Hacking
A.11.1. What bugs are in Bugzilla right now? A.11.1. What bugs are in Bugzilla right now?
A.11.2. How can I change the default priority to a null value? A.11.2. How can I change the default priority to a null value?
For instance, have the default priority be "---" instead For instance, have the default priority be "---" instead
of "P2"? of "P2"?
A.11.3. What's the best way to submit patches? What guidelines A.11.3. What's the best way to submit patches? What guidelines
should I follow? should I follow?
1. General Questions 1. General Questions
...@@ -4172,7 +4177,7 @@ Appendix A. The Bugzilla FAQ ...@@ -4172,7 +4177,7 @@ Appendix A. The Bugzilla FAQ
A.1.5. Who maintains Bugzilla? A.1.5. Who maintains Bugzilla?
Bugzilla maintenance has been in a state of flux recently. Please Bugzilla maintenance has been in a state of flux recently. Please
check the Bugzilla Project Page for the latest details. check the Bugzilla Project Page for the latest details.
A.1.6. How does Bugzilla stack up against other bug-tracking A.1.6. How does Bugzilla stack up against other bug-tracking
databases? databases?
...@@ -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 --
{
print "The variable is true"; if ($var)
} {
else print "The variable is true";
{ }
print "Try again"; else
} {
3. File Names print "Try again";
File names for bugzilla code and support documention should be leg }
al across
multiple platforms. \ / : * ? " < > and | are all illegal charact
ers for * File Names
filenames on various platforms. Also, file names should not have File names for bugzilla code and support documention should be
spaces in legal across multiple platforms. \ / : * ? " < > and | are all
them as they can cause confusion in CVS and other mozilla.org util illegal characters for filenames on various platforms. Also, file
ities. names should not have spaces in them as they can cause confusion
4. Variable Names in CVS and other mozilla.org utilities.
* 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
expression unless that variable is supposed to contain an expression.
It is very important that you don't use a variable in a regular This especially applies when using grep. You should use:
expression unless that variable is supposed to contain an expression. </para>
This especially applies when using grep. You should use: <para>
<programlisting>
grep ($_ eq $value, @array); grep ($_ eq $value, @array);
</programlisting>
- NOT - </para>
<para>
grep (/$value/, @array); -- NOT THIS --
</para>
If you need to use a non-expression variable inside of an expression, be <para>
sure to quote it properly (using \Q..\E). <programlisting>
grep (/$value/, @array);
Coding Style for Bugzilla </programlisting>
------------------------- </para>
<note>
While it's true that not all of the code currently in Bugzilla adheres to <para>
this styleguide, it is something that is being worked toward. Therefore, If you need to use a non-expression variable inside of an expression, be
we ask that all new code (submitted patches and new files) follow this guide sure to quote it properly (using <function>\Q..\E</function>).
as closely as possible (if you're only changing 1 or 2 lines, you don't have </para>
to reformat the entire file :). </note>
</listitem>
1. Whitespace </orderedlist>
</section>
Bugzilla's prefered indentation is 4 spaces (no tabs, please). <section>
<title>Coding Style for Bugzilla</title>
2. Curly braces. <para>
While it's true that not all of the code currently in Bugzilla adheres to
The opening brace of a block should be on the same line as the statement this (or any) styleguide, it is something that is being worked toward. Therefore,
that is causing the block and the closing brace should be at the same we ask that all new code (submitted patches and new files) follow this guide
indentation level as that statement, for example: as closely as possible (if you're only changing 1 or 2 lines, you don't have
to reformat the entire file :).
if ($var) { </para>
print "The variable is true"; <para>
} The Bugzilla development team has decided to adopt the perl style guide as
else { published by Larry Wall. This giude can be found in <quote>Programming
print "Try again"; Perl</quote> (the camel book) or by typing <command>man perlstyle</command> at
} your favorite shell prompt.
</para>
- NOT - <para>
What appears below if a brief summary, please refer to the perl style
if ($var) guide if you don't see your question covered here.
{ </para>
print "The variable is true"; <itemizedlist>
} <listitem>
else <para>
{ Whitespace
print "Try again"; </para>
} <para>
Bugzilla's prefered indentation is 4 spaces (no tabs, please).
3. File Names </para>
</listitem>
File names for bugzilla code and support documention should be legal across <listitem>
multiple platforms. \ / : * ? " < > and | are all illegal characters for <para>
filenames on various platforms. Also, file names should not have spaces in Curly braces.
them as they can cause confusion in CVS and other mozilla.org utilities. </para>
<para>
4. Variable Names 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
If a variable is scoped globally ($::variable) its name should be descriptive indentation level as that statement, for example:
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 <para>
staging variable for a routine's return value as the line |return $ret;| will <programlisting>
make it blatently obvious what the variable holds and most likely be shown if ($var) {
on the same screen as |my $ret = "";|. print "The variable is true";
}
5. Cross Database Compatability else {
print "Try again";
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 </programlisting>
should be avoided in all new code. Examples of these features are enums and </para>
encrypt(). <para>
-- NOT THIS --
6. Cross Platform Compatability </para>
<para>
While Bugzilla was written to be used on Unix based systems (and Unix/Linux is <programlisting>
still the only officially supported platform) there are many who desire/need to if ($var)
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 print "The variable is true";
that break Bugzilla's ability to run on multiple operating systems. }
else
</literallayout> {
print "Try again";
}
</programlisting>
</para>
</listitem>
<listitem>
<para>
File Names
</para>
<para>
File names for bugzilla code and support documention should be legal across
multiple platforms. <computeroutput>\ / : * ? &quot; &lt; &gt;</computeroutput>
and <computeroutput>|</computeroutput> 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.
</para>
</listitem>
<listitem>
<para>
Variable Names
</para>
<para>
If a variable is scoped globally (<computeroutput>$::variable</computeroutput>)
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,
<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
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
<function>encrypt()</function>.
</para>
</listitem>
<listitem>
<para>
Cross Platform Compatability
</para>
<para>
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.
</para>
</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