diff --git a/.scrutinizer.yml b/.scrutinizer.yml
index 016129c7629..a176c114cb8 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -13,36 +13,7 @@ filter:
paths: { }
tools:
- # Similar code detection
- php_sim:
- enabled: true
- min_mass: 16
- filter:
- excluded_paths:
- - 'build/*'
- - 'dev/*'
- - 'doc/*'
- - 'test/*'
- - 'htdocs/includes/*'
- paths: { }
-
- # php_depend
- php_pdepend:
- enabled: true
- configuration_file: null
- suffixes:
- - php
- excluded_dirs: { }
- filter:
- excluded_paths:
- - 'build/*'
- - 'dev/*'
- - 'doc/*'
- - 'test/*'
- - 'htdocs/includes/*'
- paths: { }
-
- # php_analyzer
+ # php_analyzer. Doc on https://scrutinizer-ci.com/docs/tools/php/php-analyzer/
php_analyzer:
enabled: true
extensions:
@@ -56,11 +27,131 @@ tools:
- 'test/*'
- 'htdocs/includes/*'
paths: { }
- path_configs: { }
+ config:
+ parameter_reference_check:
+ enabled: true
+ checkstyle:
+ enabled: false
+ no_trailing_whitespace: true
+ naming:
+ enabled: true
+ local_variable: ^[a-z][a-zA-Z0-9]*$
+ abstract_class_name: ^Abstract|Factory$
+ utility_class_name: Utils?$
+ constant_name: ^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$
+ property_name: ^[a-z][a-zA-Z0-9]*$
+ method_name: ^(?:[a-z]|__)[a-zA-Z0-9]*$
+ parameter_name: ^[a-z][a-zA-Z0-9]*$
+ interface_name: ^[A-Z][a-zA-Z0-9]*Interface$
+ type_name: ^[A-Z][a-zA-Z0-9]*$
+ exception_name: ^[A-Z][a-zA-Z0-9]*Exception$
+ isser_method_name: ^(?:is|has|should|may|supports)
+ unreachable_code:
+ enabled: true
+ check_access_control:
+ enabled: true
+ typo_checks:
+ enabled: true
+ check_variables:
+ enabled: true
+ check_calls:
+ enabled: true
+ too_many_arguments: true
+ missing_argument: true
+ argument_type_checks: lenient # Allowed Values: "disabled", "lenient", "strict"
+ suspicious_code:
+ enabled: true
+ overriding_parameter: false
+ overriding_closure_use: true
+ parameter_closure_use_conflict: true
+ parameter_multiple_times: true
+ non_existent_class_in_instanceof_check: true
+ non_existent_class_in_catch_clause: true
+ assignment_of_null_return: true
+ non_commented_switch_fallthrough: true
+ non_commented_empty_catch_block: true
+ overriding_private_members: true
+ use_statement_alias_conflict: true
+ precedence_in_condition_assignment: true
+ dead_assignments:
+ enabled: true
+ verify_php_doc_comments:
+ enabled: false
+ parameters: true
+ return: true
+ suggest_more_specific_types: true
+ ask_for_return_if_not_inferrable: true
+ ask_for_param_type_annotation: true
+ loops_must_use_braces:
+ enabled: true
+ check_usage_context:
+ enabled: true
+ simplify_boolean_return:
+ enabled: false
+ phpunit_checks:
+ enabled: false
+ reflection_checks:
+ enabled: true
+
+ # Checks Common Precedence Mistakes
+ precedence_checks:
+ enabled: true
+ assignment_in_condition: true
+ comparison_of_bit_result: true
+ basic_semantic_checks:
+ enabled: true
+ unused_code:
+ enabled: true
+ deprecation_checks:
+ enabled: true
+ useless_function_calls:
+ enabled: true
+ metrics_lack_of_cohesion_methods:
+ enabled: true
+ metrics_coupling:
+ enabled: true
+ stable_code:
+ namespace_prefixes: []
+ classes: []
+ doctrine_parameter_binding:
+ enabled: false
+ doctrine_entity_manager_injection:
+ enabled: false
+ symfony_request_injection:
+ enabled: false
+ doc_comment_fixes:
+ enabled: true
+ reflection_fixes:
+ enabled: false
+ use_statement_fixes:
+ enabled: true
+ remove_unused: true
+ # Whether you would like multiple imports in one USE statement to be preserved, e.g. ``use A, B;``.
+ preserve_multiple: false
+ # Whether you would like to preserve blank lines between use statements.
+ preserve_blanklines: false
+ order_alphabetically: false
+ # To use specific config for a specific path, use path_configs: (see example on page https://scrutinizer-ci.com/docs/configuration/tool_config_structure)
+
+ # php_depend
+ php_pdepend:
+ enabled: false
+ configuration_file: null
+ suffixes:
+ - php
+ excluded_dirs: { }
+ filter:
+ excluded_paths:
+ - 'build/*'
+ - 'dev/*'
+ - 'doc/*'
+ - 'test/*'
+ - 'htdocs/includes/*'
+ paths: { }
# change tracking
php_changetracking:
- enabled: true
+ enabled: false
bug_patterns:
- '\bfix(?:es|ed)?\b'
feature_patterns:
@@ -75,8 +166,21 @@ tools:
- 'htdocs/includes/*'
paths: { }
+ # Similar code detection
+ php_sim:
+ enabled: false
+ min_mass: 30
+ filter:
+ excluded_paths:
+ - 'build/*'
+ - 'dev/*'
+ - 'doc/*'
+ - 'test/*'
+ - 'htdocs/includes/*'
+ paths: { }
+
# Coding-Style / Bug Detection
- js_hint: true
+ js_hint: false
before_commands: { }
diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php
index 9f93f0f1bda..c88257b8de3 100644
--- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php
+++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php
@@ -368,7 +368,7 @@ abstract class ActionsAdherentCardCommon
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$login=dol_buildlogin($this->object->lastname, $this->object->firstname);
- $generated_password=getRandomPassword('');
+ $generated_password=getRandomPassword(false);
$password=$generated_password;
// Create a form array
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index 5f26d1106f7..c7943ff26b2 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -825,7 +825,7 @@ class Adherent extends CommonObject
if (! $password)
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
- $password=getRandomPassword('');
+ $password=getRandomPassword(false);
}
// Cryptage mot de passe
@@ -1242,15 +1242,15 @@ class Adherent extends CommonObject
/**
* Insert subscription into database and eventually add links to banks, mailman, etc...
*
- * @param timestamp $date Date d'effet de la cotisation
- * @param amount $montant Montant cotisation (accepte 0 pour les adherents non soumis a cotisation)
- * @param int $accountid Id compte bancaire
- * @param string $operation Type operation (si Id compte bancaire fourni)
- * @param string $label Label operation (si Id compte bancaire fourni)
- * @param string $num_chq Numero cheque (si Id compte bancaire fourni)
- * @param string $emetteur_nom Nom emetteur cheque
- * @param string $emetteur_banque Nom banque emetteur cheque
- * @param timestamp $datesubend Date fin adhesion
+ * @param timestamp $date Date of effect of subscription
+ * @param double $montant Amount of subscription (0 accepted for some members)
+ * @param int $accountid Id bank account
+ * @param string $operation Type operation (if Id bank account provided)
+ * @param string $label Label operation (if Id bank account provided)
+ * @param string $num_chq Numero cheque (if Id bank account provided)
+ * @param string $emetteur_nom Name of cheque writer
+ * @param string $emetteur_banque Name of bank of cheque
+ * @param timestamp $datesubend Date end subscription
* @return int rowid of record added, <0 if KO
*/
function cotisation($date, $montant, $accountid=0, $operation='', $label='', $num_chq='', $emetteur_nom='', $emetteur_banque='', $datesubend=0)
diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php
index 90e0abcfd4b..59791b5cad9 100644
--- a/htdocs/adherents/fiche.php
+++ b/htdocs/adherents/fiche.php
@@ -812,7 +812,7 @@ else
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
- $generated_password=getRandomPassword('');
+ $generated_password=getRandomPassword(false);
print '
'.$langs->trans("Password").' ';
print ' ';
print ' ';
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index 37d8a6c04f8..5a30f8bafb6 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -103,11 +103,11 @@ class Categorie extends CommonObject
$this->visible = $res['visible'];
$this->type = $res['type'];
$this->entity = $res['entity'];
-
+
$this->fetch_optionals($this->id,$extralabels);
$this->db->free($resql);
-
+
// multilangs
if (! empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs();
@@ -194,7 +194,7 @@ class Categorie extends CommonObject
if ($id > 0)
{
$this->id = $id;
-
+
// Actions on extra fields (by external module or standard code)
// FIXME le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('HookModuleNamedao'));
@@ -281,7 +281,7 @@ class Categorie extends CommonObject
dol_syslog(get_class($this)."::update sql=".$sql);
if ($this->db->query($sql))
{
-
+
// Actions on extra fields (by external module or standard code)
// FIXME le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('HookCategorydao'));
@@ -299,10 +299,10 @@ class Categorie extends CommonObject
}
}
else if ($reshook < 0) $error++;
-
+
$this->db->commit();
-
+
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
@@ -340,7 +340,7 @@ class Categorie extends CommonObject
if (! $error)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."categorie";
- $sql.= " SET fk_parent = ".$this->fk_parent;
+ $sql.= " SET fk_parent = ".$this->fk_parent;
$sql.= " WHERE fk_parent = ".$this->id;
if (!$this->db->query($sql))
@@ -771,7 +771,7 @@ class Categorie extends CommonObject
function get_full_arbo($type,$markafterid=0)
{
global $langs;
-
+
$this->cats = array();
// Init this->motherof that is array(id_son=>id_parent, ...)
@@ -780,7 +780,7 @@ class Categorie extends CommonObject
// Init $this->cats array
$sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.fk_parent"; // Distinct reduce pb with old tables with duplicates
- if (! empty($conf->global->MAIN_MULTILANGS))
+ if (! empty($conf->global->MAIN_MULTILANGS))
$sql.= ", t.label as label_trans, t.description as description_trans";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as c";
if (! empty($conf->global->MAIN_MULTILANGS))
@@ -1055,63 +1055,6 @@ class Categorie extends CommonObject
}
- /**
- * Affiche le chemin le plus court pour se rendre a un produit
- *
- * @param int $id Id of category
- * @param string $type Type of category
- * @return void
- * @deprecated function not used ?
- */
- function get_primary_way($id, $type="")
- {
- $primary_way = array("taille" => -1, "chemin" => array());
- $meres = $this->containing($id,$type);
- foreach ($meres as $mere)
- {
- foreach ($mere->get_all_ways() as $way)
- {
- if(count($way) < $primary_way["taille"] || $primary_way["taille"] < 0)
- {
- $primary_way["taille"] = count($way);
- $primary_way["chemin"] = $way;
- }
- }
- }
- return $primary_way["chemin"];
-
- }
-
- /**
- * Affiche le chemin le plus court pour se rendre a un produit
- *
- * @param int $id Id of category
- * @param string $sep Separator
- * @param string $url Url
- * @param string $type Type
- * @return void
- * @deprecated function not used ?
- */
- function print_primary_way($id, $sep= " >> ", $url="", $type="")
- {
- $primary_way = array();
- $way = $this->get_primary_way($id,$type);
- $w = array();
- foreach ($way as $cat)
- {
- if ($url == '')
- {
- $w[] = "".$cat->label." ";
- }
- else
- {
- $w[] = "".$cat->label." ";
- }
- }
-
- return implode($sep, $w);
- }
-
/**
* Retourne un tableau contenant la liste des categories meres
*
@@ -1476,19 +1419,19 @@ class Categorie extends CommonObject
function setMultiLangs()
{
global $langs;
-
+
$langs_available = $langs->get_available_languages();
$current_lang = $langs->getDefaultLang();
-
+
foreach ($langs_available as $key => $value)
{
$sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_lang";
$sql.= " WHERE fk_category=".$this->id;
$sql.= " AND lang='".$key."'";
-
+
$result = $this->db->query($sql);
-
+
if ($key == $current_lang)
{
if ($this->db->num_rows($result)) // si aucune ligne dans la base
@@ -1527,7 +1470,7 @@ class Categorie extends CommonObject
$sql2.= " VALUES(".$this->id.",'".$key."','". $this->db->escape($this->multilangs["$key"]["label"]);
$sql2.= "','".$this->db->escape($this->multilangs["$key"]["description"])."')";
}
-
+
// on ne sauvegarde pas des champs vides
if ( $this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"] )
dol_syslog(get_class($this).'::setMultiLangs sql='.$sql2);
@@ -1541,7 +1484,7 @@ class Categorie extends CommonObject
}
return 1;
}
-
+
/**
* Load array this->multilangs
*
@@ -1550,13 +1493,13 @@ class Categorie extends CommonObject
function getMultiLangs()
{
global $langs;
-
+
$current_lang = $langs->getDefaultLang();
-
+
$sql = "SELECT lang, label, description";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_lang";
$sql.= " WHERE fk_category=".$this->id;
-
+
$result = $this->db->query($sql);
if ($result)
{
@@ -1567,7 +1510,7 @@ class Categorie extends CommonObject
{
$this->label = $obj->label;
$this->description = $obj->description;
-
+
}
$this->multilangs["$obj->lang"]["label"] = $obj->label;
$this->multilangs["$obj->lang"]["description"] = $obj->description;
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index ae05923bcce..9302b53d5bd 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -1803,10 +1803,13 @@ if ($action == 'create') {
if ($action != 'editline') {
$var = true;
- if ($conf->global->MAIN_FEATURES_LEVEL > 1) {
+ if ($conf->global->MAIN_FEATURES_LEVEL > 1)
+ {
// Add free or predefined products/services
$object->formAddObjectLine(1, $mysoc, $soc);
- } else {
+ }
+ else
+ {
// Add free products/services
$object->formAddFreeProduct(1, $mysoc, $soc);
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 120d6e8e474..a14ba58e19e 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -2102,10 +2102,13 @@ if ($action == 'create' && $user->rights->commande->creer) {
if ($action != 'editline') {
$var = true;
- if ($conf->global->MAIN_FEATURES_LEVEL > 1) {
+ if ($conf->global->MAIN_FEATURES_LEVEL > 1)
+ {
// Add free or predefined products/services
$object->formAddObjectLine(1, $mysoc, $soc);
- } else {
+ }
+ else
+ {
// Add free products/services
$object->formAddFreeProduct(1, $mysoc, $soc);
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 448c509e52f..24e01023397 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -3307,10 +3307,13 @@ if ($action == 'create')
if ($object->statut == 0 && $user->rights->facture->creer && $action != 'valid' && $action != 'editline') {
$var = true;
- if ($conf->global->MAIN_FEATURES_LEVEL > 1) {
+ if ($conf->global->MAIN_FEATURES_LEVEL > 1)
+ {
// Add free or predefined products/services
$object->formAddObjectLine(1, $mysoc, $soc);
- } else {
+ }
+ else
+ {
// Add free products/services
$object->formAddFreeProduct(1, $mysoc, $soc);
diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php
index 0b65d2b2db8..b95f9113180 100644
--- a/htdocs/contact/canvas/actions_contactcard_common.class.php
+++ b/htdocs/contact/canvas/actions_contactcard_common.class.php
@@ -400,7 +400,7 @@ abstract class ActionsContactCardCommon
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$login=dol_buildlogin($this->object->lastname, $this->object->firstname);
- $generated_password=getRandomPassword('');
+ $generated_password=getRandomPassword(false);
$password=$generated_password;
// Create a form array
diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php
index 7724806f5c2..98874ba4804 100644
--- a/htdocs/contact/fiche.php
+++ b/htdocs/contact/fiche.php
@@ -749,7 +749,7 @@ else
$doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
print $doleditor->Create(1);
print '';
-
+
// Note Private
print ''.$langs->trans("NotePrivate").' ';
$doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
@@ -843,7 +843,7 @@ else
if (! $ldap_sid) // TODO ldap_sid ?
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
- $generated_password=getRandomPassword('');
+ $generated_password=getRandomPassword(false);
}
$password=$generated_password;
@@ -971,7 +971,7 @@ else
print ' '.$langs->trans("NotePublic").' ';
print nl2br($object->note_public);
print ' ';
-
+
// Note Private
print ''.$langs->trans("NotePrivate").' ';
print nl2br($object->note_private);
@@ -1067,9 +1067,9 @@ else
print ''.$langs->trans("DisableUser").' ';
}
}
-
+
print " ";
-
+
print load_fiche_titre($langs->trans("TasksHistoryForThisContact"),'','');
print show_actions_todo($conf,$langs,$db,$objsoc,$object);
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index b32c5d4cb75..3835f7cb07e 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -2693,13 +2693,12 @@ abstract class CommonObject
/**
* Show add free products/services form
* TODO Edit templates to use global variables and include them directly in controller call
- * But for the moment we don't know if it'st possible as we keep a method available on overloaded objects.
+ * But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
*
- * @param int $dateSelector 1=Show also date range input fields
+ * @param int $dateSelector 1=Show also date range input fields (start and end date)
* @param Societe $seller Object thirdparty who sell
* @param Societe $buyer Object thirdparty who buy
* @return void
- * @deprecated
*/
function formAddFreeProduct($dateSelector,$seller,$buyer)
{
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index 3241f6dbc12..2ff681b8fe4 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -1356,7 +1356,7 @@ class User extends CommonObject
// If new password not provided, we generate one
if (! $password)
{
- $password=getRandomPassword('');
+ $password=getRandomPassword(false);
}
// Crypte avec md5
diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php
index 0ae409ca8fe..ba851ea3840 100644
--- a/htdocs/user/fiche.php
+++ b/htdocs/user/fiche.php
@@ -748,7 +748,7 @@ if (($action == 'create') || ($action == 'adduserldap'))
if (empty($ldap_sid)) // ldap_sid is for activedirectory
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
- $generated_password=getRandomPassword('');
+ $generated_password=getRandomPassword(false);
}
$password=$generated_password;