mygento/yandexdelivery

View on GitHub
app/code/local/Mygento/Yandexdelivery/controllers/Adminhtml/Yandexdelivery/ApiController.php

Summary

Maintainability
A
3 hrs
Test Coverage

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

    public function sendAction()
    {

        if (!$this->getRequest()->isPost()) {
            Mage::getSingleton('adminhtml/session')->addError('Sending error');

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

        private function confirmOrder($ydId, $senderId, $type, $showAdmin = true)
        {
    
            $result = Mage::getModel('yandexdelivery/carrier')->confirmOrders($ydId, $senderId, $type);
    
    

    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 sendAction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function sendAction()
        {
    
            if (!$this->getRequest()->isPost()) {
                Mage::getSingleton('adminhtml/session')->addError('Sending error');

    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 using undefined variables such as '$warehouseId' which will lead to PHP notices.
    Open

            Mage::getModel('yandexdelivery/carrier')->updateOrder($orderId, $warehouseId, $senderId, $requisiteId);

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$requisiteId' which will lead to PHP notices.
    Open

            Mage::getModel('yandexdelivery/carrier')->updateOrder($orderId, $warehouseId, $senderId, $requisiteId);

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$senderId' which will lead to PHP notices.
    Open

            Mage::getModel('yandexdelivery/carrier')->updateOrder($orderId, $warehouseId, $senderId, $requisiteId);

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    The method confirmOrder has a boolean flag argument $showAdmin, which is a certain sign of a Single Responsibility Principle violation.
    Open

        private function confirmOrder($ydId, $senderId, $type, $showAdmin = true)

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

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

    The method deleteAction uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $errors = (array) $result->data->errors;
                $error_text = '';
                foreach ($errors as $key => $value) {
                    $error_text .= $key . " - " . $value . "\n";

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    Avoid unused local variables such as '$senderId'.
    Open

            Mage::getModel('yandexdelivery/carrier')->updateOrder($orderId, $warehouseId, $senderId, $requisiteId);

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    Avoid unused local variables such as '$warehouseId'.
    Open

            Mage::getModel('yandexdelivery/carrier')->updateOrder($orderId, $warehouseId, $senderId, $requisiteId);

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    Avoid unused local variables such as '$requisiteId'.
    Open

            Mage::getModel('yandexdelivery/carrier')->updateOrder($orderId, $warehouseId, $senderId, $requisiteId);

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    Avoid unused local variables such as '$yandexShipment'.
    Open

            $yandexShipment = Mage::getModel('yandexdelivery/carrier')->getShipment($orderId);

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    Avoid excessively long class names like Mygento_Yandexdelivery_Adminhtml_Yandexdelivery_ApiController. Keep class name length under 40.
    Open

    class Mygento_Yandexdelivery_Adminhtml_Yandexdelivery_ApiController extends Mage_Adminhtml_Controller_Action
    {
    
        public function sendAction()
        {

    LongClassName

    Since: 2.9

    Detects when classes or interfaces are declared with excessively long names.

    Example

    class ATooLongClassNameThatHintsAtADesignProblem {
    
    }
    
    interface ATooLongInterfaceNameThatHintsAtADesignProblem {
    
    }

    Source https://phpmd.org/rules/naming.html#longclassname

    The class Mygento_Yandexdelivery_Adminhtml_Yandexdelivery_ApiController is not named in CamelCase.
    Open

    class Mygento_Yandexdelivery_Adminhtml_Yandexdelivery_ApiController extends Mage_Adminhtml_Controller_Action
    {
    
        public function sendAction()
        {

    CamelCaseClassName

    Since: 0.2

    It is considered best practice to use the CamelCase notation to name classes.

    Example

    class class_name {
    }

    Source

    The variable $order_id is not named in camelCase.
    Open

        public function labelAction()
        {
            $order_id = Mage::app()->getRequest()->getParam('orderid');
    
            if (!$order_id) {

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $order_id is not named in camelCase.
    Open

        public function labelAction()
        {
            $order_id = Mage::app()->getRequest()->getParam('orderid');
    
            if (!$order_id) {

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $order_id is not named in camelCase.
    Open

        public function deleteAction()
        {
            $order_id = Mage::app()->getRequest()->getParam('orderid');
    
            if (!$order_id) {

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $order_id is not named in camelCase.
    Open

        public function deleteAction()
        {
            $order_id = Mage::app()->getRequest()->getParam('orderid');
    
            if (!$order_id) {

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $error_text is not named in camelCase.
    Open

        public function deleteAction()
        {
            $order_id = Mage::app()->getRequest()->getParam('orderid');
    
            if (!$order_id) {

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $error_text is not named in camelCase.
    Open

        public function deleteAction()
        {
            $order_id = Mage::app()->getRequest()->getParam('orderid');
    
            if (!$order_id) {

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $order_id is not named in camelCase.
    Open

        public function deleteAction()
        {
            $order_id = Mage::app()->getRequest()->getParam('orderid');
    
            if (!$order_id) {

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $error_text is not named in camelCase.
    Open

        public function deleteAction()
        {
            $order_id = Mage::app()->getRequest()->getParam('orderid');
    
            if (!$order_id) {

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $order_id is not named in camelCase.
    Open

        public function labelAction()
        {
            $order_id = Mage::app()->getRequest()->getParam('orderid');
    
            if (!$order_id) {

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The method _isAllowed is not named in camelCase.
    Open

        protected function _isAllowed()
        {
            return Mage::getSingleton('admin/session')->isAllowed('catalog/yandexdelivery/api');
        }

    CamelCaseMethodName

    Since: 0.2

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

    Example

    class ClassName {
        public function get_name() {
        }
    }

    Source

    There are no issues that match your filters.

    Category
    Status