midasplatform/Midas

View on GitHub
core/controllers/AssetstoreController.php

Summary

Maintainability
B
5 hrs
Test Coverage

addAction accesses the super-global variable $_POST.
Open

    public function addAction()
    {
        $this->requireAdminPrivileges();
        $this->disableLayout();
        $this->disableView();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

addAction accesses the super-global variable $_POST.
Open

    public function addAction()
    {
        $this->requireAdminPrivileges();
        $this->disableLayout();
        $this->disableView();

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Method addAction has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function addAction()
    {
        $this->requireAdminPrivileges();
        $this->disableLayout();
        $this->disableView();
Severity: Minor
Found in core/controllers/AssetstoreController.php - About 1 hr to fix

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

    public function editAction()
    {
        $this->requireAdminPrivileges();
        $this->disableLayout();
        $this->disableView();
Severity: Minor
Found in core/controllers/AssetstoreController.php - About 1 hr to fix

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

    public function editAction()
    {
        $this->requireAdminPrivileges();
        $this->disableLayout();
        $this->disableView();
Severity: Minor
Found in core/controllers/AssetstoreController.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 addAction has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function addAction()
    {
        $this->requireAdminPrivileges();
        $this->disableLayout();
        $this->disableView();
Severity: Minor
Found in core/controllers/AssetstoreController.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

Avoid too many return statements within this method.
Open

        return false;
Severity: Major
Found in core/controllers/AssetstoreController.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

            return true;
Severity: Major
Found in core/controllers/AssetstoreController.php - About 30 mins to fix

Missing class import via use statement (line '226', column '23').
Open

            throw new Zend_Exception('Must provide srcAssetstoreId and dstAssetstoreId parameters');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '137', column '34').
Open

            $assetstoreDao = new AssetstoreDao();

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '235', column '23').
Open

            throw new Zend_Exception('Invalid srcAssetstoreId or dstAssetstoreId');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '198', column '23').
Open

            throw new Zend_Exception('Must provide srcAssetstoreId parameter');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '204', column '23').
Open

            throw new Zend_Exception('Invalid srcAssetstoreId');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Avoid using static access to class 'JsonComponent' in method 'editAction'.
Open

                    echo JsonComponent::encode(array(false, $ze->getMessage()));

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'JsonComponent' in method 'defaultassetstoreAction'.
Open

                echo JsonComponent::encode(array(true, $this->t('Changes saved')));

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'JsonComponent' in method 'addAction'.
Open

                echo JsonComponent::encode(array('error' => $ze->getMessage()));

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'JsonComponent' in method 'addAction'.
Open

                echo JsonComponent::encode(array('error' => 'The path provided is not a valid directory'));

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'JsonComponent' in method 'deleteAction'.
Open

                echo JsonComponent::encode(array(true, $this->t('Changes saved')));

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'JsonComponent' in method 'deleteAction'.
Open

        echo JsonComponent::encode(array(false, $this->t('Error')));

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'JsonComponent' in method 'editAction'.
Open

                echo JsonComponent::encode(array(true, $this->t('Changes saved')));

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'JsonComponent' in method 'defaultassetstoreAction'.
Open

        echo JsonComponent::encode(array(false, $this->t('Error')));

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'UtilityComponent' in method 'addAction'.
Open

            $totalSpace = UtilityComponent::diskTotalSpace($assetstoreDao->getPath());

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'JsonComponent' in method 'editAction'.
Open

            echo JsonComponent::encode(array(false, 'The path provided is not a valid directory'));

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'JsonComponent' in method 'addAction'.
Open

            echo JsonComponent::encode(
                array(
                    'msg' => 'The assetstore has been added.',
                    'assetstore_id' => $assetstoreDao->getAssetstoreId(),
                    'assetstore_name' => $assetstoreDao->getName(),

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'JsonComponent' in method 'editAction'.
Open

            echo JsonComponent::encode(array(false, 'The specified directory is not writable'));

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'JsonComponent' in method 'editAction'.
Open

        echo JsonComponent::encode(array(false, $this->t('Error')));

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'JsonComponent' in method 'addAction'.
Open

                echo JsonComponent::encode(array('error' => 'The specified directory is not writable'));

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'UtilityComponent' in method 'addAction'.
Open

            $freeSpace = UtilityComponent::diskFreeSpace($assetstoreDao->getPath());

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'JsonComponent' in method 'movecontentsAction'.
Open

        echo JsonComponent::encode(array('status' => 'ok', 'message' => 'Bitstreams moved'));

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class AssetstoreController extends AppController

The property $_components is not named in camelCase.
Open

class AssetstoreController extends AppController
{
    public $_models = array('Assetstore', 'Bitstream', 'Progress', 'Setting');
    public $_daos = array('Assetstore');
    public $_components = array('Utility');

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $_daos is not named in camelCase.
Open

class AssetstoreController extends AppController
{
    public $_models = array('Assetstore', 'Bitstream', 'Progress', 'Setting');
    public $_daos = array('Assetstore');
    public $_components = array('Utility');

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $_models is not named in camelCase.
Open

class AssetstoreController extends AppController
{
    public $_models = array('Assetstore', 'Bitstream', 'Progress', 'Setting');
    public $_daos = array('Assetstore');
    public $_components = array('Utility');

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $_forms is not named in camelCase.
Open

class AssetstoreController extends AppController
{
    public $_models = array('Assetstore', 'Bitstream', 'Progress', 'Setting');
    public $_daos = array('Assetstore');
    public $_components = array('Utility');

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

Property name "$_forms" should not be prefixed with an underscore to indicate visibility
Open

    public $_forms = array('Assetstore');

Property name "$_components" should not be prefixed with an underscore to indicate visibility
Open

    public $_components = array('Utility');

Property name "$_models" should not be prefixed with an underscore to indicate visibility
Open

    public $_models = array('Assetstore', 'Bitstream', 'Progress', 'Setting');

Property name "$_daos" should not be prefixed with an underscore to indicate visibility
Open

    public $_daos = array('Assetstore');

There are no issues that match your filters.

Category
Status