wikimedia/mediawiki-core

View on GitHub
maintenance/userOptions.php

Summary

Maintainability
D
2 days
Test Coverage

Function showUsageStats has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    private function showUsageStats() {
        $option = $this->getArg( 0 );

        $ret = [];
        $userOptionsLookup = $this->getServiceContainer()->getUserOptionsLookup();
Severity: Minor
Found in maintenance/userOptions.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

File userOptions.php has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Script to change users preferences on the fly.
 *
 * Made on an original idea by Fooey (freenode)
Severity: Minor
Found in maintenance/userOptions.php - About 2 hrs to fix

    Function deleteOptions has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        private function deleteOptions() {
            $dryRun = $this->hasOption( 'dry' );
            $option = $this->getArg( 0 );
            $fromUserId = (int)$this->getOption( 'fromuserid', 0 );
            $toUserId = (int)$this->getOption( 'touserid', 0 ) ?: null;
    Severity: Minor
    Found in maintenance/userOptions.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 updateOptions has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function updateOptions() {
            $dryRun = $this->hasOption( 'dry' );
            $settingWord = $dryRun ? 'Would set' : 'Setting';
            $option = $this->getArg( 0 );
            $fromIsDefault = $this->hasOption( 'old-is-default' );
    Severity: Major
    Found in maintenance/userOptions.php - About 2 hrs to fix

      Method deleteOptions has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function deleteOptions() {
              $dryRun = $this->hasOption( 'dry' );
              $option = $this->getArg( 0 );
              $fromUserId = (int)$this->getOption( 'fromuserid', 0 );
              $toUserId = (int)$this->getOption( 'touserid', 0 ) ?: null;
      Severity: Major
      Found in maintenance/userOptions.php - About 2 hrs to fix

        Method deleteDefaults has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function deleteDefaults() {
                $dryRun = $this->hasOption( 'dry' );
                $option = $this->getArg( 0 );
                $fromUserId = (int)$this->getOption( 'fromuserid', 0 );
                $toUserId = (int)$this->getOption( 'touserid', 0 ) ?: null;
        Severity: Minor
        Found in maintenance/userOptions.php - About 1 hr to fix

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

              private function updateOptions() {
                  $dryRun = $this->hasOption( 'dry' );
                  $settingWord = $dryRun ? 'Would set' : 'Setting';
                  $option = $this->getArg( 0 );
                  $fromIsDefault = $this->hasOption( 'old-is-default' );
          Severity: Minor
          Found in maintenance/userOptions.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 showUsageStats has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function showUsageStats() {
                  $option = $this->getArg( 0 );
          
                  $ret = [];
                  $userOptionsLookup = $this->getServiceContainer()->getUserOptionsLookup();
          Severity: Minor
          Found in maintenance/userOptions.php - About 1 hr to fix

            Function execute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function execute() {
                    if ( $this->hasOption( 'list' ) ) {
                        $this->listAvailableOptions();
                    } elseif ( $this->hasOption( 'usage' ) ) {
                        $this->showUsageStats();
            Severity: Minor
            Found in maintenance/userOptions.php - About 35 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