Function doAppUpgrade
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
protected function doAppUpgrade() {
$apps = \OC_App::getEnabledApps();
$priorityTypes = ['authentication', 'filesystem', 'logging'];
$pseudoOtherType = 'other';
$stacks = [$pseudoOtherType => []];
- 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 doUpgrade
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function doUpgrade($currentVersion, $installedVersion) {
// Stop update if the update is over several major versions
$allowedPreviousVersions = $this->getAllowedPreviousVersions();
if (!self::isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) {
throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
Method doAppUpgrade
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doAppUpgrade() {
$apps = \OC_App::getEnabledApps();
$priorityTypes = ['authentication', 'filesystem', 'logging'];
$pseudoOtherType = 'other';
$stacks = [$pseudoOtherType => []];
Method upgrade
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function upgrade() {
$this->emitRepairEvents();
$logLevel = $this->config->getSystemValue('loglevel', Util::WARN);
$this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
Function isUpgradePossible
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function isUpgradePossible($oldVersion, $newVersion, $allowedPreviousVersions) {
// TODO: write tests for this, since i just wrapped it to get started with migrations and this might fail in some cases
foreach ($allowedPreviousVersions as $allowedPreviousVersion) {
$allowedUpgrade = (\version_compare($allowedPreviousVersion, $oldVersion, '<=')
&& (\version_compare($oldVersion, $newVersion, '<=') || $this->config->getSystemValue('debug', false)));
- 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 doUpgrade
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function doUpgrade($currentVersion, $installedVersion) {
// Stop update if the update is over several major versions
$allowedPreviousVersions = $this->getAllowedPreviousVersions();
if (!self::isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) {
throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
- 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"