Qual: Normalize code

This commit is contained in:
Laurent Destailleur 2010-07-21 17:14:45 +00:00
parent 3d14382d4c
commit 3388764b14
11 changed files with 107 additions and 89 deletions

View File

@ -20,8 +20,14 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.php.core.PHPNature</nature> <nature>org.eclipse.php.core.PHPNature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

View File

@ -1,8 +1,8 @@
#Thu Jun 24 20:12:23 CEST 2010 #Wed Jul 21 18:10:37 CEST 2010
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.php.debug.core.use-project-settings=true org.eclipse.php.debug.core.use-project-settings=true
org.eclipse.php.debug.coredefaultPHP=PHP Wamp 5.2.8 org.eclipse.php.debug.coredefaultPHP=PHP Wamp 5.3.0
org.eclipse.php.debug.coreoutput_encoding= org.eclipse.php.debug.coreoutput_encoding=UTF-8
org.eclipse.php.debug.corephp_debugger_id=org.eclipse.php.debug.core.xdebugDebugger org.eclipse.php.debug.corephp_debugger_id=org.eclipse.php.debug.core.xdebugDebugger
org.eclipse.php.debug.corestop_at_first_line_string=true org.eclipse.php.debug.corestop_at_first_line_string=true
org.eclipse.php.debug.coretransfer_encoding= org.eclipse.php.debug.coretransfer_encoding=UTF-8

View File

@ -14,3 +14,8 @@ Choose a PHP version,
Set parameter string with Set parameter string with
--src %f --config "phpstandard.cfg.xml" --format console --src %f --config "phpstandard.cfg.xml" --format console
Choose php as Filename extension Choose php as Filename extension
Check Print PHP output to console
Then add patern
* %f INFO Line:%n - %m Warning
* %f WARNING Line:%n - %m Warning
* %f ERROR Line:%n - %m Error

View File

