mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-03 15:42:29 +01:00
Enable more PHPCS rules
This commit is contained in:
@@ -6,6 +6,10 @@ This directory contains ruleset files to use to develop Dolibarr EPR & CRM.
|
||||
To install/upgrade phpcs:
|
||||
> sudo pear upgrade PHP_CodeSniffer
|
||||
|
||||
To run phpcs:
|
||||
> cd dolibarrgitrepo
|
||||
> phpcs --standard=dev/setup/codesniffer/ruleset.xml --extensions=php --parallel=8 .
|
||||
|
||||
Note with Eclipse: You must setup the PTI plugin of Eclipse into PHPCodeSniffer menu with:
|
||||
* tab value to 4
|
||||
* path of code sniffer standard to dev/codesniffer
|
||||
|
||||
@@ -36,8 +36,6 @@
|
||||
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedElseif"/>
|
||||
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
|
||||
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedForeach"/>
|
||||
<exclude name="Generic.CodeAnalysis.EmptyStatement.NotAllowed"/>
|
||||
<exclude name="Generic.CodeAnalysis.EmptyStatement.NotAllowedWarning"/>
|
||||
</rule>
|
||||
|
||||
<!-- <rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" /> -->
|
||||
@@ -70,9 +68,6 @@
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
|
||||
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
|
||||
<!--
|
||||
<rule ref="Generic.Commenting.Todo" />
|
||||
@@ -141,7 +136,7 @@
|
||||
<!-- Tweaks to metrics -->
|
||||
<rule ref="Generic.Metrics.CyclomaticComplexity">
|
||||
<properties>
|
||||
<property name="complexity" value="120" />
|
||||
<property name="complexity" value="150" />
|
||||
<property name="absoluteComplexity" value="300" />
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
@@ -536,7 +536,7 @@ $errors = $hookmanager->errors;
|
||||
|
||||
|
||||
// Line to enter new values (input fields)
|
||||
print "<tr ".$bcnd[$var].">";
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
@@ -976,12 +976,9 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
|
||||
{
|
||||
global $conf, $langs, $user, $db;
|
||||
global $form;
|
||||
global $region_id;
|
||||
global $elementList, $sourceList, $localtax_typeList;
|
||||
global $bc;
|
||||
global $elementList, $sourceList;
|
||||
|
||||
$formadmin = new FormAdmin($db);
|
||||
$formcompany = new FormCompany($db);
|
||||
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
|
||||
@@ -533,12 +533,9 @@ class SMTPs
|
||||
/**
|
||||
* Now send the message
|
||||
*
|
||||
* @param boolean $_bolTestMsg whether to run this method in 'Test' mode.
|
||||
* @param boolean $_bolDebug whether to log all communication between this Class and the Mail Server.
|
||||
* @return boolean|null void
|
||||
* $_strMsg If this is run in 'Test' mode, the actual message structure will be returned
|
||||
* @return boolean|null Result
|
||||
*/
|
||||
public function sendMsg($_bolTestMsg = false, $_bolDebug = false)
|
||||
public function sendMsg()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
@@ -282,8 +282,9 @@ class modEmailCollector extends DolibarrModules
|
||||
$tmpresql = $this->db->query($tmpsql);
|
||||
if ($tmpresql) {
|
||||
if ($this->db->num_rows($tmpresql) == 0) {
|
||||
$descriptionA1 = 'This collector will scan your mailbox to find emails that match some rules and create automatically a ticket (Module Ticket must be enabled) with the email informations. You can use this collector if you provide some support by email, so your ticket request will be automatically generated. If the collector Collect_Responses is also enabled, when you send an email from the ticket, you may also see answers of your customers or partners directly on the ticket view.';
|
||||
$sqlforexampleA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";
|
||||
$sqlforexampleA1 .= " VALUES (".$conf->entity.", 'Collect_Ticket_Requets', 'Example to collect ticket requests', 'This collector will scan your mailbox to find emails that match some rules and create automatically a ticket (Module Ticket must be enabled) with the email informations. You can use this collector if you provide some support by email, so your ticket request will be automatically generated. If the collector Collect_Responses is also enabled, when you send an email from the ticket, you may also see answers of your customers or partners directly on the ticket view.', 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)";
|
||||
$sqlforexampleA1 .= " VALUES (".$conf->entity.", 'Collect_Ticket_Requets', 'Example to collect ticket requests', $this->db->escape($descriptionA1), 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)";
|
||||
$sqlforexampleA2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";
|
||||
$sqlforexampleA2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requets' and entity = ".$conf->entity."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";
|
||||
$sqlforexampleA3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)";
|
||||
@@ -301,8 +302,9 @@ class modEmailCollector extends DolibarrModules
|
||||
$tmpresql = $this->db->query($tmpsql);
|
||||
if ($tmpresql) {
|
||||
if ($this->db->num_rows($tmpresql) == 0) {
|
||||
$descriptionB1 = 'This collector will scan your mailbox to find all emails that are an answer of an email sent from your application. An event with the email response will be recorded at the good place (Module Agenda must be enabled). For example, if your send a commercial proposal, order or invoice by email and your customer answers your email, the system will automatically find the answer and add it into your ERP.';
|
||||
$sqlforexampleB1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";
|
||||
$sqlforexampleB1 .= " VALUES (".$conf->entity.", 'Collect_Responses', 'Example to collect any email responses', 'This collector will scan your mailbox to find all emails that are an answer of an email sent from your application. An event with the email response will be recorded at the good place (Module Agenda must be enabled). For example, if your send a commercial proposal, order or invoice by email and your customer answers your email, the system will automatically find the answer and add it into your ERP.', 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)";
|
||||
$sqlforexampleB1 .= " VALUES (".$conf->entity.", 'Collect_Responses', 'Example to collect any email responses', $this->db->escape($descriptionB1), 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)";
|
||||
$sqlforexampleB2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";
|
||||
$sqlforexampleB2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses' and entity = ".$conf->entity."), 'withtrackingid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";
|
||||
$sqlforexampleB3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)";
|
||||
@@ -317,8 +319,9 @@ class modEmailCollector extends DolibarrModules
|
||||
$tmpresql = $this->db->query($tmpsql);
|
||||
if ($tmpresql) {
|
||||
if ($this->db->num_rows($tmpresql) == 0) {
|
||||
$descriptionC1 = "This collector will scan your mailbox to find emails that match some rules and create automatically a lead (Module Project must be enabled) with the email informations. You can use this collector if you want to follow your lead using the module Project (1 lead = 1 project), so your leads will be automatically generated. If the collector Collect_Responses is also enabled, when you send an email from your leads, proposals or any other object, you may also see answers of your customers or partners directly on the application.<br>Note: With this initial example, the title of the lead is generated including the email. If the thirdparty can't be found in database (new customer), the lead will be attached to the thirdparty with ID 1.";
|
||||
$sqlforexampleC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";
|
||||
$sqlforexampleC1 .= " VALUES (".$conf->entity.", 'Collect_Leads', 'Example to collect leads', 'This collector will scan your mailbox to find emails that match some rules and create automatically a lead (Module Project must be enabled) with the email informations. You can use this collector if you want to follow your lead using the module Project (1 lead = 1 project), so your leads will be automatically generated. If the collector Collect_Responses is also enabled, when you send an email from your leads, proposals or any other object, you may also see answers of your customers or partners directly on the application.<br>Note: With this initial example, the title of the lead is generated including the email. If the thirdparty can''t be found in database (new customer), the lead will be attached to the thirdparty with ID 1.', 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)";
|
||||
$sqlforexampleC1 .= " VALUES (".$conf->entity.", 'Collect_Leads', 'Example to collect leads',$this->db->escape($descriptionC1), 'INBOX', '".$this->db->idate(dol_now())."', ".$user->id.", 0)";
|
||||
$sqlforexampleC2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";
|
||||
$sqlforexampleC2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".$conf->entity."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".$user->id.", 1)";
|
||||
$sqlforexampleC3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)";
|
||||
|
||||
@@ -135,11 +135,13 @@ class modReceiptPrinter extends DolibarrModules
|
||||
global $conf, $langs;
|
||||
// Clean before activation
|
||||
$this->remove($options);
|
||||
|
||||
$templateexample = '<dol_align_center>\r\n<dol_print_text><dol_value_mysoc_name>\r\n<dol_print_text><dol_value_mysoc_address>\r\n<dol_print_text><dol_value_mysoc_zip><dol_value_mysoc_town>\r\n<dol_line_feed>\r\n<dol_print_text>Facture <dol_value_object_ref>\r\n<dol_line_feed>\r\n<dol_align_left>\r\n<dol_print_object_lines>\r\n<dol_line_feed>\r\n<dol_print_object_tax>\r\n<dol_line_feed>\r\n<dol_print_object_total>\r\n<dol_line_feed>\r\n<dol_cut_paper_full>';
|
||||
$sql = array(
|
||||
"CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), fk_type integer, fk_profile integer, parameter varchar(128), entity integer) ENGINE=innodb;",
|
||||
"CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt_template (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), template text, entity integer) ENGINE=innodb;",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."printer_receipt_template WHERE name = '".$langs->trans('Example')."';",
|
||||
"INSERT INTO ".MAIN_DB_PREFIX."printer_receipt_template (name,template,entity) VALUES ('".$langs->trans('Example')."', '<dol_align_center>\r\n<dol_print_text><dol_value_mysoc_name>\r\n<dol_print_text><dol_value_mysoc_address>\r\n<dol_print_text><dol_value_mysoc_zip><dol_value_mysoc_town>\r\n<dol_line_feed>\r\n<dol_print_text>Facture <dol_value_object_ref>\r\n<dol_line_feed>\r\n<dol_align_left>\r\n<dol_print_object_lines>\r\n<dol_line_feed>\r\n<dol_print_object_tax>\r\n<dol_line_feed>\r\n<dol_print_object_total>\r\n<dol_line_feed>\r\n<dol_cut_paper_full>', 1);",
|
||||
"INSERT INTO ".MAIN_DB_PREFIX."printer_receipt_template (name,template,entity) VALUES ('".$langs->trans('Example')."', $templateexample, 1);",
|
||||
);
|
||||
return $this->_init($sql, $options);
|
||||
}
|
||||
|
||||
@@ -197,7 +197,8 @@ class modReception extends DolibarrModules
|
||||
$this->export_entities_array[$r] = array(
|
||||
's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company',
|
||||
'd.nom'=>'company', 'co.label'=>'company', 'co.code'=>'company', 's.fk_pays'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.ape'=>'company', 's.siret'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company',
|
||||
'c.rowid'=>"reception", 'c.ref'=>"reception", 'c.ref_supplier'=>"reception", 'c.fk_soc'=>"reception", 'c.date_creation'=>"reception", 'c.date_delivery'=>"reception", 'c.tracking_number'=>'reception', 'c.height'=>"reception", 'c.width'=>"reception", 'c.size'=>'reception', 'c.size_units'=>'reception', 'c.weight'=>"reception", 'c.weight_units'=>'reception', 'c.fk_statut'=>"reception", 'c.note_public'=>"reception", 'ed.rowid'=>'reception_line', 'ed.comment'=>'reception_line', 'ed.qty'=>"reception_line",
|
||||
'c.rowid'=>"reception", 'c.ref'=>"reception", 'c.ref_supplier'=>"reception", 'c.fk_soc'=>"reception", 'c.date_creation'=>"reception", 'c.date_delivery'=>"reception", 'c.tracking_number'=>'reception', 'c.height'=>"reception", 'c.width'=>"reception", 'c.size'=>'reception', 'c.size_units'=>'reception', 'c.weight'=>"reception", 'c.weight_units'=>'reception', 'c.fk_statut'=>"reception", 'c.note_public'=>"reception",
|
||||
'ed.rowid'=>'reception_line', 'ed.comment'=>'reception_line', 'ed.qty'=>"reception_line",
|
||||
'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product', 'p.weight'=>'product', 'p.weight_units'=>'product', 'p.volume'=>'product', 'p.volume_units'=>'product'
|
||||
);
|
||||
if ($idcontacts && !empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r] += array('sp.rowid'=>'contact', 'sp.lastname'=>'contact', 'sp.firstname'=>'contact', 'sp.note_public'=>'contact');
|
||||
|
||||
@@ -122,7 +122,12 @@ class modTicket extends DolibarrModules
|
||||
'langs' => 'ticket',
|
||||
'tabname' => array(MAIN_DB_PREFIX."c_ticket_type", MAIN_DB_PREFIX."c_ticket_severity", MAIN_DB_PREFIX."c_ticket_category", MAIN_DB_PREFIX."c_ticket_resolution"),
|
||||
'tablib' => array("TicketDictType", "TicketDictSeverity", "TicketDictCategory", "TicketDictResolution"),
|
||||
'tabsql' => array('SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_type as f', 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_severity as f', 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_category as f', 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_resolution as f'),
|
||||
'tabsql' => array(
|
||||
'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_type as f',
|
||||
'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_severity as f',
|
||||
'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_category as f',
|
||||
'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_resolution as f'
|
||||
),
|
||||
'tabsqlsort' => array("pos ASC", "pos ASC", "pos ASC", "pos ASC"),
|
||||
'tabfield' => array("pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default"),
|
||||
'tabfieldvalue' => array("pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default"),
|
||||
|
||||
@@ -498,7 +498,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
|
||||
migrate_reload_modules($db, $langs, $conf, $listofmodule);
|
||||
|
||||
// Reload menus (this must be always and only into last targeted version)
|
||||
migrate_reload_menu($db, $langs, $conf, $versionto);
|
||||
migrate_reload_menu($db, $langs, $conf);
|
||||
}
|
||||
|
||||
// Can force activation of some module during migration with parameter 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...'
|
||||
@@ -3624,10 +3624,9 @@ function migrate_mode_reglement($db, $langs, $conf)
|
||||
* @param DoliDB $db Database handler
|
||||
* @param Translate $langs Object langs
|
||||
* @param Conf $conf Object conf
|
||||
* @param string $versionto Version target
|
||||
* @return void
|
||||
*/
|
||||
function migrate_clean_association($db, $langs, $conf, $versionto)
|
||||
function migrate_clean_association($db, $langs, $conf)
|
||||
{
|
||||
$result = $db->DDLDescTable(MAIN_DB_PREFIX."categorie_association");
|
||||
if ($result) // result defined for version 3.2 or -
|
||||
@@ -4834,10 +4833,9 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo
|
||||
* @param DoliDB $db Database handler
|
||||
* @param Translate $langs Object langs
|
||||
* @param Conf $conf Object conf
|
||||
* @param string $versionto Version target
|
||||
* @return void
|
||||
*/
|
||||
function migrate_reload_menu($db, $langs, $conf, $versionto)
|
||||
function migrate_reload_menu($db, $langs, $conf)
|
||||
{
|
||||
global $conf;
|
||||
dolibarr_install_syslog("upgrade2::migrate_reload_menu");
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file test/functional/MyModuleFunctionalTest.php
|
||||
* \file test/phpunit/MyModuleFunctionalTest.php
|
||||
* \ingroup mymodule
|
||||
* \brief Example Selenium test.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user