arastta/arastta

View on GitHub
admin/controller/setting/setting.php

Summary

Maintainability
F
3 wks
Test Coverage

Function index has a Cognitive Complexity of 505 (exceeds 5 allowed). Consider refactoring.
Open

    public function index() {
        $this->load->language('setting/setting');

        $this->document->setTitle($this->language->get('heading_title'));

Severity: Minor
Found in admin/controller/setting/setting.php - About 1 wk 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 index has 1350 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function index() {
        $this->load->language('setting/setting');

        $this->document->setTitle($this->language->get('heading_title'));

Severity: Major
Found in admin/controller/setting/setting.php - About 6 days to fix

    File setting.php has 1535 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * @package     Arastta eCommerce
     * @copyright   2015-2017 Arastta Association. All rights reserved.
     * @copyright   See CREDITS.txt for credits and other copyright notices.
    Severity: Major
    Found in admin/controller/setting/setting.php - About 4 days to fix

      Function validate has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function validate() {
              if (!$this->user->hasPermission('modify', 'setting/setting')) {
                  $this->error['warning'] = $this->language->get('error_permission');
              }
      
      
      Severity: Minor
      Found in admin/controller/setting/setting.php - About 6 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 validate has 114 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function validate() {
              if (!$this->user->hasPermission('modify', 'setting/setting')) {
                  $this->error['warning'] = $this->language->get('error_permission');
              }
      
      
      Severity: Major
      Found in admin/controller/setting/setting.php - About 4 hrs to fix

        Function getTimezones has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getTimezones()
            {
                // The list of available timezone groups to use.
                $use_zones = array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific');
        
        
        Severity: Minor
        Found in admin/controller/setting/setting.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

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

            public function country() {
                $json = array();
        
                $this->load->model('localisation/country');
        
        
        Severity: Major
        Found in admin/controller/setting/setting.php and 9 other locations - About 5 hrs to fix
        admin/controller/marketing/affiliate.php on lines 1192..1216
        admin/controller/sale/customer.php on lines 1638..1662
        admin/controller/sale/order.php on lines 1594..1618
        admin/controller/setting/store.php on lines 1099..1123
        catalog/controller/account/account.php on lines 93..117
        catalog/controller/affiliate/edit.php on lines 323..347
        catalog/controller/affiliate/register.php on lines 427..451
        catalog/controller/checkout/checkout.php on lines 122..146
        catalog/controller/checkout/shipping.php on lines 214..238

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

        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

                if (isset($this->request->post['config_image']) && is_file(DIR_IMAGE . $this->request->post['config_image'])) {
                    $data['thumb'] = $this->model_tool_image->resize($this->request->post['config_image'], 100, 100);
                } elseif ($this->config->get('config_image') && is_file(DIR_IMAGE . $this->config->get('config_image'))) {
                    $data['thumb'] = $this->model_tool_image->resize($this->config->get('config_image'), 100, 100);
                } else {
        Severity: Major
        Found in admin/controller/setting/setting.php and 3 other locations - About 4 hrs to fix
        admin/controller/setting/setting.php on lines 909..915
        admin/controller/setting/setting.php on lines 923..929
        admin/controller/setting/setting.php on lines 1672..1678

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

        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

                if (isset($this->request->post['config_logo']) && is_file(DIR_IMAGE . $this->request->post['config_logo'])) {
                    $data['logo'] = $this->model_tool_image->resize($this->request->post['config_logo'], 100, 100);
                } elseif ($this->config->get('config_logo') && is_file(DIR_IMAGE . $this->config->get('config_logo'))) {
                    $data['logo'] = $this->model_tool_image->resize($this->config->get('config_logo'), 100, 100);
                } else {
        Severity: Major
        Found in admin/controller/setting/setting.php and 3 other locations - About 4 hrs to fix
        admin/controller/setting/setting.php on lines 423..429
        admin/controller/setting/setting.php on lines 923..929
        admin/controller/setting/setting.php on lines 1672..1678

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

        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

                if (isset($this->request->post['config_maintenance_image']) && is_file(DIR_IMAGE . $this->request->post['config_maintenance_image'])) {
                    $data['maintenance_image'] = $this->model_tool_image->resize($this->request->post['config_maintenance_image'], 100, 100);
                } elseif ($this->config->get('config_maintenance_image') && is_file(DIR_IMAGE . $this->config->get('config_maintenance_image'))) {
                    $data['maintenance_image'] = $this->model_tool_image->resize($this->config->get('config_maintenance_image'), 100, 100);
                } else {
        Severity: Major
        Found in admin/controller/setting/setting.php and 3 other locations - About 4 hrs to fix
        admin/controller/setting/setting.php on lines 423..429
        admin/controller/setting/setting.php on lines 909..915
        admin/controller/setting/setting.php on lines 923..929

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

        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

                if (isset($this->request->post['config_icon']) && is_file(DIR_IMAGE . $this->request->post['config_icon'])) {
                    $data['icon'] = $this->model_tool_image->resize($this->request->post['config_logo'], 100, 100);
                } elseif ($this->config->get('config_icon') && is_file(DIR_IMAGE . $this->config->get('config_icon'))) {
                    $data['icon'] = $this->model_tool_image->resize($this->config->get('config_icon'), 100, 100);
                } else {
        Severity: Major
        Found in admin/controller/setting/setting.php and 3 other locations - About 4 hrs to fix
        admin/controller/setting/setting.php on lines 423..429
        admin/controller/setting/setting.php on lines 909..915
        admin/controller/setting/setting.php on lines 1672..1678

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

        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 template() {
                if ($this->request->server['HTTPS']) {
                    $server = HTTPS_CATALOG;
                } else {
                    $server = HTTP_CATALOG;
        Severity: Major
        Found in admin/controller/setting/setting.php and 1 other location - About 2 hrs to fix
        admin/controller/setting/store.php on lines 1085..1097

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

        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 (isset($this->request->post['config_cache_memcache_servers'])) {
                    $data['config_cache_memcache_servers'] = $this->request->post['config_cache_memcache_servers'];
                } else {
                    $memcache_servers = '';
        
        
        Severity: Major
        Found in admin/controller/setting/setting.php and 1 other location - About 1 hr to fix
        admin/controller/setting/setting.php on lines 1475..1489

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

        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 (isset($this->request->post['config_pagecache_exclude'])) {
                    $data['config_pagecache_exclude'] = $this->request->post['config_pagecache_exclude'];
                } else {
                    $ex_routes = '';
        
        
        Severity: Major
        Found in admin/controller/setting/setting.php and 1 other location - About 1 hr to fix
        admin/controller/setting/setting.php on lines 1435..1449

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

        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 ($this->request->post['config_cache_memcache_servers']) {
                        $memcache_servers = '';
        
                        foreach (explode("\n", $this->request->post['config_cache_memcache_servers']) as $server) {
                            $server = trim($server);
        Severity: Minor
        Found in admin/controller/setting/setting.php and 1 other location - About 55 mins to fix
        admin/controller/setting/setting.php on lines 32..44

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

        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 ($this->request->post['config_pagecache_exclude']) {
                        $ex_routes = '';
        
                        foreach (explode("\n", $this->request->post['config_pagecache_exclude']) as $route) {
                            $route = trim($route);
        Severity: Minor
        Found in admin/controller/setting/setting.php and 1 other location - About 55 mins to fix
        admin/controller/setting/setting.php on lines 60..72

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

        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