Skip to content

Commit

Permalink
Return value immediately instead of assigning to a one-time variable
Browse files Browse the repository at this point in the history
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
  • Loading branch information
MorrisJobke committed Jan 25, 2018
1 parent b9bbb89 commit 0a56d21
Show file tree
Hide file tree
Showing 19 changed files with 21 additions and 47 deletions.
3 changes: 1 addition & 2 deletions apps/dav/lib/CardDAV/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ public function splitFullName($fullName) {
*/
private function getAvatarImage(IUser $user) {
try {
$image = $user->getAvatarImage(-1);
return $image;
return $user->getAvatarImage(-1);
} catch (\Exception $ex) {
return null;
}
Expand Down
3 changes: 1 addition & 2 deletions apps/dav/lib/Connector/Sabre/FilesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,7 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
});

$propFind->handle(self::IS_ENCRYPTED_PROPERTYNAME, function() use ($node) {
$result = $node->getFileInfo()->isEncrypted() ? '1' : '0';
return $result;
return $node->getFileInfo()->isEncrypted() ? '1' : '0';
});

$propFind->handle(self::HAS_PREVIEW_PROPERTYNAME, function () use ($node) {
Expand Down
3 changes: 1 addition & 2 deletions apps/encryption/lib/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ public function getOwner($path) {
* @return \OC\Files\Storage\Storage
*/
public function getStorage($path) {
$storage = $this->files->getMount($path)->getStorage();
return $storage;
return $this->files->getMount($path)->getStorage();
}

}
3 changes: 1 addition & 2 deletions apps/federatedfilesharing/lib/AddressHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ public function splitUserRemote($address) {
* @return string url of the current server
*/
public function generateRemoteURL() {
$url = $this->urlGenerator->getAbsoluteURL('/');
return $url;
return $this->urlGenerator->getAbsoluteURL('/');
}

/**
Expand Down
3 changes: 1 addition & 2 deletions apps/files_external/3rdparty/icewind/smb/src/Share.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,7 @@ public function notify($path) {
protected function execute($command) {
$this->connect();
$this->connection->write($command . PHP_EOL);
$output = $this->connection->read();
return $output;
return $this->connection->read();
}

/**
Expand Down
3 changes: 1 addition & 2 deletions apps/files_external/lib/Service/UserStoragesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ protected function getType() {
*/
public function addStorage(StorageConfig $newStorage) {
$newStorage->setApplicableUsers([$this->getUser()->getUID()]);
$config = parent::addStorage($newStorage);
return $config;
return parent::addStorage($newStorage);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions apps/files_sharing/lib/Controller/ShareesAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ protected function getPaginationLink($page, array $params) {
$url = $this->urlGenerator->getAbsoluteURL('/ocs/v1.php/apps/files_sharing/api/v1/sharees') . '?';
}
$params['page'] = $page + 1;
$link = '<' . $url . http_build_query($params) . '>; rel="next"';

return $link;
return '<' . $url . http_build_query($params) . '>; rel="next"';
}

/**
Expand Down
4 changes: 1 addition & 3 deletions apps/files_sharing/lib/ShareBackend/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ private function getParentId($child) {
$query = \OCP\DB::prepare('SELECT `parent` FROM `*PREFIX*filecache` WHERE `fileid` = ?');
$result = $query->execute(array($child));
$row = $result->fetchRow();
$parent = $row ? $row['parent'] : null;

return $parent;
return $row ? $row['parent'] : null;
}

public function getChildren($itemSource) {
Expand Down
3 changes: 1 addition & 2 deletions apps/files_trashbin/lib/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,7 @@ protected function shouldMoveToTrash($path){
* @return MoveToTrashEvent
*/
protected function createMoveToTrashEvent(Node $node) {
$event = new MoveToTrashEvent($node);
return $event;
return new MoveToTrashEvent($node);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ public function getDescription() {
* @return Template
*/
public function getTemplate(IUser $user) {
$tmpl = new Template('twofactor_backupcodes', 'challenge');
return $tmpl;
return new Template('twofactor_backupcodes', 'challenge');
}

/**
Expand Down
3 changes: 1 addition & 2 deletions apps/user_ldap/lib/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ public function getNextServerConfigurationPrefix() {
sort($serverConnections);
$lastKey = array_pop($serverConnections);
$lastNumber = intval(str_replace('s', '', $lastKey));
$nextPrefix = 's' . str_pad($lastNumber + 1, 2, '0', STR_PAD_LEFT);
return $nextPrefix;
return 's' . str_pad($lastNumber + 1, 2, '0', STR_PAD_LEFT);
}

private function getServersConfig($value) {
Expand Down
3 changes: 1 addition & 2 deletions core/Command/Config/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ protected function getArrayFromStdin() {
* @return string
*/
protected function getArrayFromFile($importFile) {
$content = file_get_contents($importFile);
return $content;
return file_get_contents($importFile);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/private/App/Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public function isCommandKnown($command) {

public function getLibraryVersion($name) {
$repo = new PlatformRepository();
$lib = $repo->findLibrary($name);
return $lib;
return $repo->findLibrary($name);
}
}
9 changes: 3 additions & 6 deletions lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,7 @@ public function readfile($path) {
flush();
}
fclose($handle);
$size = $this->filesize($path);
return $size;
return $this->filesize($path);
}
return false;
}
Expand Down Expand Up @@ -476,8 +475,7 @@ public function readfilePart($path, $from, $to) {
echo fread($handle, $len);
flush();
}
$size = ftell($handle) - $from;
return $size;
return ftell($handle) - $from;
}

throw new \OCP\Files\UnseekableException('fseek error');
Expand Down Expand Up @@ -1083,8 +1081,7 @@ public function hash($type, $path, $raw = false) {
}
list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix);
if ($storage) {
$result = $storage->hash($type, $internalPath, $raw);
return $result;
return $storage->hash($type, $internalPath, $raw);
}
}
return null;
Expand Down
4 changes: 1 addition & 3 deletions lib/private/Security/CertificateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,7 @@ private function getPathToCertificates($uid = '') {
if ($uid === '') {
$uid = $this->uid;
}
$path = is_null($uid) ? '/files_external/' : '/' . $uid . '/files_external/';

return $path;
return is_null($uid) ? '/files_external/' : '/' . $uid . '/files_external/';
}

/**
Expand Down
4 changes: 1 addition & 3 deletions lib/private/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ public function __construct($webRoot, \OC\Config $config) {
$this->registerService('SystemTagManagerFactory', function (Server $c) {
$config = $c->getConfig();
$factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
/** @var \OC\SystemTag\ManagerFactory $factory */
$factory = new $factoryClass($this);
return $factory;
return new $factoryClass($this);
});
$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
return $c->query('SystemTagManagerFactory')->getManager();
Expand Down
3 changes: 1 addition & 2 deletions lib/private/legacy/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ public static function getDbStructure($file) {
*/
public static function createDbFromStructure( $file ) {
$schemaManager = self::getMDB2SchemaManager();
$result = $schemaManager->createDbFromStructure($file);
return $result;
return $schemaManager->createDbFromStructure($file);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/private/legacy/db/statementwrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ public function execute($input= []) {
return false;
}
if ($this->isManipulation) {
$count = $this->statement->rowCount();
return $count;
return $this->statement->rowCount();
} else {
return $this;
}
Expand Down
4 changes: 1 addition & 3 deletions settings/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -723,9 +723,7 @@ protected function getCurrentTime() {
protected function signMessage(IUser $user, $message) {
$privateKey = $this->keyManager->getKey($user)->getPrivate();
openssl_sign(json_encode($message), $signature, $privateKey, OPENSSL_ALGO_SHA512);
$signatureBase64 = base64_encode($signature);

return $signatureBase64;
return base64_encode($signature);
}

/**
Expand Down

0 comments on commit 0a56d21

Please sign in to comment.