File Google.php
has 612 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @author Adam Williamson <awilliam@redhat.com>
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Bart Visscher <bartv@thisnet.nl>
Function opendir
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
public function opendir($path) {
$folder = $this->getDriveFile($path);
if ($folder) {
$files = [];
$duplicates = [];
- 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
Function getInternalDriveFile
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
private function getInternalDriveFile($path) {
// Remove leading and trailing slashes
$path = \trim($path, '/');
if ($path === '.') {
$path = '';
- 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
Function writeBack
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public function writeBack($tmpFile) {
if (isset(self::$tempFiles[$tmpFile])) {
$path = self::$tempFiles[$tmpFile];
$parentFolder = $this->getDriveFile(\dirname($path));
if ($parentFolder) {
- 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
Google
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class Google extends \OCP\Files\Storage\StorageAdapter {
private $client;
private $id;
private $root;
private $service;
Function rename
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function rename($path1, $path2) {
$file = $this->getDriveFile($path1);
if ($file) {
$newFile = $this->getDriveFile($path2);
$toUpdate = new DriveFile();
- 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
Function fopen
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function fopen($path, $mode) {
$pos = \strrpos($path, '.');
if ($pos !== false) {
$ext = \substr($path, $pos);
} else {
- 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 writeBack
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function writeBack($tmpFile) {
if (isset(self::$tempFiles[$tmpFile])) {
$path = self::$tempFiles[$tmpFile];
$parentFolder = $this->getDriveFile(\dirname($path));
if ($parentFolder) {
Method getInternalDriveFile
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getInternalDriveFile($path) {
// Remove leading and trailing slashes
$path = \trim($path, '/');
if ($path === '.') {
$path = '';
Function rmdir
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function rmdir($path) {
if (!$this->isDeletable($path)) {
return false;
}
if (\trim($path, '/') === '') {
- 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 fopen
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fopen($path, $mode) {
$pos = \strrpos($path, '.');
if ($pos !== false) {
$ext = \substr($path, $pos);
} else {
Method opendir
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function opendir($path) {
$folder = $this->getDriveFile($path);
if ($folder) {
$files = [];
$duplicates = [];
Method rename
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function rename($path1, $path2) {
$file = $this->getDriveFile($path1);
if ($file) {
$newFile = $this->getDriveFile($path2);
$toUpdate = new DriveFile();
Function hasUpdated
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function hasUpdated($path, $time) {
if ($this->is_file($path)) {
return parent::hasUpdated($path, $time);
}
- 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 touch
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function touch($path, $mtime = null) {
$file = $this->getDriveFile($path);
$toUpdate = new DriveFile();
$result = false;
if ($file) {
Method hasUpdated
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function hasUpdated($path, $time) {
if ($this->is_file($path)) {
return parent::hasUpdated($path, $time);
}
Function getMimeType
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getMimeType($path) {
$file = $this->getDriveFile($path);
if ($file) {
$mimetype = $file->getMimeType();
// Convert Google Doc mimetypes, choosing Open Document formats for download
- 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
Function filetype
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function filetype($path) {
if ($this->getAbsolutePath($path) === '') {
return 'dir';
} else {
$file = $this->getDriveFile($path);
- 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
Function touch
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function touch($path, $mtime = null) {
$file = $this->getDriveFile($path);
$toUpdate = new DriveFile();
$result = false;
if ($file) {
- 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
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $this->driveFiles[$path];
Avoid too many return
statements within this method. Open
return '';
Avoid too many return
statements within this method. Open
return 'application/pdf';
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return parent::getMimeType($path);
Function setDriveFileHelper
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function setDriveFileHelper($path, $file) {
$path = \trim($path, '/');
$this->driveFiles[$path] = $file;
if ($file === false) {
// Remove all children
- 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
Function mkdir
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function mkdir($path) {
if (!$this->is_dir($path)) {
$parentFolder = $this->getDriveFile(\dirname($path));
if ($parentFolder) {
$folder = new DriveFile();
- 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"