wikimedia/mediawiki-core

View on GitHub
includes/utils/GitInfo.php

Summary

Maintainability
D
1 day
Test Coverage

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

    protected function getRemoteUrl() {
        if ( !isset( $this->cache['remoteURL'] ) ) {
            $config = "{$this->basedir}/config";
            $url = false;
            if ( is_readable( $config ) ) {
Severity: Minor
Found in includes/utils/GitInfo.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 GitInfo.php has 274 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/utils/GitInfo.php - About 2 hrs to fix

    Function __construct has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        public function __construct( $repoDir, $usePrecomputed = true ) {
            $this->repoDir = $repoDir;
            $services = MediaWikiServices::getInstance();
            $this->options = new ServiceOptions(
                self::CONSTRUCTOR_OPTIONS, $services->getMainConfig()
    Severity: Minor
    Found in includes/utils/GitInfo.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 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function __construct( $repoDir, $usePrecomputed = true ) {
            $this->repoDir = $repoDir;
            $services = MediaWikiServices::getInstance();
            $this->options = new ServiceOptions(
                self::CONSTRUCTOR_OPTIONS, $services->getMainConfig()
    Severity: Minor
    Found in includes/utils/GitInfo.php - About 1 hr to fix

      Method getHeadCommitDate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getHeadCommitDate() {
              $gitBin = $this->options->get( MainConfigNames::GitBin );
      
              if ( !isset( $this->cache['headCommitDate'] ) ) {
                  $date = false;
      Severity: Minor
      Found in includes/utils/GitInfo.php - About 1 hr to fix

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

            public function getHeadSHA1() {
                if ( !isset( $this->cache['headSHA1'] ) ) {
                    $head = $this->getHead();
                    $sha1 = false;
        
        
        Severity: Minor
        Found in includes/utils/GitInfo.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 getCacheFilePath has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            private function getCacheFilePath( $repoDir ) {
                $gitInfoCacheDirectory = $this->options->get( MainConfigNames::GitInfoCacheDirectory );
                if ( $gitInfoCacheDirectory === false ) {
                    $gitInfoCacheDirectory = $this->options->get( MainConfigNames::CacheDirectory ) . '/gitinfo';
                }
        Severity: Minor
        Found in includes/utils/GitInfo.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

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

            public function getHeadCommitDate() {
                $gitBin = $this->options->get( MainConfigNames::GitBin );
        
                if ( !isset( $this->cache['headCommitDate'] ) ) {
                    $date = false;
        Severity: Minor
        Found in includes/utils/GitInfo.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

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

            public function getHead() {
                if ( !isset( $this->cache['head'] ) ) {
                    $headFile = "{$this->basedir}/HEAD";
                    $head = false;
        
        
        Severity: Minor
        Found in includes/utils/GitInfo.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

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

            public function precomputeValues() {
                if ( $this->cacheFile !== null ) {
                    // Try to completely populate the cache
                    $this->getHead();
                    $this->getHeadSHA1();
        Severity: Minor
        Found in includes/utils/GitInfo.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