diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 016129c76297d41897b6183e63ffd1aacf4071f6..a176c114cb80db3ac484055d3347c1f1a124622d 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -13,10 +13,12 @@ filter: paths: { } tools: - # Similar code detection - php_sim: + # php_analyzer. Doc on https://scrutinizer-ci.com/docs/tools/php/php-analyzer/ + php_analyzer: enabled: true - min_mass: 16 + extensions: + - php + dependency_paths: { } filter: excluded_paths: - 'build/*' @@ -25,10 +27,115 @@ tools: - 'test/*' - 'htdocs/includes/*' paths: { } + 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: true + enabled: false configuration_file: null suffixes: - php @@ -42,12 +149,14 @@ tools: - 'htdocs/includes/*' paths: { } - # php_analyzer - php_analyzer: - enabled: true - extensions: - - php - dependency_paths: { } + # change tracking + php_changetracking: + enabled: false + bug_patterns: + - '\bfix(?:es|ed)?\b' + feature_patterns: + - '\badd(?:s|ed)?\b' + - '\bimplement(?:s|ed)?\b' filter: excluded_paths: - 'build/*' @@ -56,16 +165,11 @@ tools: - 'test/*' - 'htdocs/includes/*' paths: { } - path_configs: { } - # change tracking - php_changetracking: - enabled: true - bug_patterns: - - '\bfix(?:es|ed)?\b' - feature_patterns: - - '\badd(?:s|ed)?\b' - - '\bimplement(?:s|ed)?\b' + # Similar code detection + php_sim: + enabled: false + min_mass: 30 filter: excluded_paths: - 'build/*' @@ -76,7 +180,7 @@ tools: 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 9f93f0f1bdaae4ff8cdeff893d97f77392dea1aa..c88257b8de31f6c374d6a751b77a0150e1b40bf8 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 5f26d1106f7489b7341c7663884404d944e77e3b..c7943ff26b2a79b7acd45e59807b07055479e4e6 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 90e0abcfd4bac664bdbd075fa4555a8b03dba84c..59791b5cad987a7003a4183a8aa7a8fd0a25be98 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 '<tr><td><span class="fieldrequired">'.$langs->trans("Password").'</span></td><td>'; print '<input size="30" maxsize="32" type="text" name="password" value="'.$generated_password.'">'; print '</td></tr>'; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 37d8a6c04f8949dde5d229f88bb5427b1354412b..5a30f8bafb6f8a4856f12404ea6a466eb442388d 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[] = "<a href='".DOL_URL_ROOT."/categories/viewcat.php?id=".$cat->id."'>".$cat->label."</a>"; - } - else - { - $w[] = "<a href='".DOL_URL_ROOT."/".$url."?catid=".$cat->id."'>".$cat->label."</a>"; - } - } - - 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 ae05923bcce42fd30fe188318e1fe60be74701f2..9302b53d5bd51b6337a9fde1002d147ebf0b6065 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 120d6e8e474bbaf1a8f892ef23e2f10c78aa20de..a14ba58e19e4f1658a04aa8aa3d6e339d1dcb1e5 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 448c509e52f951d130282ee25b37c781242ed336..24e010233977190ee6f07633ef083101d41df60c 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 0b65d2b2db89fb2c935cd7acb50b038bede69a86..b95f9113180dad99db7c39873e2b0398adf67238 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 7724806f5c235c77e385b4e2c8ebff8121d90dee..98874ba480474e0922ab1919b32e6e09efd68ee8 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 '</td></tr>'; - + // Note Private print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td><td colspan="3">'; $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 '<tr><td valign="top">'.$langs->trans("NotePublic").'</td><td colspan="3">'; print nl2br($object->note_public); print '</td></tr>'; - + // Note Private print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td><td colspan="3">'; print nl2br($object->note_private); @@ -1067,9 +1067,9 @@ else print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=disable&id='.$object->id.'">'.$langs->trans("DisableUser").'</a>'; } } - + print "</div><br>"; - + 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 b32c5d4cb751036cde07d2a9c3e50fdb5de4d5c8..3835f7cb07ee198f10da804f92e4d5f24d547bab 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 3241f6dbc125c71dd0197ac02c80217404611f4f..2ff681b8fe4d6dbe748e5796a1e92f42ecae86bf 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 0ae409ca8fec3115003e4cd2122adbd56bcfd681..ba851ea384060652603cf6b0fed26833f74442fb 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;