apps/files_sharing/lib/External/Manager.php
File Manager.php
has 385 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
/**
* @author Björn Schießle <bjoern@schiessle.org>
* @author Joas Schilling <coding@schilljs.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
Manager
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class Manager {
public const STORAGE = '\OCA\Files_Sharing\External\Storage';
/**
* @var string
Method addShare
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function addShare($remote, $token, $password, $name, $owner, $accepted = false, $user = null, $remoteId = -1) {
$user = $user ? $user : $this->uid;
$accepted = $accepted ? 1 : 0;
$name = Filesystem::normalizePath('/' . $name);
Function testRemoteUrl
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
public function testRemoteUrl(IClientService $clientService, string $remote) {
$parsed_host = parse_url($remote, PHP_URL_HOST);
$parsed_port = parse_url($remote, PHP_URL_PORT);
if (\is_string($parsed_host)) {
$remote = $parsed_host;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method testRemoteUrl
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function testRemoteUrl(IClientService $clientService, string $remote) {
$parsed_host = parse_url($remote, PHP_URL_HOST);
$parsed_port = parse_url($remote, PHP_URL_PORT);
if (\is_string($parsed_host)) {
$remote = $parsed_host;
Method removeShare
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function removeShare($mountPoint) {
if ($this->uid === null) {
throw new NoUserException();
}
Method acceptShare
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function acceptShare($id) {
$share = $this->getShare($id);
if ($share) {
$mountPoint = $this->getShareRecipientMountPoint($share);
Method addShare
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
public function addShare($remote, $token, $password, $name, $owner, $accepted = false, $user = null, $remoteId = -1) {
Method __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
\OCP\IDBConnection $connection,
\OC\Files\Mount\Manager $mountManager,
\OCP\Files\Storage\IStorageFactory $storageLoader,
IManager $notificationManager,
EventDispatcherInterface $eventDispatcher,
Function testUrl
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function testUrl(IClientService $clientService, string $remote, bool $checkVersion = false, bool $throwConnectException = false): bool {
try {
$client = $clientService->newClient();
$response = \json_decode($client->get(
$remote,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"