Skip to content

Commit

Permalink
Qual: Optimize PHP Code sniffer rules
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Aug 28, 2011
1 parent 69892ec commit 76a6d6a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
8 changes: 7 additions & 1 deletion dev/codesniffer/ruleset.xml
Expand Up @@ -33,7 +33,7 @@
<!-- Lines can be 85 chars long, but never show errors -->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="320" />
<property name="lineLimit" value="1000" />
<property name="absoluteLineLimit" value="0" />
</properties>
</rule>
Expand Down Expand Up @@ -169,8 +169,14 @@
<rule ref="PEAR.Functions.ValidDefaultValue" />

<rule ref="PEAR.NamingConventions.ValidClassName" />
<rule ref="PEAR.NamingConventions.ValidClassName.StartWithCaptial">
<severity>0</severity>
</rule>

<rule ref="PEAR.NamingConventions.ValidFunctionName" />
<rule ref="PEAR.NamingConventions.ValidFunctionName.NotCamelCaps">
<severity>0</severity>
</rule>

<rule ref="PEAR.NamingConventions.ValidFunctionName.FunctionNoCaptial">
<severity>0</severity>
Expand Down
16 changes: 8 additions & 8 deletions dev/skeletons/build_class_from_table.php
Expand Up @@ -151,7 +151,7 @@
$targetcontent=preg_replace('/skeleton_class\.class\.php/', $classmin.'.class.php', $targetcontent);
$targetcontent=preg_replace('/\$element=\'skeleton\'/', '\$element=\''.$classmin.'\'', $targetcontent);
$targetcontent=preg_replace('/\$table_element=\'skeleton\'/', '\$table_element=\''.$classmin.'\'', $targetcontent);
$targetcontent=preg_replace('/Skeleton_class/', $classname, $targetcontent);
$targetcontent=preg_replace('/Skeleton_Class/', $classname, $targetcontent);

// Substitute comments
$targetcontent=preg_replace('/This file is an example to create a new class file/', 'Put here description of this class', $targetcontent);
Expand Down Expand Up @@ -206,7 +206,7 @@
if ($addfield)
{
$varprop.="\t\t\$sql.= \"".$prop['field'];
if ($i < sizeof($property)) $varprop.=",";
if ($i < count($property)) $varprop.=",";
$varprop.="\";";
$varprop.="\n";
}
Expand All @@ -233,23 +233,23 @@
$varprop.='".(! isset($this->'.$prop['field'].') || dol_strlen($this->'.$prop['field'].')==0?\'NULL\':$this->db->idate(';
$varprop.="\$this->".$prop['field']."";
$varprop.='))."';
if ($i < sizeof($property)) $varprop.=",";
if ($i < count($property)) $varprop.=",";
$varprop.="\";";
}
elseif ($prop['ischar'])
{
$varprop.='".(! isset($this->'.$prop['field'].')?\'NULL\':"\'".';
$varprop.='$this->db->escape($this->'.$prop['field'].')';
$varprop.='."\'")."';
if ($i < sizeof($property)) $varprop.=",";
if ($i < count($property)) $varprop.=",";
$varprop.='";';
}
else
{
$varprop.='".(! isset($this->'.$prop['field'].')?\'NULL\':"\'".';
$varprop.="\$this->".$prop['field']."";
$varprop.='."\'")."';
if ($i < sizeof($property)) $varprop.=",";
if ($i < count($property)) $varprop.=",";
$varprop.='";';
}
$varprop.="\n";
Expand Down Expand Up @@ -287,7 +287,7 @@
$varprop.=".\"";
}

if ($i < sizeof($property)) $varprop.=',';
if ($i < count($property)) $varprop.=',';
$varprop.='";';
$varprop.="\n";
}
Expand All @@ -306,7 +306,7 @@
{
$varprop.="\t\t\$sql.= \" ";
$varprop.="t.".$prop['field'];
if ($i < sizeof($property)) $varprop.=",";
if ($i < count($property)) $varprop.=",";
$varprop.="\";";
$varprop.="\n";
}
Expand Down Expand Up @@ -385,7 +385,7 @@
$targetcontent=preg_replace('/skeleton_script\.php/', $classmin.'_script.php', $targetcontent);
$targetcontent=preg_replace('/\$element=\'skeleton\'/', '\$element=\''.$classmin.'\'', $targetcontent);
$targetcontent=preg_replace('/\$table_element=\'skeleton\'/', '\$table_element=\''.$classmin.'\'', $targetcontent);
$targetcontent=preg_replace('/Skeleton_class/', $classname, $targetcontent);
$targetcontent=preg_replace('/Skeleton_Class/', $classname, $targetcontent);

// Substitute comments
$targetcontent=preg_replace('/This file is an example to create a new class file/', 'Put here description of this class', $targetcontent);
Expand Down
24 changes: 14 additions & 10 deletions dev/skeletons/modMyModule.class.php
@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -38,8 +38,9 @@
class modMyModule extends DolibarrModules
{
/**
* \brief Constructor. Define names, constants, directories, boxes, permissions
* \param DB Database handler
* Constructor. Define names, constants, directories, boxes, permissions
*
* @param DoliDB $DB Database handler
*/
function modMyModule($DB)
{
Expand Down Expand Up @@ -232,7 +233,8 @@ function modMyModule($DB)
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories.
* It also creates data directories
*
* @return int 1 if OK, 0 if KO
*/
function init()
Expand All @@ -247,7 +249,8 @@ function init()
/**
* Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted.
* Data directories are not deleted
*
* @return int 1 if OK, 0 if KO
*/
function remove()
Expand All @@ -259,11 +262,12 @@ function remove()


/**
* \brief Create tables, keys and data required by module
* Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys
* and create data commands must be stored in directory /mymodule/sql/
* This function is called by this->init.
* \return int <=0 if KO, >0 if OK
* Create tables, keys and data required by module
* Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys
* and create data commands must be stored in directory /mymodule/sql/
* This function is called by this->init
*
* @return int <=0 if KO, >0 if OK
*/
function load_tables()
{
Expand Down
2 changes: 1 addition & 1 deletion dev/skeletons/skeleton_class.class.php
Expand Up @@ -31,7 +31,7 @@


/**
* \class Skeleton_class
* \class Skeleton_Class
* \brief Put here description of your class
* \remarks Put here some comments
*/
Expand Down

0 comments on commit 76a6d6a

Please sign in to comment.