Skip to content

Commit

Permalink
Format control structures, classes, methods and function
Browse files Browse the repository at this point in the history
To continue this formatting madness, here's a tiny patch that adds
unified formatting for control structures like if and loops as well as
classes, their methods and anonymous functions. This basically forces
the constructs to start on the same line. This is not exactly what PSR2
wants, but I think we can have a few exceptions with "our" style. The
starting of braces on the same line is pracrically standard for our
code.

This also removes and empty lines from method/function bodies at the
beginning and end.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
  • Loading branch information
ChristophWurst committed Apr 10, 2020
1 parent edf8ce3 commit caff102
Show file tree
Hide file tree
Showing 1,757 changed files with 3,872 additions and 5,891 deletions.
1 change: 0 additions & 1 deletion apps/accessibility/lib/AccessibilityProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,4 @@ public function getFonts() {
]
];
}

}
3 changes: 0 additions & 3 deletions apps/accessibility/lib/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public function getConfig(): DataResponse {
*/
public function setConfig(string $key, $value): DataResponse {
if ($key === 'theme' || $key === 'font' || $key === 'highcontrast') {

if ($value === false || $value === '') {
throw new OCSBadRequestException('Invalid value: ' . $value);
}
Expand Down Expand Up @@ -142,7 +141,6 @@ public function setConfig(string $key, $value): DataResponse {
*/
public function deleteConfig(string $key): DataResponse {
if ($key === 'theme' || $key === 'font' || $key === 'highcontrast') {

$this->config->deleteUserValue($this->userId, $this->appName, $key);
$userValues = $this->config->getUserKeys($this->userId, $this->appName);

Expand All @@ -156,5 +154,4 @@ public function deleteConfig(string $key): DataResponse {

throw new OCSBadRequestException('Invalid key: ' . $key);
}

}
1 change: 0 additions & 1 deletion apps/accessibility/lib/Migration/RepairUserConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,4 @@ public function run(IOutput $output) {
});
$output->finishProgress();
}

}
8 changes: 4 additions & 4 deletions apps/admin_audit/lib/Actions/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public function log(string $text,
array $params,
array $elements,
bool $obfuscateParameters = false) {
foreach($elements as $element) {
if(!isset($params[$element])) {
foreach ($elements as $element) {
if (!isset($params[$element])) {
if ($obfuscateParameters) {
$this->logger->critical(
'$params["'.$element.'"] was missing.',
Expand All @@ -74,8 +74,8 @@ public function log(string $text,
}

$replaceArray = [];
foreach($elements as $element) {
if($params[$element] instanceof \DateTime) {
foreach ($elements as $element) {
if ($params[$element] instanceof \DateTime) {
$params[$element] = $params[$element]->format('Y-m-d H:i:s');
}
$replaceArray[] = $params[$element];
Expand Down
32 changes: 16 additions & 16 deletions apps/admin_audit/lib/Actions/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Sharing extends Action {
* @param array $params
*/
public function shared(array $params) {
if($params['shareType'] === Share::SHARE_TYPE_LINK) {
if ($params['shareType'] === Share::SHARE_TYPE_LINK) {
$this->log(
'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)',
$params,
Expand All @@ -55,7 +55,7 @@ public function shared(array $params) {
'id',
]
);
} elseif($params['shareType'] === Share::SHARE_TYPE_USER) {
} elseif ($params['shareType'] === Share::SHARE_TYPE_USER) {
$this->log(
'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)',
$params,
Expand All @@ -68,7 +68,7 @@ public function shared(array $params) {
'id',
]
);
} elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) {
} elseif ($params['shareType'] === Share::SHARE_TYPE_GROUP) {
$this->log(
'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)',
$params,
Expand All @@ -81,7 +81,7 @@ public function shared(array $params) {
'id',
]
);
} elseif($params['shareType'] === Share::SHARE_TYPE_ROOM) {
} elseif ($params['shareType'] === Share::SHARE_TYPE_ROOM) {
$this->log(
'The %s "%s" with ID "%s" has been shared to the room "%s" with permissions "%s" (Share ID: %s)',
$params,
Expand All @@ -94,7 +94,7 @@ public function shared(array $params) {
'id',
]
);
} elseif($params['shareType'] === Share::SHARE_TYPE_EMAIL) {
} elseif ($params['shareType'] === Share::SHARE_TYPE_EMAIL) {
$this->log(
'The %s "%s" with ID "%s" has been shared to the email recipient "%s" with permissions "%s" (Share ID: %s)',
$params,
Expand All @@ -107,7 +107,7 @@ public function shared(array $params) {
'id',
]
);
} elseif($params['shareType'] === Share::SHARE_TYPE_CIRCLE) {
} elseif ($params['shareType'] === Share::SHARE_TYPE_CIRCLE) {
$this->log(
'The %s "%s" with ID "%s" has been shared to the circle "%s" with permissions "%s" (Share ID: %s)',
$params,
Expand All @@ -120,7 +120,7 @@ public function shared(array $params) {
'id',
]
);
} elseif($params['shareType'] === Share::SHARE_TYPE_REMOTE) {
} elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE) {
$this->log(
'The %s "%s" with ID "%s" has been shared to the remote user "%s" with permissions "%s" (Share ID: %s)',
$params,
Expand All @@ -133,7 +133,7 @@ public function shared(array $params) {
'id',
]
);
} elseif($params['shareType'] === Share::SHARE_TYPE_REMOTE_GROUP) {
} elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE_GROUP) {
$this->log(
'The %s "%s" with ID "%s" has been shared to the remote group "%s" with permissions "%s" (Share ID: %s)',
$params,
Expand All @@ -155,7 +155,7 @@ public function shared(array $params) {
* @param array $params
*/
public function unshare(array $params) {
if($params['shareType'] === Share::SHARE_TYPE_LINK) {
if ($params['shareType'] === Share::SHARE_TYPE_LINK) {
$this->log(
'The %s "%s" with ID "%s" has been unshared (Share ID: %s)',
$params,
Expand All @@ -166,7 +166,7 @@ public function unshare(array $params) {
'id',
]
);
} elseif($params['shareType'] === Share::SHARE_TYPE_USER) {
} elseif ($params['shareType'] === Share::SHARE_TYPE_USER) {
$this->log(
'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)',
$params,
Expand All @@ -178,7 +178,7 @@ public function unshare(array $params) {
'id',
]
);
} elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) {
} elseif ($params['shareType'] === Share::SHARE_TYPE_GROUP) {
$this->log(
'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)',
$params,
Expand All @@ -190,7 +190,7 @@ public function unshare(array $params) {
'id',
]
);
} elseif($params['shareType'] === Share::SHARE_TYPE_ROOM) {
} elseif ($params['shareType'] === Share::SHARE_TYPE_ROOM) {
$this->log(
'The %s "%s" with ID "%s" has been unshared from the room "%s" (Share ID: %s)',
$params,
Expand All @@ -202,7 +202,7 @@ public function unshare(array $params) {
'id',
]
);
} elseif($params['shareType'] === Share::SHARE_TYPE_EMAIL) {
} elseif ($params['shareType'] === Share::SHARE_TYPE_EMAIL) {
$this->log(
'The %s "%s" with ID "%s" has been unshared from the email recipient "%s" (Share ID: %s)',
$params,
Expand All @@ -214,7 +214,7 @@ public function unshare(array $params) {
'id',
]
);
} elseif($params['shareType'] === Share::SHARE_TYPE_CIRCLE) {
} elseif ($params['shareType'] === Share::SHARE_TYPE_CIRCLE) {
$this->log(
'The %s "%s" with ID "%s" has been unshared from the circle "%s" (Share ID: %s)',
$params,
Expand All @@ -226,7 +226,7 @@ public function unshare(array $params) {
'id',
]
);
} elseif($params['shareType'] === Share::SHARE_TYPE_REMOTE) {
} elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE) {
$this->log(
'The %s "%s" with ID "%s" has been unshared from the remote user "%s" (Share ID: %s)',
$params,
Expand All @@ -238,7 +238,7 @@ public function unshare(array $params) {
'id',
]
);
} elseif($params['shareType'] === Share::SHARE_TYPE_REMOTE_GROUP) {
} elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE_GROUP) {
$this->log(
'The %s "%s" with ID "%s" has been unshared from the remote group "%s" (Share ID: %s)',
$params,
Expand Down
2 changes: 0 additions & 2 deletions apps/admin_audit/lib/Actions/Trashbin.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
namespace OCA\AdminAudit\Actions;

class Trashbin extends Action {

public function delete(array $params) {
$this->log('File "%s" deleted from trash bin.',
['path' => $params['path']], ['path']
Expand All @@ -41,5 +40,4 @@ public function restore(array $params) {
['path' => $params['filePath']], ['path']
);
}

}
4 changes: 2 additions & 2 deletions apps/admin_audit/lib/Actions/UserManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function unassign(string $uid) {
* @param array $params
*/
public function change(array $params) {
switch($params['feature']) {
switch ($params['feature']) {
case 'enabled':
$this->log(
$params['value'] === true
Expand Down Expand Up @@ -130,7 +130,7 @@ public function change(array $params) {
* @param IUser $user
*/
public function setPassword(IUser $user) {
if($user->getBackendClassName() === 'Database') {
if ($user->getBackendClassName() === 'Database') {
$this->log(
'Password of user "%s" has been changed',
[
Expand Down
2 changes: 0 additions & 2 deletions apps/admin_audit/lib/Actions/Versions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
namespace OCA\AdminAudit\Actions;

class Versions extends Action {

public function rollback(array $params) {
$this->log('Version "%s" of "%s" was restored.',
[
Expand All @@ -46,5 +45,4 @@ public function delete(array $params) {
['path']
);
}

}
5 changes: 1 addition & 4 deletions apps/admin_audit/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,11 @@ public function initLogger() {

$default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log';
$logFile = $config->getAppValue('admin_audit', 'logfile', $default);
if($logFile === null) {
if ($logFile === null) {
$this->logger = $c->getLogger();
return;
}
$this->logger = $c->getLogFactory()->getCustomLogger($logFile);

}

public function register() {
Expand Down Expand Up @@ -152,7 +151,6 @@ protected function authHooks() {
}

protected function appHooks() {

$eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
$eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE, function (ManagerEvent $event) {
$appActions = new AppManagement($this->logger);
Expand All @@ -166,7 +164,6 @@ protected function appHooks() {
$appActions = new AppManagement($this->logger);
$appActions->disableApp($event->getAppID());
});

}

protected function consoleHooks() {
Expand Down
4 changes: 2 additions & 2 deletions apps/admin_audit/lib/BackgroundJobs/Rotate.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ protected function run($argument) {
$default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log';
$this->filePath = $config->getAppValue('admin_audit', 'logfile', $default);

if($this->filePath === '') {
if ($this->filePath === '') {
// default log file, nothing to do
return;
}

$this->maxSize = $config->getSystemValue('log_rotate_size', 100 * 1024 * 1024);

if($this->shouldRotateBySize()) {
if ($this->shouldRotateBySize()) {
$this->rotate();
}
}
Expand Down
1 change: 0 additions & 1 deletion apps/admin_audit/tests/Actions/SecurityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,4 @@ public function testTwofactorSuccess() {

$this->security->twofactorSuccess($this->user, ['provider' => 'myprovider']);
}

}
1 change: 0 additions & 1 deletion apps/cloud_federation_api/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use OCP\AppFramework\App;

class Application extends App {

public function __construct() {
parent::__construct('cloud_federation_api');

Expand Down
1 change: 0 additions & 1 deletion apps/cloud_federation_api/lib/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,4 @@ public function getSupportedShareTypes($resourceType) {
return [];
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $
}

if ($shareType === 'group') {
if(!$this->groupManager->groupExists($shareWith)) {
if (!$this->groupManager->groupExists($shareWith)) {
return new JSONResponse(
['message' => 'Group "' . $shareWith . '" does not exists at ' . $this->urlGenerator->getBaseUrl()],
Http::STATUS_BAD_REQUEST
Expand Down Expand Up @@ -208,14 +208,13 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $

$user = $this->userManager->get($shareWith);
$recipientDisplayName = '';
if($user) {
if ($user) {
$recipientDisplayName = $user->getDisplayName();
}

return new JSONResponse(
['recipientDisplayName' => $recipientDisplayName],
Http::STATUS_CREATED);

}

/**
Expand Down Expand Up @@ -267,16 +266,14 @@ public function receiveNotification($notificationType, $resourceType, $providerI
return new JSONResponse($e->getReturnMessage(), Http::STATUS_BAD_REQUEST);
} catch (AuthenticationFailedException $e) {
return new JSONResponse(["message" => "RESOURCE_NOT_FOUND"], Http::STATUS_FORBIDDEN);
}
catch (\Exception $e) {
} catch (\Exception $e) {
return new JSONResponse(
['message' => 'Internal error at ' . $this->urlGenerator->getBaseUrl()],
Http::STATUS_BAD_REQUEST
);
}

return new JSONResponse($result,Http::STATUS_CREATED);

}

/**
Expand All @@ -297,5 +294,4 @@ private function mapUid($uid) {

return $uid;
}

}
1 change: 0 additions & 1 deletion apps/comments/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
use OCP\Util;

class Application extends App {

const APP_ID = 'comments';

public function __construct(array $urlParams = []) {
Expand Down
Loading

0 comments on commit caff102

Please sign in to comment.