imagecms/ImageCMS

View on GitHub
application/modules/sitemap/admin.php

Summary

Maintainability
F
3 days
Test Coverage

Function blockedUrls has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public function blockedUrls() {
        if ($this->input->post()) {
            /**
             * Prepare data to update changefreq
             */
Severity: Minor
Found in application/modules/sitemap/admin.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 priorities has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function priorities() {
        if ($this->input->post()) {
            /** Priorities validation */
            $this->form_validation->set_rules('main_page_priority', lang('Main page priority', 'sitemap'), 'required|callback_priority_validation');
            $this->form_validation->set_rules('cats_priority', lang('Categories priority', 'sitemap'), 'required|callback_priority_validation');
Severity: Minor
Found in application/modules/sitemap/admin.php - About 1 hr to fix

Method changefreq has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function changefreq() {
        if ($this->input->post()) {
            /**
             * Prepare data to update changefreq
             */
Severity: Minor
Found in application/modules/sitemap/admin.php - About 1 hr to fix

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

    public function priorities() {
        if ($this->input->post()) {
            /** Priorities validation */
            $this->form_validation->set_rules('main_page_priority', lang('Main page priority', 'sitemap'), 'required|callback_priority_validation');
            $this->form_validation->set_rules('cats_priority', lang('Categories priority', 'sitemap'), 'required|callback_priority_validation');
Severity: Minor
Found in application/modules/sitemap/admin.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

Method blockedUrls has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function blockedUrls() {
        if ($this->input->post()) {
            /**
             * Prepare data to update changefreq
             */
Severity: Minor
Found in application/modules/sitemap/admin.php - About 1 hr to fix

Method settings has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function settings() {
        if ($this->input->post()) {
            /** Data to update */
            $data = $this->input->post('settings');

Severity: Minor
Found in application/modules/sitemap/admin.php - About 1 hr to fix

Function saveSiteMap has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function saveSiteMap() {
        $lang = new MY_Lang();
        $lang->load('sitemap');
        $successMessage = lang('Site map have been saved', 'sitemap');
        $successMessageTitle = lang('Site map have been saved', 'sitemap');
Severity: Minor
Found in application/modules/sitemap/admin.php - About 55 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

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

    public function settings() {
        if ($this->input->post()) {
            /** Data to update */
            $data = $this->input->post('settings');

Severity: Minor
Found in application/modules/sitemap/admin.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

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

    public function changefreq() {
        if ($this->input->post()) {
            /**
             * Prepare data to update changefreq
             */
Severity: Minor
Found in application/modules/sitemap/admin.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

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

            if (SHOP_INSTALLED) {
                $data = [
                         'main_page_changefreq'               => $this->input->post('main_page_changefreq'),
                         'categories_changefreq'              => $this->input->post('categories_changefreq'),
                         'pages_changefreq'                   => $this->input->post('pages_changefreq'),
Severity: Major
Found in application/modules/sitemap/admin.php and 1 other location - About 5 hrs to fix
application/modules/sitemap/admin.php on lines 179..197

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

            if (SHOP_INSTALLED) {
                $data = [
                         'main_page_priority'               => $this->input->post('main_page_priority'),
                         'cats_priority'                    => $this->input->post('cats_priority'),
                         'pages_priority'                   => $this->input->post('pages_priority'),
Severity: Major
Found in application/modules/sitemap/admin.php and 1 other location - About 5 hrs to fix
application/modules/sitemap/admin.php on lines 96..114

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

                         'changefreq_options' => [
                                                  'always'  => lang('always', 'sitemap'),
                                                  'hourly'  => lang('hourly', 'sitemap'),
                                                  'daily'   => lang('daily', 'sitemap'),
                                                  'weekly'  => lang('weekly', 'sitemap'),
Severity: Major
Found in application/modules/sitemap/admin.php and 1 other location - About 1 hr to fix
application/modules/mod_discount/classes/BaseDiscount.php on lines 278..286

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

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->sitemap_model->updateChangefreq($data)) {
                showMessage(lang('Changes have been saved', 'sitemap'), lang('Message', 'sitemap'));
                $this->lib_admin->log(lang('Sitemaps freq was edited', 'sitemap'));
            } else {
                showMessage(lang('Changes have not been saved', 'sitemap'), lang('Error', 'sitemap'), 'r');
Severity: Major
Found in application/modules/sitemap/admin.php and 1 other location - About 1 hr to fix
application/modules/sitemap/admin.php on lines 200..205

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

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->sitemap_model->updatePriorities($data)) {
                showMessage(lang('Changes have been saved', 'sitemap'), lang('Message', 'sitemap'));
                $this->lib_admin->log(lang('Sitemaps priorities was edited', 'sitemap'));
            } else {
                showMessage(lang('Changes have not been saved', 'sitemap'), lang('Error', 'sitemap'), 'r');
Severity: Major
Found in application/modules/sitemap/admin.php and 1 other location - About 1 hr to fix
application/modules/sitemap/admin.php on lines 117..122

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

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