wikimedia/mediawiki-core

View on GitHub
includes/user/Options/UserOptionsManager.php

Summary

Maintainability
D
2 days
Test Coverage

File UserOptionsManager.php has 415 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
Severity: Minor
Found in includes/user/Options/UserOptionsManager.php - About 5 hrs to fix

    Function getOptionKinds has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getOptionKinds(
            UserIdentity $userIdentity,
            IContextSource $context,
            $options = null
        ): array {
    Severity: Minor
    Found in includes/user/Options/UserOptionsManager.php - About 4 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

    Function saveOptionsInternal has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        public function saveOptionsInternal( UserIdentity $user, IDatabase $dbw ): bool {
            if ( !$user->isRegistered() || $this->userNameUtils->isTemp( $user->getName() ) ) {
                throw new InvalidArgumentException( __METHOD__ . ' was called on anon or temporary user' );
            }
    
    
    Severity: Minor
    Found in includes/user/Options/UserOptionsManager.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 getOptionKinds has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getOptionKinds(
            UserIdentity $userIdentity,
            IContextSource $context,
            $options = null
        ): array {
    Severity: Major
    Found in includes/user/Options/UserOptionsManager.php - About 2 hrs to fix

      Method saveOptionsInternal has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function saveOptionsInternal( UserIdentity $user, IDatabase $dbw ): bool {
              if ( !$user->isRegistered() || $this->userNameUtils->isTemp( $user->getName() ) ) {
                  throw new InvalidArgumentException( __METHOD__ . ' was called on anon or temporary user' );
              }
      
      
      Severity: Minor
      Found in includes/user/Options/UserOptionsManager.php - About 1 hr to fix

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

            public function resetOptions(
                UserIdentity $user,
                IContextSource $context,
                $resetKinds = [ 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused' ]
            ) {
        Severity: Minor
        Found in includes/user/Options/UserOptionsManager.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 loadOriginalOptions has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function loadOriginalOptions(
                UserIdentity $user,
                int $queryFlags = IDBAccessObject::READ_NORMAL,
                array $data = null
            ): array {
        Severity: Minor
        Found in includes/user/Options/UserOptionsManager.php - About 1 hr to fix

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

              public function getOptions(
                  UserIdentity $user,
                  int $flags = 0,
                  int $queryFlags = IDBAccessObject::READ_NORMAL
              ): array {
          Severity: Minor
          Found in includes/user/Options/UserOptionsManager.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 __construct has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  ServiceOptions $options,
                  DefaultOptionsLookup $defaultOptionsLookup,
                  LanguageConverterFactory $languageConverterFactory,
                  IConnectionProvider $dbProvider,
                  LoggerInterface $logger,
          Severity: Major
          Found in includes/user/Options/UserOptionsManager.php - About 1 hr to fix

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

                private function loadOriginalOptions(
                    UserIdentity $user,
                    int $queryFlags = IDBAccessObject::READ_NORMAL,
                    array $data = null
                ): array {
            Severity: Minor
            Found in includes/user/Options/UserOptionsManager.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

            Method getOption has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    UserIdentity $user,
                    string $oname,
                    $defaultOverride = null,
                    bool $ignoreHidden = false,
                    int $queryFlags = IDBAccessObject::READ_NORMAL
            Severity: Minor
            Found in includes/user/Options/UserOptionsManager.php - About 35 mins to fix

              There are no issues that match your filters.

              Category
              Status