@ -1,18 +1,20 @@
<!-- somewhat inspired by java checkstyle --> <!-- somewhat inspired by java checkstyle -->
<phpcheckstyle-configuration> <phpcheckstyle-configuration>
<!-- **************** --> <!-- **************** -->
<!-- Naming --> <!-- Naming -->
<!-- **************** --> <!-- **************** -->
<!-- Check Constant Naming --> <!-- Check Constant Naming -->
<!-- Disabled to avoid warning with $sql="SELECT ..."
<test name="constantNaming" regexp="/^[A-Z_][A-Z_]*[A-Z_]$/" level="ERROR"/> <test name="constantNaming" regexp="/^[A-Z_][A-Z_]*[A-Z_]$/" level="ERROR"/>
-->
<!-- Check Variable Naming --> <!-- Check Variable Naming -->
<test name="variableNaming" regexp="/^[a-z_][a-zA-Z0-9]*$/" /> <test name="variableNaming" regexp="/^[a-z_][a-zA-Z0-9]*$/" />
<!-- Check Function Naming --> <!-- Check Function Naming -->
<test name="functionNaming" regexp="/^[a-z]/" level="ERROR"/> <test name="functionNaming" regexp="/^[a-z_]/" level="ERROR"/>
<!-- Check Private Function Naming --> <!-- Check Private Function Naming -->
<test name="privateFunctionNaming" regexp="/^_[a-z]/" level="ERROR"/> <test name="privateFunctionNaming" regexp="/^_[a-z]/" level="ERROR"/>
@ -28,7 +30,7 @@
<test name="classNaming" regexp="/^[A-Z]/" level="ERROR"/> <test name="classNaming" regexp="/^[A-Z]/" level="ERROR"/>
<!-- **************** --> <!-- **************** -->
<!-- PHP Tags --> <!-- PHP Tags -->
<!-- **************** --> <!-- **************** -->
@ -37,7 +39,7 @@
<test name="noShortPhpCodeTag"/> <test name="noShortPhpCodeTag"/>
<!-- Test if a PHP closing file is present at the end of a file --> <!-- Test if a PHP closing file is present at the end of a file -->
<test name="noFileCloseTag"/> <!-- <test name="noFileCloseTag"/> -->
<!-- Test if a file finish with some inner HTML (OK for some view but could provoque "header already sent" error) --> <!-- Test if a file finish with some inner HTML (OK for some view but could provoque "header already sent" error) -->
<test name="noFileFinishHTML" level="ERROR" /> <test name="noFileFinishHTML" level="ERROR" />
@ -47,7 +49,7 @@
<!-- Comments --> <!-- Comments -->
<!-- **************** --> <!-- **************** -->
<!-- Check if some C style comments are used (#) --> <!-- Check if some C style comments are used (#) -->
<test name="noShellComments"/> <test name="noShellComments"/>
<!-- Tests that every function and class is immediately preceded by a docblock. A property "excludePrivateMembers" can be set if you want to disable docblocks for private member functions. --> <!-- Tests that every function and class is immediately preceded by a docblock. A property "excludePrivateMembers" can be set if you want to disable docblocks for private member functions. -->
@ -72,7 +74,7 @@
<!-- sl = same line --> <!-- sl = same line -->
<!-- nl = new line --> <!-- nl = new line -->
<test name="controlStructOpenCurly"> <test name="controlStructOpenCurly">
<property name="position" value="sl"/> <property name="position" value="nl"/>
</test> </test>
<!-- Check the position of the close curly brace --> <!-- Check the position of the close curly brace -->
@ -82,18 +84,16 @@
<!-- Check the position of the open curly brace after a function --> <!-- Check the position of the open curly brace after a function -->
<!-- sl = same line --> <!-- sl = same line -->
<!-- nl = new line --> <!-- nl = new line -->
<!--
<test name="funcDefinitionOpenCurly"> <test name="funcDefinitionOpenCurly">
<property name="position" value="sl"/> <property name="position" value="nl"/>
</test> </test>
-->
<!-- Check the position of the else --> <!-- Check the position of the else -->
<!-- sl = same line --> <!-- sl = same line -->
<!-- nl = new line --> <!-- nl = new line -->
<test name="controlStructElse"> <test name="controlStructElse">
<property name="position" value="nl"/> <property name="position" value="nl"/>
</test> </test>
<!-- **************** --> <!-- **************** -->
@ -111,24 +111,31 @@
<!-- Check for the (required) presence of a white space after some tokens (like ,) --> <!-- Check for the (required) presence of a white space after some tokens (like ,) -->
<!--
<test name="checkWhiteSpaceAfter"> <test name="checkWhiteSpaceAfter">
<exception value="."/> <!-- Exceptions to this rule --> <exception value="."/>
</test> </test>
-->
<!-- Check for the (required) presence of a white space before some tokens --> <!-- Check for the (required) presence of a white space before some tokens -->
<!--
<test name="checkWhiteSpaceBefore"> <test name="checkWhiteSpaceBefore">
<exception value="."/> <!-- Exceptions to this rule --> <exception value="."/>
<exception value=":"/> <!-- Because of the switch/case --> <exception value=":"/>
</test> </test>
-->
<!-- Check that there is no space before before some tokens --> <!-- Check that there is no space before before some tokens -->
<!--
<test name="noSpaceBeforeToken" level="INFO"> <test name="noSpaceBeforeToken" level="INFO">
</test> </test>
-->
<!-- Check that there is no space after some tokens --> <!-- Check that there is no space after some tokens -->
<!--
<test name="noSpaceAfterToken" level="INFO"> <test name="noSpaceAfterToken" level="INFO">
</test> </test>
-->
<!-- **************** --> <!-- **************** -->
<!-- Metrics --> <!-- Metrics -->
@ -150,8 +157,8 @@
</test> --> </test> -->
<!-- Check Cyclomatic Complexity --> <!-- Check Cyclomatic Complexity -->
<!-- see http://www.aivosto.com/project/help/pm-complexity.html --> <!-- see http://www.aivosto.com/project/help/pm-complexity.html -->
<test name="cyclomaticComplexity"> <test name="cyclomaticComplexity">
<!-- Level raising a warning --> <!-- Level raising a warning -->
<property name="warningLevel" value="10"/> <property name="warningLevel" value="10"/>
<!-- Level raising an error --> <!-- Level raising an error -->
@ -168,50 +175,50 @@
<!-- Check for prohibited functions --> <!-- Check for prohibited functions -->
<!-- @see http://www.php.net/manual/en/indexes.php --> <!-- @see http://www.php.net/manual/en/indexes.php -->
<test name="checkProhibitedFunctions"> <test name="checkProhibitedFunctions">
<item value="echo"/> <item value="echo"/>
<item value="system"/> <item value="system"/>
<item value="print_r"/> <item value="print_r"/>
<item value="var_dump"/> <item value="var_dump"/>
<item value="dl"/> <item value="dl"/>
<item value="exec"/> <!--<item value="exec"/>-->
<item value="passthru"/> <item value="passthru"/>
<item value="delete"/> <!-- <item value="delete"/> We disable because of false report when using method delete -->
<item value="ereg_replace"/> <item value="ereg_replace"/>
<item value="ereg"/> <item value="ereg"/>
<item value="eregi"/> <item value="eregi"/>
<!-- <item value="copy"/> --> <!-- <item value="copy"/> -->
<!-- <item value="fwrite"/> --> <!-- <item value="fwrite"/> -->
</test> </test>
<!-- Check for prohibited tokens --> <!-- Check for prohibited tokens -->
<!-- @see http://www.php.net/manual/en/tokens.php --> <!-- @see http://www.php.net/manual/en/tokens.php -->
<test name="checkProhibitedTokens"> <test name="checkProhibitedTokens">
<item value="T_BAD_CHARACTER"/> <item value="T_BAD_CHARACTER"/>
<item value="T_DECLARE"/> <item value="T_DECLARE"/>
<item value="T_ENDDECLARE"/> <item value="T_ENDDECLARE"/>
<item value="T_ENDFOR"/> <item value="T_ENDFOR"/>
<item value="T_ENDFOREACH"/> <item value="T_ENDFOREACH"/>
<item value="T_ENDIF"/> <item value="T_ENDIF"/>
<item value="T_ENDSWITCH"/> <item value="T_ENDSWITCH"/>
<item value="T_ENDWHILE"/> <item value="T_ENDWHILE"/>
<item value="T_HALT_COMPILER"/> <item value="T_HALT_COMPILER"/>
<item value="T_OLD_FUNCTION"/> <item value="T_OLD_FUNCTION"/>
<item value="T_PRINT"/> <!-- <item value="T_PRINT"/> -->
<!-- Same thing as the noShortPhpCodeTag rule --> <!-- Same thing as the noShortPhpCodeTag rule -->
<!-- <item value="T_OPEN_TAG_WITH_ECHO"/> --> <!-- <item value="T_OPEN_TAG_WITH_ECHO"/> -->
<!-- <item value="T_INLINE_HTML"/> --> <!-- <item value="T_INLINE_HTML"/> -->
<!-- <item value="T_ECHO"/> --> <!-- <item value="T_ECHO"/> -->
</test> </test>
<!-- Check for silenced errors before function calls (@function) --> <!-- Check for silenced errors before function calls (@function) -->
<test name="checkSilencedError"> <test name="checkSilencedError">
<exception value="rename"/> <!-- Exceptions to this rule --> <exception value="rename"/> <!-- Exceptions to this rule -->
<exception value="mkdir"/> <exception value="mkdir"/>
<exception value="chmod"/> <exception value="chmod"/>
</test> </test>
<!-- Check for encapsed variables inside a String ("$a") --> <!-- Check for encapsed variables inside a String ("$a") -->
@ -231,7 +238,7 @@
<!-- Check empty block like if ($a) {} --> <!-- Check empty block like if ($a) {} -->
<test name="checkEmptyBlock"> <test name="checkEmptyBlock">
<!-- <exception value="catch"/> --> <!-- <exception value="catch"/> -->
</test> </test>
<!-- Check empty statement ( ;; ) --> <!-- Check empty statement ( ;; ) -->
@ -264,7 +271,7 @@
With the exception of for iterators, all variable incrementation or decrementation should occur in their own toplevel statement to increase readability. With the exception of for iterators, all variable incrementation or decrementation should occur in their own toplevel statement to increase readability.
--> -->
<test name="checkUnaryOperator"> <test name="checkUnaryOperator">
<exception value="for"/> <exception value="for"/>
</test> </test>
<!-- <!--
@ -272,7 +279,7 @@
With the exception of for iterators, all assignments should occur in their own toplevel statement to increase readability. With the exception of for iterators, all assignments should occur in their own toplevel statement to increase readability.
--> -->
<test name="checkInnerAssignment"> <test name="checkInnerAssignment">
<exception value="for"/> <exception value="for"/>
</test> </test>
<!-- Detect unused private functions (detecting unused public ones is more difficult) --> <!-- Detect unused private functions (detecting unused public ones is more difficult) -->

View File

@ -20,7 +20,7 @@
*/ */
/** /**
* \file htdocs/compta/export/class/ComptaJournalPaiement.php * \file htdocs/compta/export/class/ComptaJournalPaiement.class.php
* \ingroup compta * \ingroup compta
* \brief Fichier de la classe export compta journal * \brief Fichier de la classe export compta journal
* \version $Id$ * \version $Id$
@ -40,7 +40,7 @@ class ComptaJournalPaiement
$this->db = $db; $this->db = $db;
} }
function GeneratePdf($user, $dir, $excid, $excref) function generatePdf($user, $dir, $excid, $excref)
{ {
global $conf,$langs; global $conf,$langs;

View File

@ -18,7 +18,7 @@
*/ */
/** /**
* \file htdocs/compta/export/class/ComptaJournalPdf.php * \file htdocs/compta/export/class/ComptaJournalPdf.class.php
* \ingroup compta * \ingroup compta
* \brief Fichier de la classe export compta journal * \brief Fichier de la classe export compta journal
* \version $Id$ * \version $Id$

View File

@ -19,7 +19,7 @@
*/ */
/** /**
\file htdocs/compta/export/classComptaJournalVente.php \file htdocs/compta/export/class/ComptaJournalVente.class.php
\ingroup compta \ingroup compta
\brief Fichier de la classe export compta journal \brief Fichier de la classe export compta journal
\version $Id$ \version $Id$
@ -40,7 +40,7 @@ class ComptaJournalVente {
} }
function GeneratePdf($user, $dir, $excid, $excref) function generatePdf($user, $dir, $excid, $excref)
{ {
global $conf, $langs; global $conf, $langs;

View File

@ -72,12 +72,12 @@ if ($_GET["action"] == 'export')
/* G<>n<EFBFBD>ration du journal des Paiements */ /* G<>n<EFBFBD>ration du journal des Paiements */
$jp= new ComptaJournalPaiement($db); $jp= new ComptaJournalPaiement($db);
$jp->GeneratePdf($user, $dir, $exc->id, $exc->ref); $jp->generatePdf($user, $dir, $exc->id, $exc->ref);
/* G<>n<EFBFBD>ration du journal des Ventes */ /* G<>n<EFBFBD>ration du journal des Ventes */
$jp= new ComptaJournalVente($db); $jp= new ComptaJournalVente($db);
$jp->GeneratePdf($user, $dir, $exc->id, $exc->ref); $jp->generatePdf($user, $dir, $exc->id, $exc->ref);
} }
/* /*

View File

@ -62,7 +62,7 @@ class RemiseCheque extends CommonObject
* \param ref Ref record * \param ref Ref record
* \return int <0 if KO, >= 0 if OK * \return int <0 if KO, >= 0 if OK
*/ */
function Fetch($id,$ref='') function fetch($id,$ref='')
{ {
global $conf; global $conf;
@ -117,7 +117,7 @@ class RemiseCheque extends CommonObject
* \param account_id Compte bancaire concerne * \param account_id Compte bancaire concerne
* \return int <0 if KO, >0 if OK * \return int <0 if KO, >0 if OK
*/ */
function Create($user, $account_id) function create($user, $account_id)
{ {
global $conf; global $conf;
@ -220,7 +220,7 @@ class RemiseCheque extends CommonObject
if ($this->id > 0 && $this->errno == 0) if ($this->id > 0 && $this->errno == 0)
{ {
if ($this->UpdateAmount() <> 0) if ($this->updateAmount() <> 0)
{ {
$this->errno = -1027; $this->errno = -1027;
dol_syslog("RemiseCheque::Create ERREUR ($this->errno)"); dol_syslog("RemiseCheque::Create ERREUR ($this->errno)");
@ -254,7 +254,7 @@ class RemiseCheque extends CommonObject
\brief Supprime la remise en base \brief Supprime la remise en base
\param user utilisateur qui effectue l'operation \param user utilisateur qui effectue l'operation
*/ */
function Delete($user='') function delete($user='')
{ {
global $conf; global $conf;
@ -308,7 +308,7 @@ class RemiseCheque extends CommonObject
* \brief Validate receipt * \brief Validate receipt
* \param user User * \param user User
*/ */
function Validate($user) function validate($user)
{ {
global $langs,$conf; global $langs,$conf;
@ -530,7 +530,7 @@ class RemiseCheque extends CommonObject
* \brief Mets a jour le montant total * \brief Mets a jour le montant total
* \return int, 0 en cas de succes * \return int, 0 en cas de succes
*/ */
function UpdateAmount() function updateAmount()
{ {
global $conf; global $conf;
@ -563,13 +563,13 @@ class RemiseCheque extends CommonObject
if (!$resql) if (!$resql)
{ {
$this->errno = -1030; $this->errno = -1030;
dol_syslog("RemiseCheque::UpdateAmount ERREUR UPDATE ($this->errno)"); dol_syslog("RemiseCheque::updateAmount ERREUR UPDATE ($this->errno)");
} }
} }
else else
{ {
$this->errno = -1031; $this->errno = -1031;
dol_syslog("RemiseCheque::UpdateAmount ERREUR SELECT ($this->errno)"); dol_syslog("RemiseCheque::updateAmount ERREUR SELECT ($this->errno)");
} }
if ($this->errno === 0) if ($this->errno === 0)
@ -579,7 +579,7 @@ class RemiseCheque extends CommonObject
else else
{ {
$this->db->rollback(); $this->db->rollback();
dol_syslog("RemiseCheque::UpdateAmount ROLLBACK ($this->errno)"); dol_syslog("RemiseCheque::updateAmount ROLLBACK ($this->errno)");
} }
return $this->errno; return $this->errno;
@ -590,7 +590,7 @@ class RemiseCheque extends CommonObject
\param user utilisateur qui effectue l'operation \param user utilisateur qui effectue l'operation
\param account_id Compte bancaire concerne \param account_id Compte bancaire concerne
*/ */
function RemoveCheck($account_id) function removeCheck($account_id)
{ {
$this->errno = 0; $this->errno = 0;
@ -604,12 +604,12 @@ class RemiseCheque extends CommonObject
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$this->UpdateAmount(); $this->updateAmount();
} }
else else
{ {
$this->errno = -1032; $this->errno = -1032;
dol_syslog("RemiseCheque::RemoveCheck ERREUR UPDATE ($this->errno)"); dol_syslog("RemiseCheque::removeCheck ERREUR UPDATE ($this->errno)");
} }
} }
return 0; return 0;

View File

@ -111,7 +111,7 @@ if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' &&
if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && $user->rights->banque->cheque) if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && $user->rights->banque->cheque)
{ {
$remisecheque = new RemiseCheque($db); $remisecheque = new RemiseCheque($db);
$result = $remisecheque->Fetch($_GET["id"]); $result = $remisecheque->fetch($_GET["id"]);
$result = $remisecheque->Validate($user); $result = $remisecheque->Validate($user);
if ($result >= 0) if ($result >= 0)
{ {
@ -127,7 +127,7 @@ if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' &&
if ($_POST['action'] == 'builddoc' && $user->rights->banque->cheque) if ($_POST['action'] == 'builddoc' && $user->rights->banque->cheque)
{ {
$remisecheque = new RemiseCheque($db); $remisecheque = new RemiseCheque($db);
$result = $remisecheque->Fetch($_GET["id"]); $result = $remisecheque->fetch($_GET["id"]);
/*if ($_REQUEST['model']) /*if ($_REQUEST['model'])
{ {
@ -141,7 +141,7 @@ if ($_POST['action'] == 'builddoc' && $user->rights->banque->cheque)
$outputlangs->setDefaultLang($_REQUEST['lang_id']); $outputlangs->setDefaultLang($_REQUEST['lang_id']);
} }
$result = $remisecheque->GeneratePdf($_POST["model"], $outputlangs); $result = $remisecheque->generatePdf($_POST["model"], $outputlangs);
if ($result <= 0) if ($result <= 0)
{ {
dol_print_error($db,$remisecheque->error); dol_print_error($db,$remisecheque->error);

View File

@ -84,7 +84,7 @@ if ($_POST["action"] == 'infotrans')
if ($_POST["action"] == 'infocredit') if ($_POST["action"] == 'infocredit')
{ {
$bon = new BonPrelevement($db,""); $bon = new BonPrelevement($db,"");
$bon->Fetch($_GET["id"]); $bon->fetch($_GET["id"]);
$dt = mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); $dt = mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
$error = $bon->set_infocredit($user, $dt); $error = $bon->set_infocredit($user, $dt);