wikimedia/mediawiki-core

View on GitHub
includes/language/Language.php

Summary

Maintainability
F
1 mo
Test Coverage

File Language.php has 2503 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: Major
Found in includes/language/Language.php - About 1 wk to fix

    Function sprintfDate has a Cognitive Complexity of 151 (exceeds 5 allowed). Consider refactoring.
    Open

        public function sprintfDate( $format, $ts, DateTimeZone $zone = null, &$ttl = 'unused' ) {
            // @phan-suppress-previous-line PhanTypeMismatchDefault Type mismatch on pass-by-ref args
            $s = '';
            $raw = false;
            $roman = false;
    Severity: Minor
    Found in includes/language/Language.php - About 3 days 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

    Language has 148 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Language implements Bcp47Code {
        use DebugInfoTrait;
    
        /** @var string */
        public $mCode;
    Severity: Major
    Found in includes/language/Language.php - About 2 days to fix

      Method sprintfDate has 449 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function sprintfDate( $format, $ts, DateTimeZone $zone = null, &$ttl = 'unused' ) {
              // @phan-suppress-previous-line PhanTypeMismatchDefault Type mismatch on pass-by-ref args
              $s = '';
              $raw = false;
              $roman = false;
      Severity: Major
      Found in includes/language/Language.php - About 2 days to fix

        Function truncateHtml has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
        Open

            public function truncateHtml( $text, $length, $ellipsis = '...' ) {
                # Use the localized ellipsis character
                if ( $ellipsis == '...' ) {
                    $ellipsis = $this->msg( 'ellipsis' )->escaped();
                }
        Severity: Minor
        Found in includes/language/Language.php - About 7 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 formatNumInternal has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
        Open

            private function formatNumInternal(
                string $number, bool $noTranslate, bool $noSeparators
            ): string {
                $translateNumerals = $this->config->get( MainConfigNames::TranslateNumerals );
        
        
        Severity: Minor
        Found in includes/language/Language.php - About 5 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 tsToHebrew has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
        Open

            private static function tsToHebrew( $ts ) {
                # Parse date
                $year = (int)substr( $ts, 0, 4 );
                $month = (int)substr( $ts, 4, 2 );
                $day = (int)substr( $ts, 6, 2 );
        Severity: Minor
        Found in includes/language/Language.php - About 5 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 formatTimePeriod has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

            public function formatTimePeriod( $seconds, $format = [] ) {
                if ( !is_array( $format ) ) {
                    $format = [ 'avoid' => $format ]; // For backwards compatibility
                }
                if ( !isset( $format['avoid'] ) ) {
        Severity: Minor
        Found in includes/language/Language.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

        Method tsToHebrew has 115 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static function tsToHebrew( $ts ) {
                # Parse date
                $year = (int)substr( $ts, 0, 4 );
                $month = (int)substr( $ts, 4, 2 );
                $day = (int)substr( $ts, 6, 2 );
        Severity: Major
        Found in includes/language/Language.php - About 4 hrs to fix

          Method formatNumInternal has 98 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function formatNumInternal(
                  string $number, bool $noTranslate, bool $noSeparators
              ): string {
                  $translateNumerals = $this->config->get( MainConfigNames::TranslateNumerals );
          
          
          Severity: Major
          Found in includes/language/Language.php - About 3 hrs to fix

            Method truncateHtml has 95 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function truncateHtml( $text, $length, $ellipsis = '...' ) {
                    # Use the localized ellipsis character
                    if ( $ellipsis == '...' ) {
                        $ellipsis = $this->msg( 'ellipsis' )->escaped();
                    }
            Severity: Major
            Found in includes/language/Language.php - About 3 hrs to fix

              Function getNamespaceAliases has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getNamespaceAliases() {
                      if ( $this->namespaceAliases === null ) {
                          $aliases = $this->localisationCache->getItem( $this->mCode, 'namespaceAliases' );
                          if ( !$aliases ) {
                              $aliases = [];
              Severity: Minor
              Found in includes/language/Language.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 formatTimePeriod has 88 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function formatTimePeriod( $seconds, $format = [] ) {
                      if ( !is_array( $format ) ) {
                          $format = [ 'avoid' => $format ]; // For backwards compatibility
                      }
                      if ( !isset( $format['avoid'] ) ) {
              Severity: Major
              Found in includes/language/Language.php - About 3 hrs to fix

                Function hebrewNumeral has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function hebrewNumeral( $num ) {
                        static $table = [
                            [ '', 'א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט', 'י' ],
                            [ '', 'י', 'כ', 'ל', 'מ', 'נ', 'ס', 'ע', 'פ', 'צ', 'ק' ],
                            [ '',
                Severity: Minor
                Found in includes/language/Language.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 hebrewNumeral has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function hebrewNumeral( $num ) {
                        static $table = [
                            [ '', 'א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט', 'י' ],
                            [ '', 'י', 'כ', 'ל', 'מ', 'נ', 'ס', 'ע', 'פ', 'צ', 'ק' ],
                            [ '',
                Severity: Major
                Found in includes/language/Language.php - About 2 hrs to fix

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

                      public function firstChar( $s ) {
                          $firstChar = mb_substr( $s, 0, 1 );
                  
                          if ( $firstChar === '' || strlen( $firstChar ) != 3 ) {
                              return $firstChar;
                  Severity: Minor
                  Found in includes/language/Language.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

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

                      public function convertGrammar( $word, $case ) {
                          $grammarForms = $this->config->get( MainConfigNames::GrammarForms );
                          if ( isset( $grammarForms[$this->getCode()][$case][$word] ) ) {
                              return $grammarForms[$this->getCode()][$case][$word];
                          }
                  Severity: Minor
                  Found in includes/language/Language.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 getNamespaceAliases has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function getNamespaceAliases() {
                          if ( $this->namespaceAliases === null ) {
                              $aliases = $this->localisationCache->getItem( $this->mCode, 'namespaceAliases' );
                              if ( !$aliases ) {
                                  $aliases = [];
                  Severity: Minor
                  Found in includes/language/Language.php - About 1 hr to fix

                    Function translateBlockExpiry has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function translateBlockExpiry( $str, UserIdentity $user = null, $now = 0 ) {
                            $duration = $this->getBlockDurations();
                            $show = array_search( $str, $duration, true );
                            if ( $show !== false ) {
                                return trim( $show );
                    Severity: Minor
                    Found in includes/language/Language.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 42 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function __construct(
                            $code = null,
                            NamespaceInfo $namespaceInfo = null,
                            LocalisationCache $localisationCache = null,
                            LanguageNameUtils $langNameUtils = null,
                    Severity: Minor
                    Found in includes/language/Language.php - About 1 hr to fix

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

                          private function getHumanTimestampInternal(
                              MWTimestamp $ts, MWTimestamp $relativeTo, User $user
                          ) {
                              $diff = $ts->diff( $relativeTo );
                              $diffDay = (bool)( (int)$ts->timestamp->format( 'w' ) -
                      Severity: Minor
                      Found in includes/language/Language.php - About 1 hr to fix

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

                            private function getHumanTimestampInternal(
                                MWTimestamp $ts, MWTimestamp $relativeTo, User $user
                            ) {
                                $diff = $ts->diff( $relativeTo );
                                $diffDay = (bool)( (int)$ts->timestamp->format( 'w' ) -
                        Severity: Minor
                        Found in includes/language/Language.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 firstChar has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function firstChar( $s ) {
                                $firstChar = mb_substr( $s, 0, 1 );
                        
                                if ( $firstChar === '' || strlen( $firstChar ) != 3 ) {
                                    return $firstChar;
                        Severity: Minor
                        Found in includes/language/Language.php - About 1 hr to fix

                          Method truncateInternal has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function truncateInternal(
                                  $string, $length, $ellipsis, $adjustLength, callable $measureLength, callable $getSubstring
                              ) {
                                  # Check if there is no need to truncate
                                  if ( $measureLength( $string ) <= abs( $length ) ) {
                          Severity: Minor
                          Found in includes/language/Language.php - About 1 hr to fix

                            Consider simplifying this complex logical expression.
                            Open

                                    if ( $ttl === 'unused' ) {
                                        // No need to calculate the TTL, the caller won't use it anyway.
                                    } elseif ( $usedSecond ) {
                                        $ttl = 1;
                                    } elseif ( $usedMinute ) {
                            Severity: Critical
                            Found in includes/language/Language.php - About 1 hr to fix

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

                                  private function truncateInternal(
                                      $string, $length, $ellipsis, $adjustLength, callable $measureLength, callable $getSubstring
                                  ) {
                                      # Check if there is no need to truncate
                                      if ( $measureLength( $string ) <= abs( $length ) ) {
                              Severity: Minor
                              Found in includes/language/Language.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 tsToIranian has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private static function tsToIranian( $ts ) {
                                      $gy = (int)substr( $ts, 0, 4 ) - 1600;
                                      $gm = (int)substr( $ts, 4, 2 ) - 1;
                                      $gd = (int)substr( $ts, 6, 2 ) - 1;
                              
                              
                              Severity: Minor
                              Found in includes/language/Language.php - About 1 hr to fix

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

                                    public function convertGrammar( $word, $case ) {
                                        $grammarForms = $this->config->get( MainConfigNames::GrammarForms );
                                        if ( isset( $grammarForms[$this->getCode()][$case][$word] ) ) {
                                            return $grammarForms[$this->getCode()][$case][$word];
                                        }
                                Severity: Minor
                                Found in includes/language/Language.php - About 1 hr to fix

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

                                      private static function tsToHijri( $ts ) {
                                          $year = (int)substr( $ts, 0, 4 );
                                          $month = (int)substr( $ts, 4, 2 );
                                          $day = (int)substr( $ts, 6, 2 );
                                  
                                  
                                  Severity: Minor
                                  Found in includes/language/Language.php - About 1 hr to fix

                                    Method getNamespaces has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public function getNamespaces() {
                                            if ( $this->namespaceNames === null ) {
                                                $metaNamespace = $this->config->get( MainConfigNames::MetaNamespace );
                                                $metaNamespaceTalk = $this->config->get( MainConfigNames::MetaNamespaceTalk );
                                                $extraNamespaces = $this->config->get( MainConfigNames::ExtraNamespaces );
                                    Severity: Minor
                                    Found in includes/language/Language.php - About 1 hr to fix

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

                                          private static function tsToYear( $ts, $cName ) {
                                              $gy = (int)substr( $ts, 0, 4 );
                                              $gm = (int)substr( $ts, 4, 2 );
                                              $gd = (int)substr( $ts, 6, 2 );
                                      
                                      
                                      Severity: Minor
                                      Found in includes/language/Language.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 translateBlockExpiry has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          public function translateBlockExpiry( $str, UserIdentity $user = null, $now = 0 ) {
                                              $duration = $this->getBlockDurations();
                                              $show = array_search( $str, $duration, true );
                                              if ( $show !== false ) {
                                                  return trim( $show );
                                      Severity: Minor
                                      Found in includes/language/Language.php - About 1 hr to fix

                                        Consider simplifying this complex logical expression.
                                        Open

                                                    if ( ( $code === 'xi'
                                                            || $code === 'xj'
                                                            || $code === 'xk'
                                                            || $code === 'xm'
                                                            || $code === 'xo'
                                        Severity: Major
                                        Found in includes/language/Language.php - About 1 hr to fix

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

                                                  $code = null,
                                                  NamespaceInfo $namespaceInfo = null,
                                                  LocalisationCache $localisationCache = null,
                                                  LanguageNameUtils $langNameUtils = null,
                                                  LanguageFallback $langFallback = null,
                                          Severity: Major
                                          Found in includes/language/Language.php - About 1 hr to fix

                                            Consider simplifying this complex logical expression.
                                            Open

                                                    if ( $c == 0 && $a > 11 && $m >= 0.89772376543210 ) {
                                                        $Mar++;
                                                    } elseif ( $c == 1 && $a > 6 && $m >= 0.63287037037037 ) {
                                                        $Mar += 2;
                                                    } elseif ( $c == 2 || $c == 4 || $c == 6 ) {
                                            Severity: Major
                                            Found in includes/language/Language.php - About 1 hr to fix

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

                                                  public function getNamespaces() {
                                                      if ( $this->namespaceNames === null ) {
                                                          $metaNamespace = $this->config->get( MainConfigNames::MetaNamespace );
                                                          $metaNamespaceTalk = $this->config->get( MainConfigNames::MetaNamespaceTalk );
                                                          $extraNamespaces = $this->config->get( MainConfigNames::ExtraNamespaces );
                                              Severity: Minor
                                              Found in includes/language/Language.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 truncate_endBracket has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                  private function truncate_endBracket( &$tag, $tagType, $lastCh, &$openTags ) {
                                                      $tag = ltrim( $tag );
                                                      if ( $tag != '' ) {
                                                          if ( $tagType == 0 && $lastCh != '/' ) {
                                                              $openTags[] = $tag; // tag opened (didn't close itself)
                                              Severity: Minor
                                              Found in includes/language/Language.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 truncateInternal has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                              Open

                                                      $string, $length, $ellipsis, $adjustLength, callable $measureLength, callable $getSubstring
                                              Severity: Minor
                                              Found in includes/language/Language.php - About 45 mins to fix

                                                Consider simplifying this complex logical expression.
                                                Open

                                                        if (
                                                            ( $zy > 1582 ) || ( ( $zy == 1582 ) && ( $zm > 10 ) ) ||
                                                            ( ( $zy == 1582 ) && ( $zm == 10 ) && ( $zd > 14 ) )
                                                        ) {
                                                            $zjd = (int)( ( 1461 * ( $zy + 4800 + (int)( ( $zm - 14 ) / 12 ) ) ) / 4 ) +
                                                Severity: Major
                                                Found in includes/language/Language.php - About 40 mins to fix

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

                                                      private function truncate_skip( &$ret, $text, $search, $start, $len = null ) {
                                                  Severity: Minor
                                                  Found in includes/language/Language.php - About 35 mins to fix

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

                                                        public function getPluralRuleTypes() {
                                                            $pluralRuleTypes =
                                                                $this->localisationCache->getItem( strtolower( $this->mCode ), 'pluralRuleTypes' );
                                                            if ( !$pluralRuleTypes ) {
                                                                $fallbacks = $this->getFallbackLanguages();
                                                    Severity: Minor
                                                    Found in includes/language/Language.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 getDateFormatString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        public function getDateFormatString( $type, $pref ) {
                                                            $wasDefault = false;
                                                            if ( $pref == 'default' ) {
                                                                $wasDefault = true;
                                                                $pref = $this->getDefaultDateFormat();
                                                    Severity: Minor
                                                    Found in includes/language/Language.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 ucfirst has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        public function ucfirst( $str ) {
                                                            $octetCode = ord( $str );
                                                            // See https://en.wikipedia.org/wiki/ASCII#Printable_characters
                                                            if ( $octetCode < 96 ) {
                                                                // Assume this is an uppercase/uncased ASCII character
                                                    Severity: Minor
                                                    Found in includes/language/Language.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 getCompiledPluralRules has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        public function getCompiledPluralRules() {
                                                            $pluralRules =
                                                                $this->localisationCache->getItem( strtolower( $this->mCode ), 'compiledPluralRules' );
                                                            if ( !$pluralRules ) {
                                                                $fallbacks = $this->getFallbackLanguages();
                                                    Severity: Minor
                                                    Found in includes/language/Language.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 hebrewYearStart has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        private static function hebrewYearStart( $year ) {
                                                            $a = ( 12 * ( $year - 1 ) + 17 ) % 19;
                                                            $b = ( $year - 1 ) % 4;
                                                            $m = 32.044093161144 + 1.5542417966212 * $a + $b / 4.0 - 0.0031777940220923 * ( $year - 1 );
                                                            if ( $m < 0 ) {
                                                    Severity: Minor
                                                    Found in includes/language/Language.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 getPluralRules has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        public function getPluralRules() {
                                                            $pluralRules =
                                                                $this->localisationCache->getItem( strtolower( $this->mCode ), 'pluralRules' );
                                                            if ( !$pluralRules ) {
                                                                $fallbacks = $this->getFallbackLanguages();
                                                    Severity: Minor
                                                    Found in includes/language/Language.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 tsToIranian has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        private static function tsToIranian( $ts ) {
                                                            $gy = (int)substr( $ts, 0, 4 ) - 1600;
                                                            $gm = (int)substr( $ts, 4, 2 ) - 1;
                                                            $gd = (int)substr( $ts, 6, 2 ) - 1;
                                                    
                                                    
                                                    Severity: Minor
                                                    Found in includes/language/Language.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 self::tsToJapaneseGengoCalculate( $gy, 2019, '令和' );
                                                    Severity: Major
                                                    Found in includes/language/Language.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                              return "西暦$gy";
                                                      Severity: Major
                                                      Found in includes/language/Language.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                    return "\u{314A}";
                                                        Severity: Major
                                                        Found in includes/language/Language.php - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                          return '↑';
                                                          Severity: Major
                                                          Found in includes/language/Language.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                        return "\u{3139}";
                                                            Severity: Major
                                                            Found in includes/language/Language.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                          return "\u{3142}";
                                                              Severity: Major
                                                              Found in includes/language/Language.php - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                            return "\u{3137}";
                                                                Severity: Major
                                                                Found in includes/language/Language.php - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                              return "\u{314C}";
                                                                  Severity: Major
                                                                  Found in includes/language/Language.php - About 30 mins to fix

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                                    return $this->userTimeAndDate( $time, $user );
                                                                    Severity: Major
                                                                    Found in includes/language/Language.php - About 30 mins to fix

                                                                      Avoid too many return statements within this method.
                                                                      Open

                                                                                  return $this->timeanddate( $time );
                                                                      Severity: Major
                                                                      Found in includes/language/Language.php - About 30 mins to fix

                                                                        Avoid too many return statements within this method.
                                                                        Open

                                                                                    return "\u{3147}";
                                                                        Severity: Major
                                                                        Found in includes/language/Language.php - About 30 mins to fix

                                                                          Avoid too many return statements within this method.
                                                                          Open

                                                                                      return preg_replace_callback( "/{$validNumberRe}/", function ( $m )  use ( $noTranslate, $noSeparators ) {
                                                                                          return $this->formatNumInternal( $m[0], $noTranslate, $noSeparators );
                                                                                      }, $number );
                                                                          Severity: Major
                                                                          Found in includes/language/Language.php - About 30 mins to fix

                                                                            Avoid too many return statements within this method.
                                                                            Open

                                                                                        return $str;
                                                                            Severity: Major
                                                                            Found in includes/language/Language.php - About 30 mins to fix

                                                                              Avoid too many return statements within this method.
                                                                              Open

                                                                                          return "\u{3145}";
                                                                              Severity: Major
                                                                              Found in includes/language/Language.php - About 30 mins to fix

                                                                                Avoid too many return statements within this method.
                                                                                Open

                                                                                                return '↓';
                                                                                Severity: Major
                                                                                Found in includes/language/Language.php - About 30 mins to fix

                                                                                  Avoid too many return statements within this method.
                                                                                  Open

                                                                                          return strtr( $number, [
                                                                                              "\u{200E}" => '', // LRM
                                                                                              "\u{200F}" => '', // RLM
                                                                                              "\u{061C}" => '', // ALM
                                                                                          ] );
                                                                                  Severity: Major
                                                                                  Found in includes/language/Language.php - About 30 mins to fix

                                                                                    Avoid too many return statements within this method.
                                                                                    Open

                                                                                                return "\u{314D}";
                                                                                    Severity: Major
                                                                                    Found in includes/language/Language.php - About 30 mins to fix

                                                                                      Avoid too many return statements within this method.
                                                                                      Open

                                                                                                  return "\u{3141}";
                                                                                      Severity: Major
                                                                                      Found in includes/language/Language.php - About 30 mins to fix

                                                                                        Avoid too many return statements within this method.
                                                                                        Open

                                                                                                    return "\u{3148}";
                                                                                        Severity: Major
                                                                                        Found in includes/language/Language.php - About 30 mins to fix

                                                                                          Avoid too many return statements within this method.
                                                                                          Open

                                                                                                      return "\u{314B}";
                                                                                          Severity: Major
                                                                                          Found in includes/language/Language.php - About 30 mins to fix

                                                                                            Avoid too many return statements within this method.
                                                                                            Open

                                                                                                        return "\u{314E}";
                                                                                            Severity: Major
                                                                                            Found in includes/language/Language.php - About 30 mins to fix

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

                                                                                                  private function internalUserTimeAndDate( $type, $ts, UserIdentity $user, array $options ) {
                                                                                                      $ts = wfTimestamp( TS_MW, $ts );
                                                                                                      $options += [ 'timecorrection' => true, 'format' => true ];
                                                                                                      if ( $options['timecorrection'] !== false ) {
                                                                                                          if ( $options['timecorrection'] === true ) {
                                                                                              Severity: Minor
                                                                                              Found in includes/language/Language.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

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

                                                                                                  public function dateFormat( $usePrefs = true ) {
                                                                                                      if ( is_bool( $usePrefs ) ) {
                                                                                                          if ( $usePrefs ) {
                                                                                                              $datePreference = RequestContext::getMain()
                                                                                                                  ->getUser()
                                                                                              Severity: Minor
                                                                                              Found in includes/language/Language.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

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

                                                                                                  protected function handleExplicitPluralForms( $count, array $forms ) {
                                                                                                      foreach ( $forms as $index => $form ) {
                                                                                                          if ( preg_match( '/\d+=/i', $form ) ) {
                                                                                                              $pos = strpos( $form, '=' );
                                                                                                              if ( substr( $form, 0, $pos ) === (string)$count ) {
                                                                                              Severity: Minor
                                                                                              Found in includes/language/Language.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

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

                                                                                                  public function getDurationIntervals( $seconds, array $chosenIntervals = [] ) {
                                                                                                      if ( !$chosenIntervals ) {
                                                                                                          $chosenIntervals = [
                                                                                                              'millennia',
                                                                                                              'centuries',
                                                                                              Severity: Minor
                                                                                              Found in includes/language/Language.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

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

                                                                                                  private static function tsToJapaneseGengo( $ts ) {
                                                                                                      # Nengō dates up to Meiji period.
                                                                                                      # Deduct years from the Gregorian calendar
                                                                                                      # depending on the nengo periods
                                                                                                      # The months and days are identical
                                                                                              Severity: Minor
                                                                                              Found in includes/language/Language.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

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

                                                                                                  private static function tsToHijri( $ts ) {
                                                                                                      $year = (int)substr( $ts, 0, 4 );
                                                                                                      $month = (int)substr( $ts, 4, 2 );
                                                                                                      $day = (int)substr( $ts, 6, 2 );
                                                                                              
                                                                                              
                                                                                              Severity: Minor
                                                                                              Found in includes/language/Language.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

                                                                                              Similar blocks of code found in 3 locations. Consider refactoring.
                                                                                              Open

                                                                                                  public function time( $ts, $adj = false, $format = true, $timecorrection = false ) {
                                                                                                      $ts = wfTimestamp( TS_MW, $ts );
                                                                                                      if ( $adj ) {
                                                                                                          $ts = $this->userAdjust( $ts, $timecorrection );
                                                                                                      }
                                                                                              Severity: Major
                                                                                              Found in includes/language/Language.php and 2 other locations - About 1 hr to fix
                                                                                              includes/language/Language.php on lines 2069..2076
                                                                                              includes/language/Language.php on lines 2108..2115

                                                                                              Duplicated Code

                                                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                              Tuning

                                                                                              This issue has a mass of 110.

                                                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                              Refactorings

                                                                                              Further Reading

                                                                                              Similar blocks of code found in 3 locations. Consider refactoring.
                                                                                              Open

                                                                                                  public function timeanddate( $ts, $adj = false, $format = true, $timecorrection = false ) {
                                                                                                      $ts = wfTimestamp( TS_MW, $ts );
                                                                                                      if ( $adj ) {
                                                                                                          $ts = $this->userAdjust( $ts, $timecorrection );
                                                                                                      }
                                                                                              Severity: Major
                                                                                              Found in includes/language/Language.php and 2 other locations - About 1 hr to fix
                                                                                              includes/language/Language.php on lines 2069..2076
                                                                                              includes/language/Language.php on lines 2088..2095

                                                                                              Duplicated Code

                                                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                              Tuning

                                                                                              This issue has a mass of 110.

                                                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                              Refactorings

                                                                                              Further Reading

                                                                                              Similar blocks of code found in 3 locations. Consider refactoring.
                                                                                              Open

                                                                                                  public function date( $ts, $adj = false, $format = true, $timecorrection = false ) {
                                                                                                      $ts = wfTimestamp( TS_MW, $ts );
                                                                                                      if ( $adj ) {
                                                                                                          $ts = $this->userAdjust( $ts, $timecorrection );
                                                                                                      }
                                                                                              Severity: Major
                                                                                              Found in includes/language/Language.php and 2 other locations - About 1 hr to fix
                                                                                              includes/language/Language.php on lines 2088..2095
                                                                                              includes/language/Language.php on lines 2108..2115

                                                                                              Duplicated Code

                                                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                              Tuning

                                                                                              This issue has a mass of 110.

                                                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                              Refactorings

                                                                                              Further Reading

                                                                                              There are no issues that match your filters.

                                                                                              Category
                                                                                              Status