piotrpolak/pepiscms

View on GitHub
pepiscms/application/models/Siteconfig_model.php

Summary

Maintainability
D
2 days
Test Coverage

File Siteconfig_model.php has 369 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * PepisCMS
 *
Severity: Minor
Found in pepiscms/application/models/Siteconfig_model.php - About 4 hrs to fix

    Function makeConfigurationTestsAngGetErrors has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        public function makeConfigurationTestsAngGetErrors()
        {
            $cache_path = $this->config->item('cache_path');
            $cache_path = ($cache_path === '') ? 'application/cache/' : $cache_path;
            if ($cache_path[0] !== '/') {
    Severity: Minor
    Found in pepiscms/application/models/Siteconfig_model.php - About 2 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

    Method getAvailableTimezones has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getAvailableTimezones()
        {
            $tz = array(
                'Europe/Amsterdam',
                'Europe/Andorra',
    Severity: Major
    Found in pepiscms/application/models/Siteconfig_model.php - About 2 hrs to fix

      Function saveAllConfigurationVariables has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function saveAllConfigurationVariables($data)
          {
              $known_config_data = (array)$this->getAllConfigurationVariables();
      
              $data = array_merge($known_config_data, $data);
      Severity: Minor
      Found in pepiscms/application/models/Siteconfig_model.php - About 2 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

      Method makeConfigurationTestsAngGetErrors has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function makeConfigurationTestsAngGetErrors()
          {
              $cache_path = $this->config->item('cache_path');
              $cache_path = ($cache_path === '') ? 'application/cache/' : $cache_path;
              if ($cache_path[0] !== '/') {
      Severity: Minor
      Found in pepiscms/application/models/Siteconfig_model.php - About 1 hr to fix

        Method saveConfigByName has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function saveConfigByName($name, $value, $module = null)
            {
                $entry = $this->getByName($name);
        
                $id = false;
        Severity: Minor
        Found in pepiscms/application/models/Siteconfig_model.php - About 1 hr to fix

          Method saveAllConfigurationVariables has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function saveAllConfigurationVariables($data)
              {
                  $known_config_data = (array)$this->getAllConfigurationVariables();
          
                  $data = array_merge($known_config_data, $data);
          Severity: Minor
          Found in pepiscms/application/models/Siteconfig_model.php - About 1 hr to fix

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

                public function saveConfigByName($name, $value, $module = null)
                {
                    $entry = $this->getByName($name);
            
                    $id = false;
            Severity: Minor
            Found in pepiscms/application/models/Siteconfig_model.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 $obj->value;
            Severity: Major
            Found in pepiscms/application/models/Siteconfig_model.php - About 30 mins to fix

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

                  public function getAvailableThemes()
                  {
                      $theme_path = $this->config->item('theme_path');
                      $dir = opendir($theme_path);
              
              
              Severity: Minor
              Found in pepiscms/application/models/Siteconfig_model.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

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

                  private function toValue($obj)
                  {
                      if ($obj->is_serialized) {
                          return json_decode($obj->value);
                      } elseif ($obj->is_boolean) {
              Severity: Minor
              Found in pepiscms/application/models/Siteconfig_model.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