bcit-ci/CodeIgniter

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

Summary

Maintainability
C
1 day
Test Coverage

Method open has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function open($save_path, $name)
    {
        $this->_memcached = new Memcached();
        $this->_memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, TRUE); // required for touch() usage
        $server_list = array();
Severity: Minor
Found in system/libraries/Session/drivers/Session_memcached_driver.php - About 1 hr to fix

    Method _get_lock has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function _get_lock($session_id)
        {
            // PHP 7 reuses the SessionHandler object on regeneration,
            // so we need to check here if the lock key is for the
            // correct session ID.
    Severity: Minor
    Found in system/libraries/Session/drivers/Session_memcached_driver.php - About 1 hr to fix

      Method write has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function write($session_id, $session_data)
          {
              if ( ! isset($this->_memcached, $this->_lock_key))
              {
                  return $this->_fail();
      Severity: Minor
      Found in system/libraries/Session/drivers/Session_memcached_driver.php - About 1 hr to fix

        Function open has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function open($save_path, $name)
            {
                $this->_memcached = new Memcached();
                $this->_memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, TRUE); // required for touch() usage
                $server_list = array();
        Severity: Minor
        Found in system/libraries/Session/drivers/Session_memcached_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

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

            public function write($session_id, $session_data)
            {
                if ( ! isset($this->_memcached, $this->_lock_key))
                {
                    return $this->_fail();
        Severity: Minor
        Found in system/libraries/Session/drivers/Session_memcached_driver.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

        Function _get_lock has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function _get_lock($session_id)
            {
                // PHP 7 reuses the SessionHandler object on regeneration,
                // so we need to check here if the lock key is for the
                // correct session ID.
        Severity: Minor
        Found in system/libraries/Session/drivers/Session_memcached_driver.php - About 45 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 $this->_success;
        Severity: Major
        Found in system/libraries/Session/drivers/Session_memcached_driver.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return $this->_fail();
          Severity: Major
          Found in system/libraries/Session/drivers/Session_memcached_driver.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

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

              There are no issues that match your filters.

              Category
              Status