plugins/geo/modules/yf_geo_content.class.php

Summary

Maintainability
F
6 days
Test Coverage

Function change_location has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring.
Open

    public function change_location()
    {
        if ( ! main()->USE_GEO_IP) {
            return false;
        }
Severity: Minor
Found in plugins/geo/modules/yf_geo_content.class.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 change_location has 219 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function change_location()
    {
        if ( ! main()->USE_GEO_IP) {
            return false;
        }
Severity: Major
Found in plugins/geo/modules/yf_geo_content.class.php - About 1 day to fix

    Function ajax_city has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        public function ajax_city()
        {
            main()->NO_GRAPHICS = true;
            // Check input
            if (isset($_REQUEST['country'])) {
    Severity: Minor
    Found in plugins/geo/modules/yf_geo_content.class.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

    File yf_geo_content.class.php has 404 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    // Content display by geo location (ads, pages, etc)
    class yf_geo_content
    {
    Severity: Minor
    Found in plugins/geo/modules/yf_geo_content.class.php - About 5 hrs to fix

      Method ajax_city has 78 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function ajax_city()
          {
              main()->NO_GRAPHICS = true;
              // Check input
              if (isset($_REQUEST['country'])) {
      Severity: Major
      Found in plugins/geo/modules/yf_geo_content.class.php - About 3 hrs to fix

        Method _city_select has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function _city_select($params = [])
            {
                $STPL_NAME = 'register/city_select';
                if ( ! empty($params['stpl_name'])) {
                    $STPL_NAME = $params['stpl_name'];
        Severity: Major
        Found in plugins/geo/modules/yf_geo_content.class.php - About 2 hrs to fix

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

              public function _city_select($params = [])
              {
                  $STPL_NAME = 'register/city_select';
                  if ( ! empty($params['stpl_name'])) {
                      $STPL_NAME = $params['stpl_name'];
          Severity: Minor
          Found in plugins/geo/modules/yf_geo_content.class.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 change_location_result has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function change_location_result()
              {
                  if ( ! main()->USE_GEO_IP) {
                      return false;
                  }
          Severity: Minor
          Found in plugins/geo/modules/yf_geo_content.class.php - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Consider simplifying this complex logical expression.
          Open

                      if (($sel_data['country_code'] && $sel_data['country_code'] != $this->_user_info['country'])
                          || ($sel_data['region_code'] && $sel_data['region_code'] != $this->_user_info['state'])
                          || ($sel_data['city_name'] && strtolower($sel_data['city_name']) != strtolower($this->_user_info['city']))
                          || ($sel_data['zip_code'] && $sel_data['zip_code'] != $this->_user_info['zip_code'])
                      ) {
          Severity: Critical
          Found in plugins/geo/modules/yf_geo_content.class.php - About 1 hr to fix

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

                        if (strlen($sel_data['region_code'])) {
                            $_cities[''] = '  --   Please select city   --  ';
                            $Q = db()->query(
                                'SELECT * 
                                FROM ' . db('geo_city_location') . " 
            Severity: Major
            Found in plugins/geo/modules/yf_geo_content.class.php and 1 other location - About 2 hrs to fix
            plugins/geo/modules/yf_geo_content.class.php on lines 59..73

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

            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 (strlen($_POST['region'])) {
                            $_cities[''] = '  --   Please select city   --  ';
                            $Q = db()->query(
                                'SELECT * 
                                FROM ' . db('geo_city_location') . " 
            Severity: Major
            Found in plugins/geo/modules/yf_geo_content.class.php and 1 other location - About 2 hrs to fix
            plugins/geo/modules/yf_geo_content.class.php on lines 216..230

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

            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