woothemes/woocommerce

View on GitHub
includes/class-wc-geo-ip.php

Summary

Maintainability
F
1 mo
Test Coverage

File class-wc-geo-ip.php has 1478 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Geo IP class
 *
 * This class is a fork of GeoIP class from MaxMind LLC.
Severity: Major
Found in includes/class-wc-geo-ip.php - About 3 days to fix

    Function _setup_segments has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
    Open

        private function _setup_segments() {
            $this->databaseType  = self::GEOIP_COUNTRY_EDITION;
            $this->record_length = self::STANDARD_RECORD_LENGTH;
    
            if ( $this->flags & self::GEOIP_SHARED_MEMORY ) {
    Severity: Minor
    Found in includes/class-wc-geo-ip.php - About 1 day 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 _setup_segments has 126 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function _setup_segments() {
            $this->databaseType  = self::GEOIP_COUNTRY_EDITION;
            $this->record_length = self::STANDARD_RECORD_LENGTH;
    
            if ( $this->flags & self::GEOIP_SHARED_MEMORY ) {
    Severity: Major
    Found in includes/class-wc-geo-ip.php - About 5 hrs to fix

      Consider simplifying this complex logical expression.
      Open

                          if ( self::GEOIP_REGION_EDITION_REV0 == $this->databaseType ) {
                              $this->databaseSegments = self::GEOIP_STATE_BEGIN_REV0;
                          } elseif ( self::GEOIP_REGION_EDITION_REV1 == $this->databaseType ) {
                              $this->databaseSegments = self::GEOIP_STATE_BEGIN_REV1;
                          } elseif ( ( self::GEOIP_CITY_EDITION_REV0 == $this->databaseType )
      Severity: Critical
      Found in includes/class-wc-geo-ip.php - About 4 hrs to fix

        Consider simplifying this complex logical expression.
        Open

                            if ( self::GEOIP_REGION_EDITION_REV0 == $this->databaseType ) {
                                $this->databaseSegments = self::GEOIP_STATE_BEGIN_REV0;
                            } elseif ( self::GEOIP_REGION_EDITION_REV1 == $this->databaseType ) {
                                $this->databaseSegments = self::GEOIP_STATE_BEGIN_REV1;
                            } elseif ( ( self::GEOIP_CITY_EDITION_REV0 == $this->databaseType )
        Severity: Critical
        Found in includes/class-wc-geo-ip.php - About 4 hrs to fix

          Function _geoip_seek_country has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

              private function _geoip_seek_country( $ipnum ) {
                  $offset = 0;
                  for ( $depth = 31; $depth >= 0; --$depth ) {
                      if ( $this->flags & self::GEOIP_MEMORY_CACHE ) {
                          $buf = $this->_safe_substr(
          Severity: Minor
          Found in includes/class-wc-geo-ip.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

          Function _geoip_seek_country_v6 has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

              public function _geoip_seek_country_v6( $ipnum ) {
                  // arrays from unpack start with offset 1
                  // yet another php mystery. array_merge work around
                  // this broken behaviour
                  $v6vec = array_merge( unpack( 'C16', $ipnum ) );
          Severity: Minor
          Found in includes/class-wc-geo-ip.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 _common_get_record has 79 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function _common_get_record( $seek_country ) {
                  // workaround php's broken substr, strpos, etc handling with
                  // mbstring.func_overload and mbstring.internal_encoding
                  $mbExists = extension_loaded( 'mbstring' );
                  if ( $mbExists ) {
          Severity: Major
          Found in includes/class-wc-geo-ip.php - About 3 hrs to fix

            Function _common_get_record has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

                private function _common_get_record( $seek_country ) {
                    // workaround php's broken substr, strpos, etc handling with
                    // mbstring.func_overload and mbstring.internal_encoding
                    $mbExists = extension_loaded( 'mbstring' );
                    if ( $mbExists ) {
            Severity: Minor
            Found in includes/class-wc-geo-ip.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 _geoip_seek_country_v6 has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function _geoip_seek_country_v6( $ipnum ) {
                    // arrays from unpack start with offset 1
                    // yet another php mystery. array_merge work around
                    // this broken behaviour
                    $v6vec = array_merge( unpack( 'C16', $ipnum ) );
            Severity: Minor
            Found in includes/class-wc-geo-ip.php - About 1 hr to fix

              Method _geoip_seek_country has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function _geoip_seek_country( $ipnum ) {
                      $offset = 0;
                      for ( $depth = 31; $depth >= 0; --$depth ) {
                          if ( $this->flags & self::GEOIP_MEMORY_CACHE ) {
                              $buf = $this->_safe_substr(
              Severity: Minor
              Found in includes/class-wc-geo-ip.php - About 1 hr to fix

                Function geoip_open has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function geoip_open( $filename, $flags ) {
                        $this->flags = $flags;
                        if ( $this->flags & self::GEOIP_SHARED_MEMORY ) {
                            $this->shmid = @shmop_open( self::GEOIP_SHM_KEY, 'a', 0, 0 );
                        } else {
                Severity: Minor
                Found in includes/class-wc-geo-ip.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

                Consider simplifying this complex logical expression.
                Open

                                        if ( ( self::GEOIP_ORG_EDITION == $this->databaseType )
                                            || ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType )
                                            || ( self::GEOIP_DOMAIN_EDITION == $this->databaseType )
                                            || ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType )
                                            || ( self::GEOIP_ISP_EDITION == $this->databaseType )
                Severity: Major
                Found in includes/class-wc-geo-ip.php - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                                          if ( ( self::GEOIP_ORG_EDITION == $this->databaseType )
                                              || ( self::GEOIP_DOMAIN_EDITION == $this->databaseType )
                                              || ( self::GEOIP_ISP_EDITION == $this->databaseType )
                                              || ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType )
                                              || ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType )
                  Severity: Major
                  Found in includes/class-wc-geo-ip.php - About 40 mins to fix

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

                        public function geoip_country_code_by_addr( $addr ) {
                            if ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType ) {
                                $record = $this->geoip_record_by_addr( $addr );
                                if ( false !== $record ) {
                                    return $record->country_code;
                    Severity: Minor
                    Found in includes/class-wc-geo-ip.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

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

                        public $GEOIP_COUNTRY_NAMES = array(
                            '',
                            'Asia/Pacific Region',
                            'Europe',
                            'Andorra',
                    Severity: Major
                    Found in includes/class-wc-geo-ip.php and 3 other locations - About 4 days to fix
                    includes/class-wc-geo-ip.php on lines 112..369
                    includes/class-wc-geo-ip.php on lines 376..633
                    includes/class-wc-geo-ip.php on lines 904..1161

                    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 775.

                    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 4 locations. Consider refactoring.
                    Open

                        public $GEOIP_COUNTRY_CODES3 = array(
                            '',
                            'AP',
                            'EU',
                            'AND',
                    Severity: Major
                    Found in includes/class-wc-geo-ip.php and 3 other locations - About 4 days to fix
                    includes/class-wc-geo-ip.php on lines 112..369
                    includes/class-wc-geo-ip.php on lines 640..897
                    includes/class-wc-geo-ip.php on lines 904..1161

                    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 775.

                    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 4 locations. Consider refactoring.
                    Open

                        public $GEOIP_COUNTRY_CODES = array(
                            '',
                            'AP',
                            'EU',
                            'AD',
                    Severity: Major
                    Found in includes/class-wc-geo-ip.php and 3 other locations - About 4 days to fix
                    includes/class-wc-geo-ip.php on lines 376..633
                    includes/class-wc-geo-ip.php on lines 640..897
                    includes/class-wc-geo-ip.php on lines 904..1161

                    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 775.

                    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 4 locations. Consider refactoring.
                    Open

                        public $GEOIP_CONTINENT_CODES = array(
                            '--',
                            'AS',
                            'EU',
                            'EU',
                    Severity: Major
                    Found in includes/class-wc-geo-ip.php and 3 other locations - About 4 days to fix
                    includes/class-wc-geo-ip.php on lines 112..369
                    includes/class-wc-geo-ip.php on lines 376..633
                    includes/class-wc-geo-ip.php on lines 640..897

                    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 775.

                    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 2 locations. Consider refactoring.
                    Open

                                        } elseif ( ( self::GEOIP_CITY_EDITION_REV0 == $this->databaseType )
                                            || ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType )
                                            || ( self::GEOIP_CITY_EDITION_REV0_V6 == $this->databaseType )
                                            || ( self::GEOIP_CITY_EDITION_REV1_V6 == $this->databaseType )
                                            || ( self::GEOIP_ORG_EDITION == $this->databaseType )
                    Severity: Major
                    Found in includes/class-wc-geo-ip.php and 1 other location - About 7 hrs to fix
                    includes/class-wc-geo-ip.php on lines 1233..1268

                    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 232.

                    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 2 locations. Consider refactoring.
                    Open

                                        } elseif ( ( self::GEOIP_CITY_EDITION_REV0 == $this->databaseType )
                                            || ( self::GEOIP_CITY_EDITION_REV1 == $this->databaseType )
                                            || ( self::GEOIP_ORG_EDITION == $this->databaseType )
                                            || ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType )
                                            || ( self::GEOIP_DOMAIN_EDITION == $this->databaseType )
                    Severity: Major
                    Found in includes/class-wc-geo-ip.php and 1 other location - About 7 hrs to fix
                    includes/class-wc-geo-ip.php on lines 1300..1335

                    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 232.

                    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

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                                if ( $this->flags & self::GEOIP_MEMORY_CACHE ) {
                                    $buf = $this->_safe_substr(
                                        $this->memory_buffer,
                                        2 * $this->record_length * $offset,
                                        2 * $this->record_length
                    Severity: Major
                    Found in includes/class-wc-geo-ip.php and 1 other location - About 4 hrs to fix
                    includes/class-wc-geo-ip.php on lines 1514..1532

                    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 170.

                    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

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                                if ( $this->flags & self::GEOIP_MEMORY_CACHE ) {
                                    $buf = $this->_safe_substr(
                                        $this->memory_buffer,
                                        2 * $this->record_length * $offset,
                                        2 * $this->record_length
                    Severity: Major
                    Found in includes/class-wc-geo-ip.php and 1 other location - About 4 hrs to fix
                    includes/class-wc-geo-ip.php on lines 1570..1588

                    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 170.

                    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 2 locations. Consider refactoring.
                    Open

                                            if ( ( self::GEOIP_ORG_EDITION == $this->databaseType )
                                                || ( self::GEOIP_DOMAIN_EDITION == $this->databaseType )
                                                || ( self::GEOIP_ISP_EDITION == $this->databaseType )
                                                || ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType )
                                                || ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType )
                    Severity: Minor
                    Found in includes/class-wc-geo-ip.php and 1 other location - About 30 mins to fix
                    includes/class-wc-geo-ip.php on lines 1259..1267

                    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 91.

                    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 2 locations. Consider refactoring.
                    Open

                                            if ( ( self::GEOIP_ORG_EDITION == $this->databaseType )
                                                || ( self::GEOIP_ORG_EDITION_V6 == $this->databaseType )
                                                || ( self::GEOIP_DOMAIN_EDITION == $this->databaseType )
                                                || ( self::GEOIP_DOMAIN_EDITION_V6 == $this->databaseType )
                                                || ( self::GEOIP_ISP_EDITION == $this->databaseType )
                    Severity: Minor
                    Found in includes/class-wc-geo-ip.php and 1 other location - About 30 mins to fix
                    includes/class-wc-geo-ip.php on lines 1326..1334

                    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 91.

                    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