summaryrefslogtreecommitdiffstats
path: root/apps/federation
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-04-10 14:19:56 +0200
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-04-10 14:19:56 +0200
commitcaff1023ea72bb2ea94130e18a2a6e2ccf819e5f (patch)
tree186d494c2aea5dea7255d3584ef5d595fc6e6194 /apps/federation
parentedf8ce32cffdb920e8171207b342abbd7f1fbe73 (diff)
downloadnextcloud-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/federation')
-rw-r--r--apps/federation/lib/AppInfo/Application.php2
-rw-r--r--apps/federation/lib/BackgroundJob/GetSharedSecret.php2
-rw-r--r--apps/federation/lib/BackgroundJob/RequestSharedSecret.php3
-rw-r--r--apps/federation/lib/Command/SyncFederationAddressBooks.php2
-rw-r--r--apps/federation/lib/Controller/OCSAuthAPIController.php3
-rw-r--r--apps/federation/lib/Controller/SettingsController.php1
-rw-r--r--apps/federation/lib/DbHandler.php1
-rw-r--r--apps/federation/lib/Hooks.php1
-rw-r--r--apps/federation/lib/Middleware/AddServerMiddleware.php2
-rw-r--r--apps/federation/lib/Settings/Admin.php1
-rw-r--r--apps/federation/lib/SyncFederationAddressBooks.php1
-rw-r--r--apps/federation/lib/TrustedServers.php3
-rw-r--r--apps/federation/templates/settings-admin.php10
-rw-r--r--apps/federation/tests/BackgroundJob/GetSharedSecretTest.php1
-rw-r--r--apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php2
-rw-r--r--apps/federation/tests/Controller/OCSAuthAPIControllerTest.php6
-rw-r--r--apps/federation/tests/Controller/SettingsControllerTest.php3
-rw-r--r--apps/federation/tests/HooksTest.php1
-rw-r--r--apps/federation/tests/Middleware/AddServerMiddlewareTest.php2
-rw-r--r--apps/federation/tests/TrustedServersTest.php3
20 files changed, 8 insertions, 42 deletions
diff --git a/apps/federation/lib/AppInfo/Application.php b/apps/federation/lib/AppInfo/Application.php
index 119756b16e4..cc5f63309af 100644
--- a/apps/federation/lib/AppInfo/Application.php
+++ b/apps/federation/lib/AppInfo/Application.php
@@ -57,7 +57,6 @@ class Application extends App {
* list of trusted servers.
*/
public function registerHooks() {
-
$container = $this->getContainer();
$hooksManager = $container->query(Hooks::class);
@@ -81,5 +80,4 @@ class Application extends App {
}
});
}
-
}
diff --git a/apps/federation/lib/BackgroundJob/GetSharedSecret.php b/apps/federation/lib/BackgroundJob/GetSharedSecret.php
index ad526885d0f..c86c7f1d75a 100644
--- a/apps/federation/lib/BackgroundJob/GetSharedSecret.php
+++ b/apps/federation/lib/BackgroundJob/GetSharedSecret.php
@@ -181,7 +181,6 @@ class GetSharedSecret extends Job {
);
$status = $result->getStatusCode();
-
} catch (ClientException $e) {
$status = $e->getCode();
if ($status === Http::STATUS_FORBIDDEN) {
@@ -232,7 +231,6 @@ class GetSharedSecret extends Job {
$this->trustedServers->setServerStatus($target, TrustedServers::STATUS_FAILURE);
}
}
-
}
/**
diff --git a/apps/federation/lib/BackgroundJob/RequestSharedSecret.php b/apps/federation/lib/BackgroundJob/RequestSharedSecret.php
index 4eaa94a53d5..990f5025bf5 100644
--- a/apps/federation/lib/BackgroundJob/RequestSharedSecret.php
+++ b/apps/federation/lib/BackgroundJob/RequestSharedSecret.php
@@ -142,7 +142,6 @@ class RequestSharedSecret extends Job {
}
protected function run($argument) {
-
$target = $argument['url'];
$created = isset($argument['created']) ? (int)$argument['created'] : $this->timeFactory->getTime();
$currentTime = $this->timeFactory->getTime();
@@ -179,7 +178,6 @@ class RequestSharedSecret extends Job {
);
$status = $result->getStatusCode();
-
} catch (ClientException $e) {
$status = $e->getCode();
if ($status === Http::STATUS_FORBIDDEN) {
@@ -205,7 +203,6 @@ class RequestSharedSecret extends Job {
) {
$this->retainJob = true;
}
-
}
/**
diff --git a/apps/federation/lib/Command/SyncFederationAddressBooks.php b/apps/federation/lib/Command/SyncFederationAddressBooks.php
index cad000cf71f..709cd60b3ba 100644
--- a/apps/federation/lib/Command/SyncFederationAddressBooks.php
+++ b/apps/federation/lib/Command/SyncFederationAddressBooks.php
@@ -57,13 +57,11 @@ class SyncFederationAddressBooks extends Command {
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output) {
-
$progress = new ProgressBar($output);
$progress->start();
$this->syncService->syncThemAll(function ($url, $ex) use ($progress, $output) {
if ($ex instanceof \Exception) {
$output->writeln("Error while syncing $url : " . $ex->getMessage());
-
} else {
$progress->advance();
}
diff --git a/apps/federation/lib/Controller/OCSAuthAPIController.php b/apps/federation/lib/Controller/OCSAuthAPIController.php
index 38293dca736..ecd0757f6fb 100644
--- a/apps/federation/lib/Controller/OCSAuthAPIController.php
+++ b/apps/federation/lib/Controller/OCSAuthAPIController.php
@@ -46,7 +46,7 @@ use OCP\Security\ISecureRandom;
*
* @package OCA\Federation\Controller
*/
-class OCSAuthAPIController extends OCSController{
+class OCSAuthAPIController extends OCSController {
/** @var ISecureRandom */
private $secureRandom;
@@ -181,7 +181,6 @@ class OCSAuthAPIController extends OCSController{
* @throws OCSForbiddenException
*/
public function getSharedSecret($url, $token) {
-
if ($this->trustedServers->isTrustedServer($url) === false) {
$this->logger->error('remote server not trusted (' . $url . ') while getting shared secret', ['app' => 'federation']);
throw new OCSForbiddenException();
diff --git a/apps/federation/lib/Controller/SettingsController.php b/apps/federation/lib/Controller/SettingsController.php
index 00b2885f66d..7f68f238366 100644
--- a/apps/federation/lib/Controller/SettingsController.php
+++ b/apps/federation/lib/Controller/SettingsController.php
@@ -119,5 +119,4 @@ class SettingsController extends Controller {
return true;
}
-
}
diff --git a/apps/federation/lib/DbHandler.php b/apps/federation/lib/DbHandler.php
index 6adad5b69d1..dddb7e13297 100644
--- a/apps/federation/lib/DbHandler.php
+++ b/apps/federation/lib/DbHandler.php
@@ -330,5 +330,4 @@ class DbHandler {
$statement->closeCursor();
return !empty($result);
}
-
}
diff --git a/apps/federation/lib/Hooks.php b/apps/federation/lib/Hooks.php
index 3f6a45422a7..f02409ef242 100644
--- a/apps/federation/lib/Hooks.php
+++ b/apps/federation/lib/Hooks.php
@@ -44,5 +44,4 @@ class Hooks {
$this->trustedServers->addServer($params['server']);
}
}
-
}
diff --git a/apps/federation/lib/Middleware/AddServerMiddleware.php b/apps/federation/lib/Middleware/AddServerMiddleware.php
index 043d10d0455..ffce7710223 100644
--- a/apps/federation/lib/Middleware/AddServerMiddleware.php
+++ b/apps/federation/lib/Middleware/AddServerMiddleware.php
@@ -87,7 +87,5 @@ class AddServerMiddleware extends Middleware {
['message' => $message],
Http::STATUS_BAD_REQUEST
);
-
}
-
}
diff --git a/apps/federation/lib/Settings/Admin.php b/apps/federation/lib/Settings/Admin.php
index d363397e9e7..9dd06dc8f53 100644
--- a/apps/federation/lib/Settings/Admin.php
+++ b/apps/federation/lib/Settings/Admin.php
@@ -65,5 +65,4 @@ class Admin implements ISettings {
public function getPriority() {
return 30;
}
-
}
diff --git a/apps/federation/lib/SyncFederationAddressBooks.php b/apps/federation/lib/SyncFederationAddressBooks.php
index f0e3d2ba38b..3ec233df037 100644
--- a/apps/federation/lib/SyncFederationAddressBooks.php
+++ b/apps/federation/lib/SyncFederationAddressBooks.php
@@ -60,7 +60,6 @@ class SyncFederationAddressBooks {
* @param \Closure $callback
*/
public function syncThemAll(\Closure $callback) {
-
$trustedServers = $this->dbHandler->getAllServer();
foreach ($trustedServers as $trustedServer) {
$url = $trustedServer['url'];
diff --git a/apps/federation/lib/TrustedServers.php b/apps/federation/lib/TrustedServers.php
index 2a3a2d809b9..3d659e7eb95 100644
--- a/apps/federation/lib/TrustedServers.php
+++ b/apps/federation/lib/TrustedServers.php
@@ -239,7 +239,6 @@ class TrustedServers {
);
if ($result->getStatusCode() === Http::STATUS_OK) {
$isValidOwnCloud = $this->checkOwnCloudVersion($result->getBody());
-
}
} catch (\Exception $e) {
\OC::$server->getLogger()->logException($e, [
@@ -282,9 +281,7 @@ class TrustedServers {
strpos($url, 'https://') === 0
|| strpos($url, 'http://') === 0
) {
-
return $url;
-
}
return 'https://' . $url;
diff --git a/apps/federation/templates/settings-admin.php b/apps/federation/templates/settings-admin.php
index f0c2db81961..2bc3684ccd9 100644
--- a/apps/federation/templates/settings-admin.php
+++ b/apps/federation/templates/settings-admin.php
@@ -11,17 +11,19 @@ style('federation', 'settings-admin')
<p class="settings-hint"><?php p($l->t('Federation allows you to connect with other trusted servers to exchange the user directory. For example this will be used to auto-complete external users for federated sharing.')); ?></p>
<p>
- <input id="autoAddServers" type="checkbox" class="checkbox" <?php if($_['autoAddServers']) p('checked'); ?> />
+ <input id="autoAddServers" type="checkbox" class="checkbox" <?php if ($_['autoAddServers']) {
+ p('checked');
+} ?> />
<label for="autoAddServers"><?php p($l->t('Add server automatically once a federated share was created successfully')); ?></label>
</p>
<ul id="listOfTrustedServers">
- <?php foreach($_['trustedServers'] as $trustedServer) { ?>
+ <?php foreach ($_['trustedServers'] as $trustedServer) { ?>
<li id="<?php p($trustedServer['id']); ?>">
- <?php if((int)$trustedServer['status'] === TrustedServers::STATUS_OK) { ?>
+ <?php if ((int)$trustedServer['status'] === TrustedServers::STATUS_OK) { ?>
<span class="status success"></span>
<?php
- } elseif(
+ } elseif (
(int)$trustedServer['status'] === TrustedServers::STATUS_PENDING ||
(int)$trustedServer['status'] === TrustedServers::STATUS_ACCESS_REVOKED
) { ?>
diff --git a/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php b/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php
index ba84d718df6..691b9fb19a4 100644
--- a/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php
+++ b/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php
@@ -158,7 +158,6 @@ class GetSharedSecretTest extends TestCase {
}
$getSharedSecret->execute($this->jobList);
-
}
public function dataTestExecute() {
diff --git a/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php b/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php
index f35654b0895..2ef6fd4250d 100644
--- a/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php
+++ b/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php
@@ -150,7 +150,6 @@ class RequestSharedSecretTest extends TestCase {
}
$requestSharedSecret->execute($this->jobList);
-
}
public function dataTestExecute() {
@@ -167,7 +166,6 @@ class RequestSharedSecretTest extends TestCase {
* @param int $statusCode
*/
public function testRun($statusCode) {
-
$target = 'targetURL';
$source = 'sourceURL';
$token = 'token';
diff --git a/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php b/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php
index c8a79748534..791928a8ccc 100644
--- a/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php
+++ b/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php
@@ -91,7 +91,6 @@ class OCSAuthAPIControllerTest extends TestCase {
$this->timeFactory->method('getTime')
->willReturn($this->currentTime);
-
}
/**
@@ -103,7 +102,6 @@ class OCSAuthAPIControllerTest extends TestCase {
* @param bool $ok
*/
public function testRequestSharedSecret($token, $localToken, $isTrustedServer, $ok) {
-
$url = 'url';
$this->trustedServers
@@ -144,7 +142,6 @@ class OCSAuthAPIControllerTest extends TestCase {
* @param bool $ok
*/
public function testGetSharedSecret($isTrustedServer, $isValidToken, $ok) {
-
$url = 'url';
$token = 'token';
@@ -169,7 +166,7 @@ class OCSAuthAPIControllerTest extends TestCase {
$ocsAuthApi->expects($this->any())
->method('isValidToken')->with($url, $token)->willReturn($isValidToken);
- if($ok) {
+ if ($ok) {
$this->secureRandom->expects($this->once())->method('generate')->with(32)
->willReturn('secret');
$this->trustedServers->expects($this->once())
@@ -197,5 +194,4 @@ class OCSAuthAPIControllerTest extends TestCase {
[false, false, false],
];
}
-
}
diff --git a/apps/federation/tests/Controller/SettingsControllerTest.php b/apps/federation/tests/Controller/SettingsControllerTest.php
index 48c9b91268a..90db0b58035 100644
--- a/apps/federation/tests/Controller/SettingsControllerTest.php
+++ b/apps/federation/tests/Controller/SettingsControllerTest.php
@@ -127,7 +127,6 @@ class SettingsControllerTest extends TestCase {
$this->assertTrue(
$this->invokePrivate($this->controller, 'checkServer', ['url'])
);
-
}
/**
@@ -153,7 +152,6 @@ class SettingsControllerTest extends TestCase {
$this->assertTrue(
$this->invokePrivate($this->controller, 'checkServer', ['url'])
);
-
}
/**
@@ -167,5 +165,4 @@ class SettingsControllerTest extends TestCase {
[false, false]
];
}
-
}
diff --git a/apps/federation/tests/HooksTest.php b/apps/federation/tests/HooksTest.php
index 0bbf2bfb7ac..afb6b2408f9 100644
--- a/apps/federation/tests/HooksTest.php
+++ b/apps/federation/tests/HooksTest.php
@@ -66,7 +66,6 @@ class HooksTest extends TestCase {
}
$this->hooks->addServerHook(['server' => 'url']);
-
}
public function dataTestAddServerHook() {
diff --git a/apps/federation/tests/Middleware/AddServerMiddlewareTest.php b/apps/federation/tests/Middleware/AddServerMiddlewareTest.php
index a43ad557dae..a50f5e5851f 100644
--- a/apps/federation/tests/Middleware/AddServerMiddlewareTest.php
+++ b/apps/federation/tests/Middleware/AddServerMiddlewareTest.php
@@ -70,7 +70,6 @@ class AddServerMiddlewareTest extends TestCase {
* @param string $hint
*/
public function testAfterException($exception, $hint) {
-
$this->logger->expects($this->once())->method('logException');
$this->l10n->expects($this->any())->method('t')
@@ -99,5 +98,4 @@ class AddServerMiddlewareTest extends TestCase {
[new \Exception('message'), 'message'],
];
}
-
}
diff --git a/apps/federation/tests/TrustedServersTest.php b/apps/federation/tests/TrustedServersTest.php
index 59b1c577e75..67814ee96ac 100644
--- a/apps/federation/tests/TrustedServersTest.php
+++ b/apps/federation/tests/TrustedServersTest.php
@@ -100,7 +100,6 @@ class TrustedServersTest extends TestCase {
$this->dispatcher,
$this->timeFactory
);
-
}
/**
@@ -267,7 +266,6 @@ class TrustedServersTest extends TestCase {
* @param bool $expected
*/
public function testIsOwnCloudServer($statusCode, $isValidOwnCloudVersion, $expected) {
-
$server = 'server1';
/** @var \PHPUnit_Framework_MockObject_MockObject | TrustedServers $trustedServers */
@@ -306,7 +304,6 @@ class TrustedServersTest extends TestCase {
$this->assertSame($expected,
$trustedServers->isOwnCloudServer($server)
);
-
}
public function dataTestIsOwnCloudServer() {