From 155dff3cfb59bde7fccfb17e453d1e8caf6875d5 Mon Sep 17 00:00:00 2001
From: Benoit Mortier <benoit.mortier@opensides.be>
Date: Sat, 3 Dec 2016 01:44:31 +0100
Subject: [PATCH] sonar fixes :

Add curly braces around the nested statement(s).

Signed-off-by: Benoit Mortier <benoit.mortier@opensides.be>
---
 html/progress.php            |  6 ++++--
 include/class_ldap.inc       |  6 ++++--
 include/class_management.inc |  9 ++++++---
 include/functions_debug.inc  | 15 +++++++++++----
 4 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/html/progress.php b/html/progress.php
index f8e908c62..c133b48b4 100644
--- a/html/progress.php
+++ b/html/progress.php
@@ -75,8 +75,10 @@ if (!function_exists("imagecreate")) {
   }
 
   /* Draw image in GD image stream */
-  $im = imagecreate ($x, $y)
-    or die ("Cannot Initialize new GD image stream");
+  $im = imagecreate ($x, $y);
+  if (!$im) {
+    die ('Cannot Initialize new GD image stream');
+  }
 
   /* Set colors */
   $bg_color = imagecolorallocate($im, 255,  255,  255);
diff --git a/include/class_ldap.inc b/include/class_ldap.inc
index 66e2cbde9..9bf4af49d 100644
--- a/include/class_ldap.inc
+++ b/include/class_ldap.inc
@@ -576,8 +576,9 @@ class LDAP
         $this->connect();
       }
 
-      if ($dn == "")
+      if ($dn == "") {
         $dn = $this->basedn;
+      }
 
       $r = ldap_mod_del($this->cid, LDAP::fix($dn), $attrs);
       $this->error = @ldap_error($this->cid);
@@ -595,8 +596,9 @@ class LDAP
         $this->connect();
       }
 
-      if ($dn == "")
+      if ($dn == "") {
         $dn = $this->basedn;
+      }
 
       $r = @ldap_mod_add($this->cid, LDAP::fix($dn), $attrs);
       $this->error = @ldap_error($this->cid);
diff --git a/include/class_management.inc b/include/class_management.inc
index c109b54c1..dd372dee0 100644
--- a/include/class_management.inc
+++ b/include/class_management.inc
@@ -380,12 +380,15 @@ class management
     $tabClass     = $this->tabClass;
     $aclCategory  = $this->aclCategory;
 
-    if (!empty($altTabClass))
+    if (!empty($altTabClass)) {
       $tabClass = $altTabClass;
-    if (!empty($altTabType))
+    }
+    if (!empty($altTabType)) {
       $tabType = $altTabType;
-    if (!empty($altAclCategory))
+    }
+    if (!empty($altAclCategory)) {
       $aclCategory = $altAclCategory;
+    }
 
     @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $target, "Entry removal confirmed!");
 
diff --git a/include/functions_debug.inc b/include/functions_debug.inc
index 709a9711a..fe6b5092a 100644
--- a/include/functions_debug.inc
+++ b/include/functions_debug.inc
@@ -112,7 +112,9 @@ class Print_a_class {
    */
   function print_a($array, $iteration = FALSE, $key_bg_color = FALSE)
   {
-    $key_bg_color or $key_bg_color = $this->key_bg_color;
+    if (!$key_bg_color) {
+      $key_bg_color = $this->key_bg_color;
+    }
 
     if (!$iteration && isset($this->export_flag)) {
       $this->output .= '<form id="pa_form_'.$this->export_hash.'" action="'.$this->export_dumper_path.'?mode='.$this->export_flag.'" method="post" target="_blank"><input name="array" type="hidden" value="'.htmlspecialchars( serialize( $array ) ).'"></form>';
@@ -123,8 +125,13 @@ class Print_a_class {
       for ($i = 0; $i < 6; $i += 2) {
         $c = substr( $key_bg_color, $i, 2 );
         $c = hexdec( $c );
-        ( $c += 15 ) > 255 and $c = 255;
-        isset($tmp_key_bg_color) or $tmp_key_bg_color = '';
+        $c += 15;
+        if ($c > 255) {
+          $c = 255;
+        }
+        if (!isset($tmp_key_bg_color)) {
+          $tmp_key_bg_color = '';
+        }
         $tmp_key_bg_color .= sprintf( "%02X", $c );
       }
       $key_bg_color = $tmp_key_bg_color;
@@ -221,7 +228,7 @@ class Print_a_class {
 function print_a($array, $return_mode = FALSE, $show_object_vars = FALSE, $export_flag = FALSE )
 {
   $e = error_reporting(0);
-  if (is_array($array) or is_object($array)) {
+  if (is_array($array) || is_object($array)) {
     $pa = new Print_a_class;
     if ($show_object_vars) {
       $pa->show_object_vars = TRUE;
-- 
GitLab