Showing 4,217 of 4,217 total issues

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

    public function has_one($related, $foreign_key = null, $local_key = null, $relation = null)
    {
        if ($relation === null) {
            list(, $caller) = debug_backtrace(false);
            $relation = $caller['function'];
Severity: Major
Found in plugins/sys/classes/yf_model.class.php and 1 other location - About 3 hrs to fix
plugins/sys/classes/yf_model.class.php on lines 554..569

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

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

    public function has_many($related, $foreign_key = null, $local_key = null, $relation = null)
    {
        if ($relation === null) {
            list(, $caller) = debug_backtrace(false);
            $relation = $caller['function'];
Severity: Major
Found in plugins/sys/classes/yf_model.class.php and 1 other location - About 3 hrs to fix
plugins/sys/classes/yf_model.class.php on lines 506..521

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

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 _init has 86 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function _init()
    {
        // class
        $this->payment_api = _class('payment_api');
        $this->manage_payment_lib = module('manage_payment_lib');
Severity: Major
Found in plugins/payment/admin_modules/yf_manage_transfer.class.php - About 3 hrs to fix

    Function _paths has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        public function _paths() {
            $paths = [
                '.',
                'plugins',
            ];
    Severity: Minor
    Found in plugins/tpl/classes/tpl/yf_tpl_driver_twig.class.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 query_fetch_all has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        public function query_fetch_all($sql, $key_name = null, $use_cache = true)
        {
            if ( ! strlen($sql)) {
                return false;
            }
    Severity: Minor
    Found in plugins/db/classes/yf_db.class.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 _render_thead has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        public function _render_thead(&$params, &$a, &$to_hide)
        {
            $data = &$a['data'];
            $thead_attrs = '';
            if (isset($params['thead'])) {
    Severity: Minor
    Found in plugins/table2/classes/yf_table2.class.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 _render_table_contents has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        public function _render_table_contents($data, $params = [], $to_hide = [])
        {
            $tbody_attrs = '';
            if (isset($params['tbody'])) {
                $tbody_attrs = is_array($params['tbody']) ? _attrs($params['tbody'], ['class', 'id']) : ' ' . $params['tbody'];
    Severity: Minor
    Found in plugins/table2/classes/yf_table2.class.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 _render_table_contents_rotated has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        public function _render_table_contents_rotated($data = [], $params, $to_hide = [])
        {
            $tbody_attrs = '';
            if (isset($params['tbody'])) {
                $tbody_attrs = is_array($params['tbody']) ? _attrs($params['tbody'], ['class', 'id']) : ' ' . $params['tbody'];
    Severity: Minor
    Found in plugins/table2/classes/yf_table2.class.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 render_type_slide has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        public function render_type_slide($params = [])
        {
            $total_records = $params['total_records'];
            $per_page = $params['per_page'];
            $requested_page = $params['requested_page'];
    Severity: Minor
    Found in plugins/common/classes/common/yf_divide_pages.class.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 url_to_absolute has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        public function url_to_absolute($baseUrl, $relativeUrl)
        {
            // Remove several frag parts from URL
            if (substr_count($baseUrl, '#') > 1) {
                $baseUrl = substr($baseUrl, 0, strpos($baseUrl, '#', strpos($baseUrl, '#') + 1));
    Severity: Minor
    Found in plugins/common/classes/common/yf_url_to_absolute.class.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 split_url has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        public function split_url($url, $decode = false)
        {
            // Character sets from RFC3986.
            $xunressub = 'a-zA-Z\d\-._~\!$&\'()\[\]*+,;=\|';
            $xpchar = $xunressub . ':@%';
    Severity: Minor
    Found in plugins/common/classes/common/yf_url_to_absolute.class.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 _order_create has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        public function _order_create()
        {
            if (empty($_POST)) {
                return false;
            }
    Severity: Minor
    Found in plugins/shop/modules/shop/yf_shop__order_create.class.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 my_array_merge has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        function my_array_merge($a1, $a2)
        {
            foreach ((array) $a2 as $k => $v) {
                if (isset($a1[$k]) && is_array($a1[$k])) {
                    if (is_array($a2[$k])) {
    Severity: Minor
    Found in functions/yf_common_funcs.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

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

    <?php
    
    class yf_manage_shop_attributes
    {
        public function attributes()

      Method start has 85 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function start()
          {
              $main = main();
              if ( ! empty($this->_started) || $main->is_console() || conf('SESSION_OFF') || $this->OFF) {
                  return false;
      Severity: Major
      Found in plugins/session/classes/yf_session.class.php - About 3 hrs to fix

        Method _transaction has 85 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function _transaction($options)
            {
                if ( ! $this->ENABLE) {
                    return  null;
                }
        Severity: Major
        Found in plugins/payment/classes/yf_payment_api__provider.class.php - About 3 hrs to fix

          Method create_table has 85 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function create_table($table, $extra = [], &$error = false)
              {
                  // Example callable: create_table($name, function($t) { $t->int('id', 10); });
                  if (is_callable($extra)) {
                      if (strpos($table, '.') !== false) {
          Severity: Major
          Found in plugins/db/classes/db/yf_db_utils_driver.class.php - About 3 hrs to fix

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

            <?php
            
            _class('payment_api__provider_remote');
            
            class yf_payment_api__provider_bitcoin extends yf_payment_api__provider_remote
            Severity: Minor
            Found in plugins/payment/classes/yf_payment_api__provider_bitcoin.class.php - About 3 hrs to fix

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

              <?php
              
              /**
               * Ethereum API wrapper.
               */
              Severity: Minor
              Found in plugins/ethereum/classes/yf_wrapper_ethereum.class.php - About 3 hrs to fix

                File pack_zend.php has 307 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                //-----------------------------------------------------------
                // settings
                //-----------------------------------------------------------
                Severity: Minor
                Found in .dev/useful/pack_zend.php - About 3 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language