Skip to content

Commit 44e7c64

Browse files
committed
Code revised with reactor
Applied rules: * ShortenElseIfRector
1 parent ff96e3b commit 44e7c64

34 files changed

+613
-762
lines changed

install/sqlParser.class.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,10 @@ protected function only_good_sql($v, $comment_char = '-')
127127
$v_c = trim($v, "\r\n ");
128128
$pos = strpos($v_c, $findme);
129129

130-
if ($pos === false) {
131-
$use_v = true;
132-
} else {
133-
if ($pos == 0) {
134-
$use_v = false;
135-
}
130+
if ($pos === false) {
131+
$use_v = true;
132+
} elseif ($pos == 0) {
133+
$use_v = false;
136134
}
137135

138136
// Empty line must not be used

lib/api/xmlrpc/v1/xmlrpc.class.php

Lines changed: 60 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,8 @@ protected function userHasRight($rightToCheck,
577577
$tprojectid = intval(
578578
isset($context[self::$testProjectIDParamName]) ? $context[self::$testProjectIDParamName] : 0);
579579

580-
if ($tprojectid == 0 && isset(
581-
$this->args[self::$testProjectIDParamName])) {
580+
if ($tprojectid == 0 &&
581+
isset($this->args[self::$testProjectIDParamName])) {
582582
$tprojectid = $this->args[self::$testProjectIDParamName];
583583
}
584584

@@ -606,8 +606,8 @@ protected function userHasRight($rightToCheck,
606606
// Try using TestSuiteID to get TestProjectID
607607
$tsuiteid = intval(
608608
isset($context[self::$testSuiteIDParamName]) ? $context[self::$testSuiteIDParamName] : 0);
609-
if ($tsuiteid == 0 && isset(
610-
$this->args[self::$testSuiteIDParamName])) {
609+
if ($tsuiteid == 0 &&
610+
isset($this->args[self::$testSuiteIDParamName])) {
611611
$tsuiteid = intval($this->args[self::$testSuiteIDParamName]);
612612
}
613613
if ($tsuiteid > 0) {
@@ -787,15 +787,13 @@ protected function checkTestPlanID($messagePrefix = '')
787787
$msg = $messagePrefix . sprintf(INVALID_TPLANID_STR, $tplanid);
788788
$this->errors[] = new IXR_Error(INVALID_TPLANID, $msg);
789789
$status = false;
790-
} else {
790+
} elseif ($this->checkGuess() &&
791+
(! $this->_isBuildIDPresent() &&
792+
! $this->_isParamPresent(self::$buildNameParamName,
793+
$messagePrefix))) {
791794
// tplanid exists and its valid
792795
// Do we need to try to guess build id ?
793-
if ($this->checkGuess() &&
794-
(! $this->_isBuildIDPresent() &&
795-
! $this->_isParamPresent(self::$buildNameParamName,
796-
$messagePrefix))) {
797-
$status = $this->_setBuildID2Latest();
798-
}
796+
$status = $this->_setBuildID2Latest();
799797
}
800798
}
801799
return $status;
@@ -3786,11 +3784,9 @@ protected function checkVersionNumber()
37863784
$msg = sprintf(PARAMETER_NOT_INT_STR,
37873785
self::$versionNumberParamName, $version);
37883786
$this->errors[] = new IXR_Error(PARAMETER_NOT_INT, $msg);
3789-
} else {
3790-
if (! ($status = ($version > 0))) {
3791-
$msg = sprintf(VERSION_NOT_VALID_STR, $version);
3792-
$this->errors[] = new IXR_Error(VERSION_NOT_VALID, $msg);
3793-
}
3787+
} elseif (! ($status = ($version > 0))) {
3788+
$msg = sprintf(VERSION_NOT_VALID_STR, $version);
3789+
$this->errors[] = new IXR_Error(VERSION_NOT_VALID, $msg);
37943790
}
37953791
}
37963792
return $status;
@@ -3923,11 +3919,9 @@ public function addTestCaseToTestPlan($args)
39233919
if ($this->_isParamPresent($key)) {
39243920
$additional_values[] = $this->args[$key];
39253921
$additional_fields[] = $field_name;
3926-
} else {
3927-
if (! is_null($opt_values[$key])) {
3928-
$additional_values[] = $opt_values[$key];
3929-
$additional_fields[] = $field_name;
3930-
}
3922+
} elseif (! is_null($opt_values[$key])) {
3923+
$additional_values[] = $opt_values[$key];
3924+
$additional_fields[] = $field_name;
39313925
}
39323926
}
39333927
}
@@ -4663,8 +4657,8 @@ public function getTestCaseAttachments($args)
46634657
return $this->errors;
46644658
}
46654659

