wikimedia/mediawiki-core

View on GitHub
includes/diff/TextDiffer/ManifoldTextDiffer.php

Summary

Maintainability
C
7 hrs
Test Coverage

ManifoldTextDiffer has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

class ManifoldTextDiffer implements TextDiffer {
    /** @var MessageLocalizer */
    private $localizer;
    /** @var Language|null */
    private $contentLanguage;
Severity: Minor
Found in includes/diff/TextDiffer/ManifoldTextDiffer.php - About 2 hrs to fix

    Function getDiffers has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        private function getDiffers() {
            if ( $this->differs === null ) {
                $differs = [];
                if ( $this->diffEngine === null ) {
                    $differNames = [ 'external', 'wikidiff2', 'php' ];
    Severity: Minor
    Found in includes/diff/TextDiffer/ManifoldTextDiffer.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 maybeCreateDiffer has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function maybeCreateDiffer( $engine, &$failureReason ) {
            switch ( $engine ) {
                case 'external':
                    if ( is_string( $this->externalPath ) ) {
                        if ( is_executable( $this->externalPath ) ) {
    Severity: Minor
    Found in includes/diff/TextDiffer/ManifoldTextDiffer.php - About 1 hr to fix

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

              MessageLocalizer $localizer,
              ?Language $contentLanguage,
              $diffEngine,
              $externalPath,
              $wikidiff2Options
      Severity: Minor
      Found in includes/diff/TextDiffer/ManifoldTextDiffer.php - About 35 mins to fix

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

            private function maybeCreateDiffer( $engine, &$failureReason ) {
                switch ( $engine ) {
                    case 'external':
                        if ( is_string( $this->externalPath ) ) {
                            if ( is_executable( $this->externalPath ) ) {
        Severity: Minor
        Found in includes/diff/TextDiffer/ManifoldTextDiffer.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

        Avoid too many return statements within this method.
        Open

                        return null;
        Severity: Major
        Found in includes/diff/TextDiffer/ManifoldTextDiffer.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return new PhpTextDiffer(
                              $this->contentLanguage
                          );
          Severity: Major
          Found in includes/diff/TextDiffer/ManifoldTextDiffer.php - About 30 mins to fix

            Function getDiffersByFormat has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                private function getDiffersByFormat() {
                    if ( $this->differsByFormat === null ) {
                        $differs = [];
                        foreach ( $this->getDiffers() as $differ ) {
                            foreach ( $differ->getFormats() as $format ) {
            Severity: Minor
            Found in includes/diff/TextDiffer/ManifoldTextDiffer.php - About 25 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