imagecms/ImageCMS

View on GitHub
application/modules/search/search.php

Summary

Maintainability
F
4 days
Test Coverage

Function execute has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute($where = [], $offset = 0) {
        $collect_ids = FALSE;

        if ($this->table == '') {
            $error = lang('Error. Select or specify the table for search', 'search');
Severity: Minor
Found in application/modules/search/search.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

File search.php has 435 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}
Severity: Minor
Found in application/modules/search/search.php - About 6 hrs to fix

Method execute has 111 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function execute($where = [], $offset = 0) {
        $collect_ids = FALSE;

        if ($this->table == '') {
            $error = lang('Error. Select or specify the table for search', 'search');
Severity: Major
Found in application/modules/search/search.php - About 4 hrs to fix

Function countSearchResults has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    private function countSearchResults($where) {
        // begin query
        if (count($where) > 0) {
            foreach ($where as $params) {
                // Set search operator. (where, like, or_where, etc..)
Severity: Minor
Found in application/modules/search/search.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

Method index has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function index($hash = '', $offset = 0) {
        $this->template->registerMeta('ROBOTS', 'NOINDEX, NOFOLLOW');

        $offset = (int) $offset;

Severity: Major
Found in application/modules/search/search.php - About 2 hrs to fix

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

    private function prepareCategoriesForSearchResults($foundInCategories) {
        $categoriesArray = [];
        $categoriesAll = $this->lib_category->unsorted();
        foreach ($categoriesAll as $key => $value) {
            /** Count of found pages in category * */
Severity: Minor
Found in application/modules/search/search.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 index has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function index($hash = '', $offset = 0) {
        $this->template->registerMeta('ROBOTS', 'NOINDEX, NOFOLLOW');

        $offset = (int) $offset;

Severity: Minor
Found in application/modules/search/search.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 _install has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function _install() {
        if ($this->dx_auth->is_admin() == FALSE) {
            exit;
        }

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

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

    private function countSearchResults($where) {
        // begin query
        if (count($where) > 0) {
            foreach ($where as $params) {
                // Set search operator. (where, like, or_where, etc..)
Severity: Minor
Found in application/modules/search/search.php - About 1 hr to fix

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

    public function _display($pages = [], $foundInCategories = null) {
        /*         * Prepare categories for search results * */
        $categoriesInSearchResults = null;
        $tree = null;
        $categories = [];
Severity: Minor
Found in application/modules/search/search.php - About 1 hr to fix

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

    public function _display($pages = [], $foundInCategories = null) {
        /*         * Prepare categories for search results * */
        $categoriesInSearchResults = null;
        $tree = null;
        $categories = [];
Severity: Minor
Found in application/modules/search/search.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 init has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function init($config = []) {
        foreach ($config as $key => $val) {
            if (isset($this->$key)) {
                $this->$key = $val;
            } else {
Severity: Minor
Found in application/modules/search/search.php - About 35 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 _highlight_text has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function _highlight_text($data, $text) {
        if (!$data) {
            return;
        }
        $dataCount = count($data);
Severity: Minor
Found in application/modules/search/search.php - About 25 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

There are no issues that match your filters.

Category
Status