bcit-ci/CodeIgniter

View on GitHub
system/libraries/Session/drivers/Session_files_driver.php

Summary

Maintainability
C
1 day
Test Coverage

Function write has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function write($session_id, $session_data)
    {
        // If the two IDs don't match, we have a session_regenerate_id() call
        // and we need to close the old handle and open a new one
        if ($session_id !== $this->_session_id && ($this->close() === $this->_failure OR $this->read($session_id) === $this->_failure))
Severity: Minor
Found in system/libraries/Session/drivers/Session_files_driver.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 read has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function read($session_id)
    {
        // This might seem weird, but PHP 5.6 introduces session_reset(),
        // which re-reads session data
        if ($this->_file_handle === NULL)
Severity: Minor
Found in system/libraries/Session/drivers/Session_files_driver.php - About 1 hr to fix

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

        public function read($session_id)
        {
            // This might seem weird, but PHP 5.6 introduces session_reset(),
            // which re-reads session data
            if ($this->_file_handle === NULL)
    Severity: Minor
    Found in system/libraries/Session/drivers/Session_files_driver.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 write has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function write($session_id, $session_data)
        {
            // If the two IDs don't match, we have a session_regenerate_id() call
            // and we need to close the old handle and open a new one
            if ($session_id !== $this->_session_id && ($this->close() === $this->_failure OR $this->read($session_id) === $this->_failure))
    Severity: Minor
    Found in system/libraries/Session/drivers/Session_files_driver.php - About 1 hr to fix

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

          public function gc($maxlifetime)
          {
              if ( ! is_dir($this->_config['save_path']) OR ($directory = opendir($this->_config['save_path'])) === FALSE)
              {
                  log_message('debug', "Session: Garbage collector couldn't list files under directory '".$this->_config['save_path']."'.");
      Severity: Minor
      Found in system/libraries/Session/drivers/Session_files_driver.php - About 1 hr to fix

        Avoid too many return statements within this method.
        Open

                return $this->_success;
        Severity: Major
        Found in system/libraries/Session/drivers/Session_files_driver.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return $session_data;
          Severity: Major
          Found in system/libraries/Session/drivers/Session_files_driver.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return $this->_failure;
            Severity: Major
            Found in system/libraries/Session/drivers/Session_files_driver.php - About 30 mins to fix

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

                  public function destroy($session_id)
                  {
                      if ($this->close() === $this->_success)
                      {
                          if (file_exists($this->_file_path.$session_id))
              Severity: Minor
              Found in system/libraries/Session/drivers/Session_files_driver.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