Skip to content

Commit 70bea2c

Browse files
committed
Cleaned up code - some files were refactored with refactor
The following adjustments were made: - Simplify regex pattern to known ranges (SimplifyRegexPatternRector) - Return early prepared value in ifs (PreparedValueToEarlyReturnRector) - Change ternary of bool : false to && bool (TernaryToBooleanOrFalseToBooleanAndRector) - Replace if conditioned variable override with direct return (ReturnEarlyIfVariableRector) - Remove recasting of the same type (RecastingRemovalRector)
1 parent 88f2806 commit 70bea2c

65 files changed

Lines changed: 188 additions & 199 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

gui/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/templates_c/

gui/templates_c/.gitignore

Lines changed: 0 additions & 6 deletions
This file was deleted.

install/sqlParser.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ protected function only_good_sql($v, $comment_char = '-')
137137

138138
// Empty line must not be used
139139
if ($use_v && strlen($v_c) == 0) {
140-
$use_v = false;
140+
return false;
141141
}
142142

143143
return $use_v;

lib/api/rest/v2/tlRestApi.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ protected function userHasRight($rightToCheck,
14431443

14441444
if (! $this->user->hasRight($this->db, $rightToCheck, $tproject_id,
14451445
$tplan_id, $checkPublicPrivateAttr)) {
1446-
$status_ok = false;
1446+
return false;
14471447
}
14481448
return $status_ok;
14491449
}

lib/api/rest/v3/RestApi.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1709,7 +1709,7 @@ protected function userHasRight($rightToCheck,
17091709

17101710
if (! $this->user->hasRight($this->db, $rightToCheck, $tproject_id,
17111711
$tplan_id, $checkPublicPrivateAttr)) {
1712-
$status_ok = false;
1712+
return false;
17131713
}
17141714
return $status_ok;
17151715
}

lib/api/xmlrpc/v1/sample_clients/php/clientTestSuiteTestCaseStepsManagement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
}
8282

8383
// Now reinsert original content if any
84-
$steps2insert = ! is_null($originalSteps) && count((array) $originalSteps > 0) ? $originalSteps : $fakeSteps;
84+
$steps2insert = ! is_null($originalSteps) && count($originalSteps > 0) ? $originalSteps : $fakeSteps;
8585
$args = $commonArgs;
8686
$args["version"] = $cfg->tcaseVersionNumber;
8787
$args["action"] = 'create';

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,7 +1632,7 @@ protected function _checkCreateBuildRequest($messagePrefix = '')
16321632
];
16331633
$status_ok = $this->_runChecks($checkFunctions, $messagePrefix);
16341634
if ($status_ok) {
1635-
$status_ok = $this->_isParamPresent(self::$buildNameParamName,
1635+
return $this->_isParamPresent(self::$buildNameParamName,
16361636
$messagePrefix, self::SET_ERROR);
16371637
}
16381638

@@ -2317,7 +2317,7 @@ public function getProjectTestPlans($args)
23172317
$testProjectID = $this->args[self::$testProjectIDParamName];
23182318
$info = $this->tprojectMgr->get_all_testplans($testProjectID);
23192319
if (! empty($info)) {
2320-
$info = array_values($info);
2320+
return array_values($info);
23212321
}
23222322
return $info;
23232323
} else {
@@ -3680,7 +3680,7 @@ protected function getKeywordSet($tproject_id)
36803680
}
36813681

36823682
if (! is_null($kMethod)) {
3683-
$keywordSet = $this->$kMethod($tproject_id, $this->args[$accessKey]);
3683+
return $this->$kMethod($tproject_id, $this->args[$accessKey]);
36843684
}
36853685

36863686
return $keywordSet;
@@ -4437,7 +4437,7 @@ protected function checkReqIdentity($messagePrefix = '')
44374437
}
44384438

44394439
if ($status) {
4440-
$status = $this->checkReqID($messagePrefix);
4440+
return $this->checkReqID($messagePrefix);
44414441
}
44424442

44434443
return $status;
@@ -4528,7 +4528,7 @@ protected function checkReqSpecQuality()
45284528
}
45294529

45304530
if (! $status_ok) {
4531-
$ret = [
4531+
return [
45324532
'status_ok' => false,
45334533
'error_msg' => $msg,
45344534
'error_code' => $error_code
@@ -9259,7 +9259,7 @@ public function getIssueTrackerSystem($args, $call = null)
92599259
}
92609260

92619261
if ($extCall && ! $status_ok) {
9262-
$ret = $this->errors;
9262+
return $this->errors;
92639263
}
92649264
return $ret;
92659265
}

lib/cfields/cfieldsView.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
* @param tlUser $user
2727
* @return boolean
2828
*/
29-
function checkRights(&$db, &$user)
30-
{
31-
return $user->hasRight($db, "cfield_management") ||
32-
$user->hasRight($db, "cfield_view");
29+
function checkRights(&$db, &$user)
30+
{
31+
if ($user->hasRight($db, "cfield_management")) {
32+
return true;
33+
}
34+
return (bool) $user->hasRight($db, "cfield_view");
3335
}
3436

lib/codetrackerintegration/stashrestInterface.class.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ public function connect()
9494
// $this->cfg is a simpleXML Object, then seems very conservative and safe
9595
// to cast properties BEFORE using it.
9696
$this->stashCfg = [
97-
'username' => (string) trim($this->cfg->username),
98-
'password' => (string) trim($this->cfg->password),
99-
'host' => (string) trim($this->cfg->uriapi)
97+
'username' => trim($this->cfg->username),
98+
'password' => trim($this->cfg->password),
99+
'host' => trim($this->cfg->uriapi)
100100
];
101101

102102
$this->stashCfg['proxy'] = config_get('proxy');
@@ -157,7 +157,7 @@ public function getProjectsForHTMLSelect()
157157
$ret = null;
158158
$projList = $this->getProjects();
159159
if (property_exists($projList, 'values')) {
160-
$ret = $this->objectAttrToKeyName($projList->values);
160+
return $this->objectAttrToKeyName($projList->values);
161161
}
162162
return $ret;
163163
}
@@ -180,7 +180,7 @@ public function getReposForHTMLSelect($projectKey)
180180
$ret = null;
181181
$repoList = $this->getRepos($projectKey);
182182
if (property_exists($repoList, 'values')) {
183-
$ret = $this->objectAttrToIDName($repoList->values, 'slug', 'name');
183+
return $this->objectAttrToIDName($repoList->values, 'slug', 'name');
184184
}
185185
return $ret;
186186
}
@@ -244,7 +244,7 @@ public function getBranchesForHTMLSelect($projectKey, $repoName)
244244
$ret = null;
245245
$branchList = $this->getBranches($projectKey, $repoName);
246246
if (property_exists($branchList, 'values')) {
247-
$ret = $this->objectAttrToIDName($branchList->values, 'displayId',
247+
return $this->objectAttrToIDName($branchList->values, 'displayId',
248248
'displayId');
249249
}
250250
return $ret;

lib/codetrackers/codeTrackerView.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ function initArgs()
6969
return $args;
7070
}
7171

72-
function checkRights(&$db, &$user)
73-
{
74-
return $user->hasRight($db, "codetracker_view") ||
75-
$user->hasRight($db, "codetracker_management");
72+
function checkRights(&$db, &$user)
73+
{
74+
if ($user->hasRight($db, "codetracker_view")) {
75+
return true;
76+
}
77+
return (bool) $user->hasRight($db, "codetracker_management");
7678
}

0 commit comments

Comments
 (0)