owncloud/core

View on GitHub
apps/files/lib/Controller/ViewController.php

Summary

Maintainability
C
1 day
Test Coverage

Method index has 105 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function index($dir = '', $view = '', $fileid = null, $details = null) {
        $fileNotFound = false;
        if ($fileid !== null) {
            try {
                return $this->showFile($fileid, $details);
Severity: Major
Found in apps/files/lib/Controller/ViewController.php - About 4 hrs to fix

    Method showFile has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function showFile($fileId, $details = null) {
            $uid = $this->userSession->getUser()->getUID();
            $baseFolder = $this->rootFolder->get($uid . '/files/');
            '@phan-var \OCP\Files\Folder $baseFolder';
            $files = $baseFolder->getById($fileId);
    Severity: Minor
    Found in apps/files/lib/Controller/ViewController.php - About 1 hr to fix

      Function index has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function index($dir = '', $view = '', $fileid = null, $details = null) {
              $fileNotFound = false;
              if ($fileid !== null) {
                  try {
                      return $this->showFile($fileid, $details);
      Severity: Minor
      Found in apps/files/lib/Controller/ViewController.php - About 1 hr to fix

      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 showFile has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function showFile($fileId, $details = null) {
              $uid = $this->userSession->getUser()->getUID();
              $baseFolder = $this->rootFolder->get($uid . '/files/');
              '@phan-var \OCP\Files\Folder $baseFolder';
              $files = $baseFolder->getById($fileId);
      Severity: Minor
      Found in apps/files/lib/Controller/ViewController.php - About 1 hr to fix

      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 __construct has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              $appName,
              IRequest $request,
              IURLGenerator $urlGenerator,
              IL10N $l10n,
              IConfig $config,
      Severity: Major
      Found in apps/files/lib/Controller/ViewController.php - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status