wikimedia/mediawiki-core

View on GitHub
includes/utils/ClassCollector.php

Summary

Maintainability
C
1 day
Test Coverage

Function tryEndExpect has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    protected function tryEndExpect( $token ) {
        // @phan-suppress-next-line PhanTypeArraySuspiciousNullable
        switch ( $this->startToken[0] ) {
            case T_DOUBLE_COLON:
                // Skip over T_CLASS after T_DOUBLE_COLON because this is something like
Severity: Minor
Found in includes/utils/ClassCollector.php - About 3 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 tryEndExpect has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function tryEndExpect( $token ) {
        // @phan-suppress-next-line PhanTypeArraySuspiciousNullable
        switch ( $this->startToken[0] ) {
            case T_DOUBLE_COLON:
                // Skip over T_CLASS after T_DOUBLE_COLON because this is something like
Severity: Major
Found in includes/utils/ClassCollector.php - About 2 hrs to fix

    Method getClasses has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getClasses( $code ) {
            $this->namespace = '';
            $this->classes = [];
            $this->startToken = null;
            $this->alias = null;
    Severity: Minor
    Found in includes/utils/ClassCollector.php - About 1 hr to fix

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

          public function getClasses( $code ) {
              $this->namespace = '';
              $this->classes = [];
              $this->startToken = null;
              $this->alias = null;
      Severity: Minor
      Found in includes/utils/ClassCollector.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

      Consider simplifying this complex logical expression.
      Open

                          if ( $token === '(' ) {
                              // Start of a function call to class_alias()
                              $this->alias = [ 'target' => false, 'name' => false ];
                          } elseif ( $token === ',' ) {
                              // Record that we're past the first parameter
      Severity: Major
      Found in includes/utils/ClassCollector.php - About 40 mins to fix

        There are no issues that match your filters.

        Category
        Status