4666-
if ($status_ok && ! $this->_isParamPresent(
4667-
self::$versionNumberParamName)) {
4660+
if ($status_ok &&
4661+
! $this->_isParamPresent(self::$versionNumberParamName)) {
46684662
try {
46694663
$tc = $this->getTestCase($args, self::THROW_ON_ERROR);
46704664
$this->args[self::$versionNumberParamName] = $tc[0][self::$versionNumberParamName];
@@ -5181,19 +5175,15 @@ public function createTestPlan($args)
51815175
$this->errors[] = new IXR_Error(
51825176
TESTPROJECTNAME_DOESNOT_EXIST, $msg);
51835177
}
5184-
} else {
5185-
5186-
if (isset($target[self::$prefixParamName]) &&
5187-
$target[self::$prefixParamName] != '') {
5188-
$prefix = trim($this->args[self::$prefixParamName]);
5189-
$tprojectInfo = $this->tprojectMgr->get_by_prefix($prefix);
5190-
5191-
if ($status_ok = is_null($tprojectInfo)) {
5192-
$msg = $msg_prefix .
5193-
sprintf(TPROJECT_PREFIX_DOESNOT_EXIST_STR, $prefix);
5194-
$this->errors[] = new IXR_Error(
5195-
TPROJECT_PREFIX_DOESNOT_EXIST, $msg);
5196-
}
5178+
} elseif (isset($target[self::$prefixParamName]) &&
5179+
$target[self::$prefixParamName] != '') {
5180+
$prefix = trim($this->args[self::$prefixParamName]);
5181+
$tprojectInfo = $this->tprojectMgr->get_by_prefix($prefix);
5182+
if ($status_ok = is_null($tprojectInfo)) {
5183+
$msg = $msg_prefix .
5184+
sprintf(TPROJECT_PREFIX_DOESNOT_EXIST_STR, $prefix);
5185+
$this->errors[] = new IXR_Error(
5186+
TPROJECT_PREFIX_DOESNOT_EXIST, $msg);
51975187
}
51985188
}
51995189
}
@@ -7227,8 +7217,8 @@ public function setTestCaseExecutionType($args)
72277217
'checkTestCaseVersionNumber'
72287218
);
72297219
$status_ok = $this->_runChecks($checkFunctions, $msg_prefix);
7230-
if ($status_ok &&
7231-
! $this->_isParamPresent(self::$executionTypeParamName)) {
7220+
if ($status_ok && ! $this->_isParamPresent(
7221+
self::$executionTypeParamName)) {
72327222
$status_ok = false;
72337223
$msg = sprintf(MISSING_REQUIRED_PARAMETER_STR,
72347224
self::$customFieldsParamName);
@@ -8033,26 +8023,22 @@ public function getTestCaseAssignedTester($args)
80338023
$msg = $messagePrefix .
80348024
sprintf(MISSING_REQUIRED_PARAMETER_STR, $pname);
80358025
$this->errors[] = new IXR_Error(MISSING_REQUIRED_PARAMETER, $msg);
8036-
} else {
8026+
} elseif ($status_ok = $this->checkPlatformIdentity($tplan_id)) {
80378027
// get platform_id and check it
8038-
if ($status_ok = $this->checkPlatformIdentity($tplan_id)) {
8039-
$platform_set = $this->tplanMgr->getPlatforms($tplan_id,
8040-
array(
8041-
'outputFormat' => 'mapAccessByID',
8042-
'outputDetails' => 'name'
8043-
));
8044-
8045-
// Now check if link has all 3 components
8046-
// test plan, test case, platform
8047-
$platform_id = $this->args[self::$platformIDParamName];
8048-
$platform_info = array(
8049-
$platform_id => $platform_set[$platform_id]
8050-
);
8051-
8052-
if ($status_ok = $this->_checkTCIDAndTPIDValid(
8053-
$platform_info, $msg_prefix)) {
8054-
$execContext['platform_id'] = $platform_id;
8055-
}
8028+
$platform_set = $this->tplanMgr->getPlatforms($tplan_id,
8029+
array(
8030+
'outputFormat' => 'mapAccessByID',
8031+
'outputDetails' => 'name'
8032+
));
8033+
// Now check if link has all 3 components
8034+
// test plan, test case, platform
8035+
$platform_id = $this->args[self::$platformIDParamName];
8036+
$platform_info = array(
8037+
$platform_id => $platform_set[$platform_id]
8038+
);
8039+
if ($status_ok = $this->_checkTCIDAndTPIDValid($platform_info,
8040+
$msg_prefix)) {
8041+
$execContext['platform_id'] = $platform_id;
80568042
}
80578043
}
80588044
}
@@ -8173,8 +8159,8 @@ public function getTestCaseBugs($args)
81738159
" WHERE parent_id = {$this->args[self::$testCaseIDParamName]})";
81748160

81758161
if (! is_null($execContext['build_id'])) {
8176-
$sql .= " AND build_id = " . intval(
8177-
$execContext['build_id']);
8162+
$sql .= " AND build_id = " .
8163+
intval($execContext['build_id']);
81788164
}
81798165

81808166
if (! is_null($execContext['platform_id'])) {
@@ -8316,26 +8302,22 @@ private function manageTestCaseExecutionTask($args, $msg_prefix)
83168302
$msg = $messagePrefix .
83178303
sprintf(MISSING_REQUIRED_PARAMETER_STR, $pname);
83188304
$this->errors[] = new IXR_Error(MISSING_REQUIRED_PARAMETER, $msg);
8319-
} else {
8305+
} elseif ($status_ok = $this->checkPlatformIdentity($tplan_id)) {
83208306
// get platform_id and check it
8321-
if ($status_ok = $this->checkPlatformIdentity($tplan_id)) {
8322-
$platform_set = $this->tplanMgr->getPlatforms($tplan_id,
8323-
array(
8324-
'outputFormat' => 'mapAccessByID',
8325-
'outputDetails' => 'name'
8326-
));
8327-
8328-
// Now check if link has all 3 components
8329-
// test plan, test case, platform
8330-
$platform_id = $this->args[self::$platformIDParamName];
8331-
$platform_info = array(
8332-
$platform_id => $platform_set[$platform_id]
8333-
);
8334-
8335-
if ($status_ok = $this->_checkTCIDAndTPIDValid(
8336-
$platform_info, $msg_prefix)) {
8337-
$execContext['platform_id'] = $platform_id;
8338-
}
8307+
$platform_set = $this->tplanMgr->getPlatforms($tplan_id,
8308+
array(
8309+
'outputFormat' => 'mapAccessByID',
8310+
'outputDetails' => 'name'
8311+
));
8312+
// Now check if link has all 3 components
8313+
// test plan, test case, platform
8314+
$platform_id = $this->args[self::$platformIDParamName];
8315+
$platform_info = array(
8316+
$platform_id => $platform_set[$platform_id]
8317+
);
8318+
if ($status_ok = $this->_checkTCIDAndTPIDValid($platform_info,
8319+
$msg_prefix)) {
8320+
$execContext['platform_id'] = $platform_id;
83398321
}
83408322
}
83418323
}

lib/cfields/cfieldsTprojectAssign.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,8 @@ function doSimpleBooleanMgmt(&$cfieldMgr, $argsObj, $cfg)
258258
if ($argsObj->attrBefore[$id][$cfg['dbField']] == 0) {
259259
$on[] = $id;
260260
}
261-
} else {
262-
if ($argsObj->attrBefore[$id][$cfg['dbField']] == 1) {
263-
$off[] = $id;
264-
}
261+
} elseif ($argsObj->attrBefore[$id][$cfg['dbField']] == 1) {
262+
$off[] = $id;
265263
}
266264
}
267265

0 commit comments

Comments
 (0)