From a8dd045586462b8e879913a3d42ba6c14e0e1b6f Mon Sep 17 00:00:00 2001 From: jgen Date: Sat, 26 Apr 2014 03:56:06 -0400 Subject: [PATCH] Combine these if statements into one to reduce the cyclomatic complexity. --- ext/notes/main.php | 36 +++++++++++++----------------------- ext/notes/theme.php | 2 +- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/ext/notes/main.php b/ext/notes/main.php index b241343d..3a259c1c 100644 --- a/ext/notes/main.php +++ b/ext/notes/main.php @@ -323,26 +323,16 @@ class Notes extends Extension { $noteText = mysql_real_escape_string(html_escape($_POST["note_text"])); // validate parameters - if(is_null($imageID) || !is_numeric($imageID)) - return; - - if(is_null($noteID) || !is_numeric($noteID)) - return; - - if(is_null($noteX1) || !is_numeric($noteX1)) - return; - - if(is_null($noteY1) || !is_numeric($noteY1)) - return; - - if(is_null($noteHeight) || !is_numeric($noteHeight)) - return; - - if(is_null($noteWidth) || !is_numeric($noteWidth)) - return; - - if(is_null($noteText) || strlen($noteText) == 0) + if (is_null($imageID) || !is_numeric($imageID) || + is_null($noteID) || !is_numeric($noteID) || + is_null($noteX1) || !is_numeric($noteX1) || + is_null($noteY1) || !is_numeric($noteY1) || + is_null($noteHeight) || !is_numeric($noteHeight) || + is_null($noteWidth) || !is_numeric($noteWidth) || + is_null($noteText) || strlen($noteText) == 0) + { return; + } global $database; $database->execute("UPDATE notes ". @@ -369,11 +359,11 @@ class Notes extends Extension { $noteID = int_escape($_POST["note_id"]); // validate parameters - if(is_null($imageID) || !is_numeric($imageID)) - return; - - if(is_null($noteID) || !is_numeric($noteID)) + if( is_null($imageID) || !is_numeric($imageID) || + is_null($noteID) || !is_numeric($noteID)) + { return; + } global $database; diff --git a/ext/notes/theme.php b/ext/notes/theme.php index 6f3fb9c9..38e7a968 100644 --- a/ext/notes/theme.php +++ b/ext/notes/theme.php @@ -235,5 +235,5 @@ class NotesTheme extends Themelet { $this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages); } -} +}