imagecms/ImageCMS

View on GitHub
application/modules/mod_stats/models/products_model.php

Summary

Maintainability
B
6 hrs
Test Coverage

Function getCategoriesCountsData has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function getCategoriesCountsData($categoryIds = [], $unique = FALSE) {
        $categories = $this->getAllCategories();

        // creating array of id and parent_id of each category
        $categoriresRelations = [];
Severity: Minor
Found in application/modules/mod_stats/models/products_model.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 getBrandsCountsData has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getBrandsCountsData($limit = 20, $brandIds = NULL, $uniqueProducts = FALSE) {
        // if brand ids specified, then leave only them
        $brands = $this->getAllBrands();
        if (is_array($brandIds)) {
            foreach ($brands as $id => $name) {
Severity: Minor
Found in application/modules/mod_stats/models/products_model.php - About 1 hr to fix

Method getCategoriesCountsData has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getCategoriesCountsData($categoryIds = [], $unique = FALSE) {
        $categories = $this->getAllCategories();

        // creating array of id and parent_id of each category
        $categoriresRelations = [];
Severity: Minor
Found in application/modules/mod_stats/models/products_model.php - About 1 hr to fix

Function getBrandsCountsData has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function getBrandsCountsData($limit = 20, $brandIds = NULL, $uniqueProducts = FALSE) {
        // if brand ids specified, then leave only them
        $brands = $this->getAllBrands();
        if (is_array($brandIds)) {
            foreach ($brands as $id => $name) {
Severity: Minor
Found in application/modules/mod_stats/models/products_model.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 getSubcategoriesIds has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getSubcategoriesIds($id = null) {
        if (!$id) {
            return FALSE;
        }
        $res = $this->db
Severity: Minor
Found in application/modules/mod_stats/models/products_model.php - About 1 hr to fix

There are no issues that match your filters.

Category
Status