Showing 4,217 of 4,217 total issues

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

        $data = [
            ['name' => 'id', 'type' => 'int', 'length' => 10, 'auto_inc' => true],
            ['name' => 'name', 'type' => 'varchar', 'length' => 255, 'default' => '', 'not_null' => true],
            ['name' => 'active', 'type' => 'enum', 'length' => '\'0\',\'1\'', 'default' => '0', 'not_null' => true],
            ['key' => 'primary', 'key_cols' => 'id'],
.dev/tests/functional/db/class_db_real_utils_pgsql.TODO.php on lines 119..124
.dev/tests/functional/db/class_db_real_utils_pgsql.TODO.php on lines 149..154
.dev/tests/functional/db/class_db_real_utils_pgsql.TODO.php on lines 248..253
.dev/tests/functional/db/class_db_real_utils_pgsql.TODO.php on lines 267..272

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

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

<?php

return [
  1 => [
    'id' => '1',
Severity: Major
Found in plugins/locale/share/db/data/sys_locale_langs.data.php and 1 other location - About 1 hr to fix
.dev/install/installer_data/db_tables/sys_locale_langs.data.php on lines 1..28

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

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

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

    public function _on_validate_ok($params = [], $form)
    {
        $p = $params ?: $_POST;
        $lang = $p['lang'];
        $to_export = [];

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

        public function _url_control()
        {
            if ( ! $this->ALLOW_URL_CONTROL) {
                return false;
            }
    Severity: Minor
    Found in plugins/assets/classes/yf_assets.class.php - About 1 hr to fix

      Function payout_provider_change has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          $scope.payout_provider_change = function( $event, provider_id, method_id ) {
              $event.stopPropagation();
              var action = $scope.action.payout;
              if( action.provider_id == provider_id && action.method_id == method_id ) {
                  $scope.payout_provider_init();
      Severity: Minor
      Found in plugins/content/templates/user/js/ng/payment/balance-recharge.js - About 1 hr to fix

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

            public function load_rate($options = null)
            {
                // import options
                is_array($options) && extract($options, EXTR_PREFIX_ALL | EXTR_REFS, '');
                // var
        Severity: Minor
        Found in plugins/payment/classes/yf_payment_api__currency.class.php - About 1 hr to fix

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

              public function find_all_hooks($section = 'all')
              {
                  if ( ! in_array($section, ['all', 'user', 'admin'])) {
                      $section = 'all';
                  }
          Severity: Minor
          Found in plugins/sys/classes/yf_admin_methods.class.php - About 1 hr to fix

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

                public function _show_themes()
                {
                    $themes = $this->_get_themes();
            
                    $num_stpls_array = cache_get($this->CACHE_NAME, 60);
            Severity: Minor
            Found in plugins/tpl/admin_modules/yf_template_editor.class.php - About 1 hr to fix

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

                  public function _process_where_cond($left, $op, $right)
                  {
                      ! $op && $op = '=';
                      $left = trim(strtolower($left));
                      if (is_string($op)) {
              Severity: Minor
              Found in plugins/db/classes/db/yf_db_query_builder_driver.class.php - About 1 hr to fix

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

                    public function _init()
                    {
                        ini_set('html_errors', 0);
                        // ob_start();
                        $class = &$this->class;
                Severity: Minor
                Found in plugins/api/classes/yf_api.class.php - About 1 hr to fix

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

                      public function add_watermark($source_img_path, $watermark_path)
                      {
                          $img_info = getimagesize($source_img_path);
                          $source_mime_type = $this->ALLOWED_MIME_TYPES[$img_info['mime']];
                          if ( ! $source_mime_type) {
                  Severity: Minor
                  Found in plugins/common/classes/common/yf_make_thumb.class.php - About 1 hr to fix

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

                        public function coupon_add()
                        {
                            if (main()->is_post()) {
                                if ( ! $_POST['code']) {
                                    _re('Code must be entered');

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

                          public function get_data($name = '', $force_ttl = 0, $params = [])
                          {
                              DEBUG_MODE && $time_start = microtime(true);
                              if (empty($name)) {
                                  return null;
                      Severity: Minor
                      Found in classes/yf_main.class.php - About 1 hr to fix

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

                            public function test_validate_post_empty_value()
                            {
                                $_SERVER['REQUEST_METHOD'] = 'POST';
                                $params = ['do_not_remove_errors' => 1];
                        
                        
                        Severity: Minor
                        Found in .dev/tests/functional/class_form_real_test.Test.php - About 1 hr to fix

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

                              public function test_with_data()
                              {
                                  $data = [
                                      [
                                          'date' => strtotime('2014-08-12 12:03:19 UTC'),
                          Severity: Minor
                          Found in .dev/tests/unit/functions/function_common_rss_page_test.php - About 1 hr to fix

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

                                public function test_rewrite_disabled_simple()
                                {
                                    $GLOBALS['PROJECT_CONF']['tpl']['REWRITE_MODE'] = false;
                                    unset($_GET['debug']);
                                    $this->assertEquals('http://' . self::$host . '/?object=test', process_url('./?object=test'));
                            Severity: Minor
                            Found in .dev/tests/rewrite/class_rewrite_testing_shared.php - About 1 hr to fix

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

                                  public function detect_content_type($asset_type, $content = '')
                                  {
                                      $content = trim($content);
                                      $type = false;
                                      if (isset($this->assets[$content])) {
                              Severity: Minor
                              Found in plugins/assets/classes/yf_assets.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

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

                                  public function show()
                                  {
                                      $all_vars = $this->_get_all_vars();
                                      $total_vars = count((array) $all_vars);
                                      $tr_vars = [];
                              Severity: Minor
                              Found in plugins/locale/admin_modules/yf_locale_editor.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

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

                                  public function time_box($selected = '', $name_postfix = '', $add_str = '', $show_text = 1, $translate = 1)
                                  {
                                      if (is_array($selected)) {
                                          $extra = (array) $extra + $name;
                                          $selected = $extra['selected'];
                              Severity: Minor
                              Found in plugins/html/classes/html/yf_html_datetime.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

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

                                  public function _update_user_geo_location($user_id = 0, $FORCE_IP = '')
                                  {
                                      if ( ! main()->USE_GEO_IP) {
                                          return false;
                                      }
                              Severity: Minor
                              Found in plugins/geo/classes/yf_geo_ip.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

                              Severity
                              Category
                              Status
                              Source
                              Language