From b920dfdbda1a4bfc428883d3eb7fb1a9f49d6e1a Mon Sep 17 00:00:00 2001 From: onhairech <47675588+oussamanhairech@users.noreply.github.com> Date: Tue, 25 Jul 2023 23:29:34 +0200 Subject: [PATCH] qodana fix 4: missing returns (#25334) * qodana fix 4: missing returns * Delete settings.json * correcting the return info function * unreachable code fix * return fix --- htdocs/asset/class/assetaccountancycodes.class.php | 1 + htdocs/compta/facture/class/facture-rec.class.php | 1 + htdocs/compta/prelevement/class/ligneprelevement.class.php | 3 +-- htdocs/compta/sociales/class/cchargesociales.class.php | 1 + htdocs/compta/sociales/class/chargesociales.class.php | 2 ++ htdocs/core/lib/functionsnumtoword.lib.php | 2 +- htdocs/core/modules/action/rapport.class.php | 1 + htdocs/core/modules/bank/doc/pdf_ban.modules.php | 2 +- htdocs/core/modules/expensereport/doc/pdf_standard.modules.php | 1 + htdocs/core/modules/facture/mod_facture_mars.php | 3 ++- htdocs/core/modules/mailings/advthirdparties.modules.php | 1 + .../core/modules/supplier_invoice/doc/pdf_canelle.modules.php | 1 + .../core/modules/supplier_payment/doc/pdf_standard.modules.php | 1 + htdocs/core/modules/takepos/mod_takepos_ref_simple.php | 3 ++- htdocs/fourn/class/fournisseur.commande.class.php | 1 + htdocs/fourn/class/fournisseur.commande.dispatch.class.php | 1 + 16 files changed, 19 insertions(+), 6 deletions(-) diff --git a/htdocs/asset/class/assetaccountancycodes.class.php b/htdocs/asset/class/assetaccountancycodes.class.php index 6c33e3af901..f52dc20a5f5 100644 --- a/htdocs/asset/class/assetaccountancycodes.class.php +++ b/htdocs/asset/class/assetaccountancycodes.class.php @@ -94,6 +94,7 @@ class AssetAccountancyCodes extends CommonObject $this->accountancy_codes[$mode_key][$field_key] = $accountancy_code; } } + return $this->accountancy_codes; } /** diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 09b2c1e6185..dc2181e8e46 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1214,6 +1214,7 @@ class FactureRec extends CommonInvoice return -1; } } + return -1; } diff --git a/htdocs/compta/prelevement/class/ligneprelevement.class.php b/htdocs/compta/prelevement/class/ligneprelevement.class.php index 6ed518f7f2f..9faafb99d84 100644 --- a/htdocs/compta/prelevement/class/ligneprelevement.class.php +++ b/htdocs/compta/prelevement/class/ligneprelevement.class.php @@ -126,7 +126,7 @@ class LignePrelevement * * @param int $status Id status * @param int $mode 0=Label, 1=Picto + label, 2=Picto, 3=Label + Picto - * @return string Label + * @return null|string Label */ public function LibStatut($status, $mode = 0) { @@ -160,7 +160,6 @@ class LignePrelevement return $langs->trans($this->statuts[$status]).' '.img_picto($langs->transnoentitiesnoconv($this->statuts[$status]), 'statut8', 'class="valignmiddle"'); } } - //return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index 741179d067e..b9b28f823b6 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -501,6 +501,7 @@ class Cchargesociales return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); } } + return ""; } diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 66bd680739d..7a65b75cf58 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -730,8 +730,10 @@ class ChargeSociales extends CommonObject } $this->db->free($result); + return 1; } else { dol_print_error($this->db); + return -1; } } diff --git a/htdocs/core/lib/functionsnumtoword.lib.php b/htdocs/core/lib/functionsnumtoword.lib.php index f14295ab068..cdc288abd17 100644 --- a/htdocs/core/lib/functionsnumtoword.lib.php +++ b/htdocs/core/lib/functionsnumtoword.lib.php @@ -163,7 +163,7 @@ function dol_convertToWord($num, $langs, $currency = '', $centimes = false) * @param float $numero Number to convert * @param Translate $langs Language * @param string $numorcurrency 'number' or 'amount' - * @return string Text of the number or -1 in case TOO LONG (more than 1000000000000.99) + * @return string|int Text of the number or -1 in case TOO LONG (more than 1000000000000.99) */ function dolNumberToWord($numero, $langs, $numorcurrency = 'number') { diff --git a/htdocs/core/modules/action/rapport.class.php b/htdocs/core/modules/action/rapport.class.php index a880b894b73..d43ebc17d01 100644 --- a/htdocs/core/modules/action/rapport.class.php +++ b/htdocs/core/modules/action/rapport.class.php @@ -215,6 +215,7 @@ class CommActionRapport return 1; } + return 0; } /** diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php index 2af920da42e..5996b3d50c0 100644 --- a/htdocs/core/modules/bank/doc/pdf_ban.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php @@ -388,6 +388,6 @@ class pdf_ban extends ModeleBankAccountDoc global $conf; $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - //return pdf_pagefoot($pdf,$outputlangs,'BANK_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); + return 1; } } diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index b8a58d3b517..ec409109d2d 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -1109,6 +1109,7 @@ class pdf_standard extends ModeleExpenseReport $this->error = $this->db->lasterror(); return -1; } + return -1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index fb4ba06b9ce..91f60af5ad0 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -158,7 +158,7 @@ class mod_facture_mars extends ModeleNumRefFactures * @param Societe $objsoc Object third party * @param Facture $invoice Object invoice * @param string $mode 'next' for next value or 'last' for last value - * @return string Value if OK, 0 if KO + * @return string|int Value if OK, 0 if KO */ public function getNextValue($objsoc, $invoice, $mode = 'next') { @@ -233,6 +233,7 @@ class mod_facture_mars extends ModeleNumRefFactures return $prefix.$yymm."-".$num; } else { dol_print_error('', 'Bad parameter for getNextValue'); + return -1; } } diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index ced14b802a0..111943e99e0 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -308,5 +308,6 @@ class mailing_advthirdparties extends MailingTargets $contactstatic->fetch($id); return $contactstatic->getNomUrl(0, '', 0, '', -1, 1); } + return ""; } } diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 982d7a4ba85..3dfb6bfd4d2 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -1057,6 +1057,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $this->error = $this->db->lasterror(); return -1; } + return -1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index d3b9681a63f..8646ecac0c9 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -546,6 +546,7 @@ class pdf_standard extends ModelePDFSuppliersPayments // Date $pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy); $pdf->MultiCell(150, 4, date("d").' '.$outputlangs->transnoentitiesnoconv(date("F")).' '.date("Y"), 0, 'L', 1); + return $posy; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_simple.php b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php index 31eb9345110..2295209bb82 100644 --- a/htdocs/core/modules/takepos/mod_takepos_ref_simple.php +++ b/htdocs/core/modules/takepos/mod_takepos_ref_simple.php @@ -130,7 +130,7 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos * @param Societe $objsoc Object third party * @param Facture $invoice Object invoice * @param string $mode 'next' for next value or 'last' for last value - * @return string Next ref value or last ref if $mode is 'last' + * @return string|int Next ref value or last ref if $mode is 'last' */ public function getNextValue($objsoc = null, $invoice = null, $mode = 'next') { @@ -198,6 +198,7 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos return $this->prefix.$pos_source.'-'.$yymm.'-'.$num; } else { dol_print_error('', 'Bad parameter for getNextValue'); + return -1; } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 5dc92c9d057..ff1964fbe9f 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2100,6 +2100,7 @@ class CommandeFournisseur extends CommonOrder return -1; } } + return -1; } diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index e4bccaa0980..0b8e70ee6c3 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -609,6 +609,7 @@ class CommandeFournisseurDispatch extends CommonObjectLine return ''.$langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts[$status]), 'statut8'); } } + return ""; }