imagecms/ImageCMS

View on GitHub
application/modules/gallery/models/gallery_m.php

Summary

Maintainability
C
1 day
Test Coverage

Gallery_m has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

class Gallery_m extends CI_Model
{

    public function Base() {
        parent::__construct();
Severity: Minor
Found in application/modules/gallery/models/gallery_m.php - About 2 hrs to fix

File gallery_m.php has 260 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/gallery/models/gallery_m.php - About 2 hrs to fix

Method get_albums has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function get_albums($order_by = 'date', $sort_order = 'desc', $category_id = 0) {
        // Select albums

        $locale = $this->chose_locale();
        $this->joinI18n($this->db, 'gallery_albums', $locale);
Severity: Minor
Found in application/modules/gallery/models/gallery_m.php - About 1 hr to fix

Method get_categories has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function get_categories($order_by = 'name', $sort_order = 'desc') {
        if ($sort_order != 'desc' AND $sort_order != 'asc') {
            $sort_order = 'desc';
        }

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

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

    public function get_albums($order_by = 'date', $sort_order = 'desc', $category_id = 0) {
        // Select albums

        $locale = $this->chose_locale();
        $this->joinI18n($this->db, 'gallery_albums', $locale);
Severity: Minor
Found in application/modules/gallery/models/gallery_m.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 get_categories has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_categories($order_by = 'name', $sort_order = 'desc') {
        if ($sort_order != 'desc' AND $sort_order != 'asc') {
            $sort_order = 'desc';
        }

Severity: Minor
Found in application/modules/gallery/models/gallery_m.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

Method get_album has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function get_album($id = 0, $include_images = TRUE, $limit, $page, $locale = null) {
Severity: Minor
Found in application/modules/gallery/models/gallery_m.php - About 35 mins to fix

There are no issues that match your filters.

Category
Status