wikimedia/mediawiki-core

View on GitHub
includes/session/Session.php

Summary

Maintainability
D
1 day
Test Coverage

Session has 50 functions (exceeds 20 allowed). Consider refactoring.
Open

class Session implements \Countable, \Iterator, \ArrayAccess {
    /** @var null|string[] Encryption algorithm to use */
    private static $encryptionAlgorithm = null;

    /** @var SessionBackend Session backend */
Severity: Minor
Found in includes/session/Session.php - About 7 hrs to fix

    File Session.php has 315 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * MediaWiki session
     *
     * This program is free software; you can redistribute it and/or modify
    Severity: Minor
    Found in includes/session/Session.php - About 3 hrs to fix

      Method getSecret has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getSecret( $key, $default = null ) {
              // Fetch
              $encrypted = $this->get( $key, null );
              if ( $encrypted === null ) {
                  return $default;
      Severity: Minor
      Found in includes/session/Session.php - About 1 hr to fix

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

            private static function getEncryptionAlgorithm() {
                if ( self::$encryptionAlgorithm === null ) {
                    if ( function_exists( 'openssl_encrypt' ) ) {
                        $methods = openssl_get_cipher_methods();
                        if ( in_array( 'aes-256-ctr', $methods, true ) ) {
        Severity: Minor
        Found in includes/session/Session.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 getSecret has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getSecret( $key, $default = null ) {
                // Fetch
                $encrypted = $this->get( $key, null );
                if ( $encrypted === null ) {
                    return $default;
        Severity: Minor
        Found in includes/session/Session.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 $value;
        Severity: Major
        Found in includes/session/Session.php - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status