imagecms/ImageCMS

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

Summary

Maintainability
F
6 days
Test Coverage

File admin.php has 821 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}
Severity: Major
Found in application/modules/gallery/admin.php - About 1 day to fix

Method resize_and_thumb has 130 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function resize_and_thumb($file = []) {
        $this->load->library('image_lib');

        // Resize image
        if ($this->conf['max_width'] > 0 AND $this->conf['max_height'] > 0) {
Severity: Major
Found in application/modules/gallery/admin.php - About 5 hrs to fix

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

    public function settings($action = 'show') {

        switch ($action) {
            case 'show':
                \CMSFactory\assetManager::create()
Severity: Major
Found in application/modules/gallery/admin.php - About 4 hrs to fix

Function resize_and_thumb has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    private function resize_and_thumb($file = []) {
        $this->load->library('image_lib');

        // Resize image
        if ($this->conf['max_width'] > 0 AND $this->conf['max_height'] > 0) {
Severity: Minor
Found in application/modules/gallery/admin.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

Admin has 30 functions (exceeds 20 allowed). Consider refactoring.
Open

class Admin extends BaseAdminController
{

    // Gallery config
    public $conf = [
Severity: Minor
Found in application/modules/gallery/admin.php - About 3 hrs to fix

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

    public function settings($action = 'show') {

        switch ($action) {
            case 'show':
                \CMSFactory\assetManager::create()
Severity: Minor
Found in application/modules/gallery/admin.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

Function upload_image has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function upload_image($album_id = 0) {
        $temp_conf = $this->conf;
        if (is_array($_FILES['newPic'])) {

            if (count($_FILES['newPic']['name']) > ini_get('max_file_uploads')) {
Severity: Minor
Found in application/modules/gallery/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 upload_image has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function upload_image($album_id = 0) {
        $temp_conf = $this->conf;
        if (is_array($_FILES['newPic'])) {

            if (count($_FILES['newPic']['name']) > ini_get('max_file_uploads')) {
Severity: Minor
Found in application/modules/gallery/admin.php - About 1 hr to fix

Method update_album has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function update_album($id, $locale) {
        $this->form_validation->set_rules('name', lang('Name', 'gallery'), 'required');
        $tpl_file = $this->input->post('tpl_file');
        if (!preg_match('/[a-z]/', $tpl_file) && !empty($tpl_file)) {
            showMessage('wrong tpl name', '', 'r');
Severity: Minor
Found in application/modules/gallery/admin.php - About 1 hr to fix

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

    public function category($id) {
        $albums = $this->gallery_m->get_albums('position', 'asc', $id);

        if ($albums != FALSE) {
            $cnt = count($albums);
Severity: Minor
Found in application/modules/gallery/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 update_category has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function update_category($id, $locale) {
        $this->load->library('Form_validation');
        $val = $this->form_validation;

        $val->set_rules('name', lang('Name', 'gallery'), 'trim|required|max_length[250]|min_length[1]');
Severity: Minor
Found in application/modules/gallery/admin.php - About 1 hr to fix

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

    private function add_image($album_id = 0, $file_data = []) {
        $this->load->helper('number');

        $size = $this->get_image_size($file_data['full_path']);

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

Method category has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function category($id) {
        $albums = $this->gallery_m->get_albums('position', 'asc', $id);

        if ($albums != FALSE) {
            $cnt = count($albums);
Severity: Minor
Found in application/modules/gallery/admin.php - About 1 hr to fix

Method create_category has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function create_category() {

        $locale = $this->gallery_m->chose_locale();

        $this->load->library('Form_validation');
Severity: Minor
Found in application/modules/gallery/admin.php - About 1 hr to fix

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

    public function update_category($id, $locale) {
        $this->load->library('Form_validation');
        $val = $this->form_validation;

        $val->set_rules('name', lang('Name', 'gallery'), 'trim|required|max_length[250]|min_length[1]');
Severity: Minor
Found in application/modules/gallery/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 update_album has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function update_album($id, $locale) {
        $this->form_validation->set_rules('name', lang('Name', 'gallery'), 'required');
        $tpl_file = $this->input->post('tpl_file');
        if (!preg_match('/[a-z]/', $tpl_file) && !empty($tpl_file)) {
            showMessage('wrong tpl name', '', 'r');
Severity: Minor
Found in application/modules/gallery/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 update_info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function update_info($id, $locale = null) {

        if (null === $locale) {
            $locale = $this->gallery_m->chose_locale();
        }
Severity: Minor
Found in application/modules/gallery/admin.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

Function create_album has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function create_album() {
        $this->load->library('Form_validation');

        $this->form_validation->set_rules('name', lang('Name', 'gallery'), 'required|min_length[3]|max_length[250]');
        $this->form_validation->set_rules('email', lang('Description', 'gallery'), 'max_length[500]');
Severity: Minor
Found in application/modules/gallery/admin.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

Function delete_category has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function delete_category() {
        foreach ($this->input->post('id') as $id) {

            // Delete category albums
            $albums = $this->gallery_m->get_albums('date', 'desc', $id);
Severity: Minor
Found in application/modules/gallery/admin.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