diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-04-10 14:19:56 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-04-10 14:19:56 +0200 |
commit | caff1023ea72bb2ea94130e18a2a6e2ccf819e5f (patch) | |
tree | 186d494c2aea5dea7255d3584ef5d595fc6e6194 /apps/admin_audit | |
parent | edf8ce32cffdb920e8171207b342abbd7f1fbe73 (diff) | |
download | nextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.tar.gz nextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.zip |
Format control structures, classes, methods and function
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>
Diffstat (limited to 'apps/admin_audit')
-rw-r--r-- | apps/admin_audit/lib/Actions/Action.php | 8 | ||||
-rw-r--r-- | apps/admin_audit/lib/Actions/Sharing.php | 32 | ||||
-rw-r--r-- | apps/admin_audit/lib/Actions/Trashbin.php | 2 | ||||
-rw-r--r-- | apps/admin_audit/lib/Actions/UserManagement.php | 4 | ||||
-rw-r--r-- | apps/admin_audit/lib/Actions/Versions.php | 2 | ||||
-rw-r--r-- | apps/admin_audit/lib/AppInfo/Application.php | 5 | ||||
-rw-r--r-- | apps/admin_audit/lib/BackgroundJobs/Rotate.php | 4 | ||||
-rw-r--r-- | apps/admin_audit/tests/Actions/SecurityTest.php | 1 |
8 files changed, 25 insertions, 33 deletions
diff --git a/apps/admin_audit/lib/Actions/Action.php b/apps/admin_audit/lib/Actions/Action.php index 16b2fd759c8..3d8d39f0ce0 100644 --- a/apps/admin_audit/lib/Actions/Action.php +++ b/apps/admin_audit/lib/Actions/Action.php @@ -53,8 +53,8 @@ class Action { 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.', @@ -74,8 +74,8 @@ class Action { } $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]; diff --git a/apps/admin_audit/lib/Actions/Sharing.php b/apps/admin_audit/lib/Actions/Sharing.php index fef112e77d3..4359360908e 100644 --- a/apps/admin_audit/lib/Actions/Sharing.php +++ b/apps/admin_audit/lib/Actions/Sharing.php @@ -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, @@ -55,7 +55,7 @@ class Sharing extends Action { '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, @@ -68,7 +68,7 @@ class Sharing extends Action { '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, @@ -81,7 +81,7 @@ class Sharing extends Action { '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, @@ -94,7 +94,7 @@ class Sharing extends Action { '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, @@ -107,7 +107,7 @@ class Sharing extends Action { '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, @@ -120,7 +120,7 @@ class Sharing extends Action { '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, @@ -133,7 +133,7 @@ class Sharing extends Action { '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, @@ -155,7 +155,7 @@ class Sharing extends Action { * @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, @@ -166,7 +166,7 @@ class Sharing extends Action { '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, @@ -178,7 +178,7 @@ class Sharing extends Action { '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, @@ -190,7 +190,7 @@ class Sharing extends Action { '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, @@ -202,7 +202,7 @@ class Sharing extends Action { '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, @@ -214,7 +214,7 @@ class Sharing extends Action { '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, @@ -226,7 +226,7 @@ class Sharing extends Action { '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, @@ -238,7 +238,7 @@ class Sharing extends Action { '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, diff --git a/apps/admin_audit/lib/Actions/Trashbin.php b/apps/admin_audit/lib/Actions/Trashbin.php index 50a3d28a8ad..a3e050a29f5 100644 --- a/apps/admin_audit/lib/Actions/Trashbin.php +++ b/apps/admin_audit/lib/Actions/Trashbin.php @@ -29,7 +29,6 @@ declare(strict_types=1); 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'] @@ -41,5 +40,4 @@ class Trashbin extends Action { ['path' => $params['filePath']], ['path'] ); } - } diff --git a/apps/admin_audit/lib/Actions/UserManagement.php b/apps/admin_audit/lib/Actions/UserManagement.php index ab231a796c7..2bc733b5e1f 100644 --- a/apps/admin_audit/lib/Actions/UserManagement.php +++ b/apps/admin_audit/lib/Actions/UserManagement.php @@ -100,7 +100,7 @@ class UserManagement extends Action { * @param array $params */ public function change(array $params) { - switch($params['feature']) { + switch ($params['feature']) { case 'enabled': $this->log( $params['value'] === true @@ -130,7 +130,7 @@ class UserManagement extends Action { * @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', [ diff --git a/apps/admin_audit/lib/Actions/Versions.php b/apps/admin_audit/lib/Actions/Versions.php index 612e5a8abd2..8594d781d74 100644 --- a/apps/admin_audit/lib/Actions/Versions.php +++ b/apps/admin_audit/lib/Actions/Versions.php @@ -29,7 +29,6 @@ declare(strict_types=1); namespace OCA\AdminAudit\Actions; class Versions extends Action { - public function rollback(array $params) { $this->log('Version "%s" of "%s" was restored.', [ @@ -46,5 +45,4 @@ class Versions extends Action { ['path'] ); } - } diff --git a/apps/admin_audit/lib/AppInfo/Application.php b/apps/admin_audit/lib/AppInfo/Application.php index 7e6c5410f6e..34c432a078e 100644 --- a/apps/admin_audit/lib/AppInfo/Application.php +++ b/apps/admin_audit/lib/AppInfo/Application.php @@ -74,12 +74,11 @@ class Application extends App { $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() { @@ -152,7 +151,6 @@ class Application extends App { } protected function appHooks() { - $eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher(); $eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE, function (ManagerEvent $event) { $appActions = new AppManagement($this->logger); @@ -166,7 +164,6 @@ class Application extends App { $appActions = new AppManagement($this->logger); $appActions->disableApp($event->getAppID()); }); - } protected function consoleHooks() { diff --git a/apps/admin_audit/lib/BackgroundJobs/Rotate.php b/apps/admin_audit/lib/BackgroundJobs/Rotate.php index 566b11cf375..f6e8f6d875b 100644 --- a/apps/admin_audit/lib/BackgroundJobs/Rotate.php +++ b/apps/admin_audit/lib/BackgroundJobs/Rotate.php @@ -38,14 +38,14 @@ class Rotate extends TimedJob { $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(); } } diff --git a/apps/admin_audit/tests/Actions/SecurityTest.php b/apps/admin_audit/tests/Actions/SecurityTest.php index 2d7560fac09..63453ca0ea0 100644 --- a/apps/admin_audit/tests/Actions/SecurityTest.php +++ b/apps/admin_audit/tests/Actions/SecurityTest.php @@ -73,5 +73,4 @@ class SecurityTest extends TestCase { $this->security->twofactorSuccess($this->user, ['provider' => 'myprovider']); } - } |