owncloud/core

View on GitHub
core/Command/Config/System/SetConfig.php

Summary

Maintainability
B
6 hrs
Test Coverage

Method castValue has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function castValue($value, $type) {
        switch ($type) {
            case 'integer':
            case 'int':
                if (!\is_numeric($value)) {
Severity: Major
Found in core/Command/Config/System/SetConfig.php - About 2 hrs to fix

    Method configure has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function configure() {
            parent::configure();
    
            $this
                ->setName('config:system:set')
    Severity: Minor
    Found in core/Command/Config/System/SetConfig.php - About 1 hr to fix

      Function mergeArrayValue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function mergeArrayValue(array $configNames, $existingValues, $value, $updateOnly) {
              $configName = \array_shift($configNames);
              if (!\is_array($existingValues)) {
                  $existingValues = [];
              }
      Severity: Minor
      Found in core/Command/Config/System/SetConfig.php - About 55 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 [
                          'value' => $decodedJson,
                          'readable-value' => 'json ' . $value,
                      ];
      Severity: Major
      Found in core/Command/Config/System/SetConfig.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return [
                            'value' => null,
                            'readable-value' => 'null',
                        ];
        Severity: Major
        Found in core/Command/Config/System/SetConfig.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return [
                              'value' => $value,
                              'readable-value' => ($value === '') ? 'empty string' : 'string ' . $value,
                          ];
          Severity: Major
          Found in core/Command/Config/System/SetConfig.php - About 30 mins to fix

            Function execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function execute(InputInterface $input, OutputInterface $output): int {
                    $configNames = $input->getArgument('name');
                    $configName = $configNames[0];
                    $configValue = $this->castValue($input->getOption('value'), $input->getOption('type'));
                    $updateOnly = $input->getOption('update-only');
            Severity: Minor
            Found in core/Command/Config/System/SetConfig.php - About 25 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

            There are no issues that match your filters.

            Category
            Status