owncloud/core

View on GitHub
lib/private/Repair/Apps.php

Summary

Maintainability
D
1 day
Test Coverage

Function run has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public function run(IOutput $output) {
        if ($this->config->getSystemValue('has_internet_connection', true) !== true) {
            $link = $this->defaults->buildDocLinkToKey('admin-marketplace-apps');
            $output->info('No internet connection available - no app updates will be taken from the marketplace.');
            $output->info("How to update apps in such situation please see $link");
Severity: Minor
Found in lib/private/Repair/Apps.php - About 3 hrs 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

File Apps.php has 283 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @author Viktar Dubiniuk <dubiniuk@owncloud.com>
 *
 * @copyright Copyright (c) 2018, ownCloud GmbH
Severity: Minor
Found in lib/private/Repair/Apps.php - About 2 hrs to fix

    Method run has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function run(IOutput $output) {
            if ($this->config->getSystemValue('has_internet_connection', true) !== true) {
                $link = $this->defaults->buildDocLinkToKey('admin-marketplace-apps');
                $output->info('No internet connection available - no app updates will be taken from the marketplace.');
                $output->info("How to update apps in such situation please see $link");
    Severity: Major
    Found in lib/private/Repair/Apps.php - About 2 hrs to fix

      Function getAppsFromMarket has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function getAppsFromMarket(IOutput $output, $appList, $event) {
              $failedApps = [];
              foreach ($appList as $app) {
                  $output->info("Fetching app from market: $app");
                  try {
      Severity: Minor
      Found in lib/private/Repair/Apps.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 getAppsFromMarket has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function getAppsFromMarket(IOutput $output, $appList, $event) {
              $failedApps = [];
              foreach ($appList as $app) {
                  $output->info("Fetching app from market: $app");
                  try {
      Severity: Minor
      Found in lib/private/Repair/Apps.php - About 1 hr to fix

        Method changeSchema has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function changeSchema(Schema $schema, array $options) {
                $prefix = $options['tablePrefix'];
                if ($schema->hasTable("{$prefix}jobs")) {
                    $jobsTable = $schema->getTable("{$prefix}jobs");
        
        
        Severity: Minor
        Found in lib/private/Repair/Apps.php - About 1 hr to fix

          Method fixMarketAppState has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function fixMarketAppState(IOutput $output) {
                  // no core update -> nothing to do
                  if (!$this->isCoreUpdate()) {
                      return false;
                  }
          Severity: Minor
          Found in lib/private/Repair/Apps.php - About 1 hr to fix

            Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function __construct(IAppManager $appManager, EventDispatcherInterface $eventDispatcher, IConfig $config, \OC_Defaults $defaults, $forceMajorUpgrade = false) {
            Severity: Minor
            Found in lib/private/Repair/Apps.php - About 35 mins to fix

              Function changeSchema has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function changeSchema(Schema $schema, array $options) {
                      $prefix = $options['tablePrefix'];
                      if ($schema->hasTable("{$prefix}jobs")) {
                          $jobsTable = $schema->getTable("{$prefix}jobs");
              
              
              Severity: Minor
              Found in lib/private/Repair/Apps.php - About 35 mins 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

              Avoid too many return statements within this method.
              Open

                          return false;
              Severity: Major
              Found in lib/private/Repair/Apps.php - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status