DemacMedia/Magento-Multi-Location-Inventory

View on GitHub

Showing 49 of 49 total issues

Method importMultiLocationInventory has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function importMultiLocationInventory(Varien_Event_Observer $observer)
    {
        /** @var Mage_ImportExport_Model_Import_Entity_Product $adapter */
        $adapter = $observer->getData('adapter');
        if(!$adapter) {

Method _locationStockIterate has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function _locationStockIterate($args)
    {
        $quoteItemId  = $args['quote_item_id'];
        $productId    = $args['product_id'];
        $requestedQty = $this->checkoutProducts[$quoteItemId];
Severity: Minor
Found in app/code/community/Demac/MultiLocationInventory/Model/Observer.php - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

        if((isset($locationData['address']) || isset($locationData['country'])
                || isset($locationData['city']) || isset($locationData['region_id']))
            && (!isset($locationData['lat']) || !isset($locationData['long'])
                || $locationData['lat'] == '' || $locationData['long'] == '')
        ) {
Severity: Critical
Found in app/code/community/Demac/MultiLocationInventory/Model/Location/Api.php - About 1 hr to fix

Method _getSearchableProducts has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function _getSearchableProducts($storeId, array $staticFields, $productIds = null, $lastProductId = 0,
                                              $limit = 100)
    {
        $websiteId    = Mage::app()->getStore($storeId)->getWebsiteId();
        $writeAdapter = $this->_getWriteAdapter();

Function checkoutAllSubmitAfter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function checkoutAllSubmitAfter($observer)
    {
        if(Mage::getStoreConfig('cataloginventory/options/can_subtract')) {

            $order   = $observer->getEvent()->getOrder();
Severity: Minor
Found in app/code/community/Demac/MultiLocationInventory/Model/Observer.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 getAddressInformation has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getAddressInformation($locationData, $locationItem)
    {
        $country = isset($locationData['country']) ? $locationData['country'] : $locationItem->getCountry();
        $address = isset($locationData['address']) ? $locationData['address'] : $locationItem->getAddress();
        $city    = isset($locationData['city']) ? $locationData['city'] : $locationItem->getCity();

Method create has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function create($data)
    {
        try {
            $data = (array) $data;
Severity: Minor
Found in app/code/community/Demac/MultiLocationInventory/Model/Stock/Api.php - About 1 hr to fix

Method cancelOrderItem has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function cancelOrderItem($observer)
    {
        $item = $observer->getEvent()->getItem();

        $children = $item->getChildrenItems();

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

    public function saveAction()
    {
        if($postData = $this->getRequest()->getPost()) {
            $locationModel = Mage::getSingleton('demac_multilocationinventory/location');
            if($id = $this->getRequest()->getParam('id')) {

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

    public function refundOrderInventory($observer)
    {
        /* @var $creditmemo Mage_Sales_Model_Order_Creditmemo */
        $creditmemo = $observer->getEvent()->getCreditmemo();
        $items      = array();

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

    public function walk($query, array $callbacks, array $args = array(), $adapter = null)
    {
        $stmt        = $this->_getStatement($query, $adapter);
        $args['idx'] = 0;
        while ($row = $stmt->fetch()) {

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 _loopCancelItem has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function _loopCancelItem($args)
    {
        $productId = $args['product_id'];

        $row = $args['row'];

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

    public function getPrioritizedLocationsForOrderQuoteItem($orderId, $quoteItemId)
    {
        //get storeview id from order id.
        $storeId = Mage::getModel('sales/order')->load($orderId)->getStoreId();

Severity: Minor
Found in app/code/community/Demac/MultiLocationInventory/Helper/Location.php - About 1 hr to fix

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

    public function update($data)
    {
        try {
            $data = (array) $data;
            $locationItem = Mage::getModel('demac_multilocationinventory/location')->load($data['location_id']);

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

    public function multiLocationInventoryProductSave($observer)
    {
        $productId       = $observer->getEvent()->getProduct()->getId();
        $this->inputData = Mage::app()->getRequest()->getPost('multilocationinventory');
        if($productId) {
Severity: Minor
Found in app/code/community/Demac/MultiLocationInventory/Model/Admin/Observer.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 checkQty has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function checkQty($qty)
    {
        if (!$this->getManageStock() || Mage::app()->getStore()->isAdmin()) {
            return true;
        }

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

    public function getRegions($countryCode)
    {
        $options            = array();
        $notAvailableOption = array(
            'value' => 'N/A',
Severity: Minor
Found in app/code/community/Demac/MultiLocationInventory/Helper/Data.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 _locationStockIterate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function _locationStockIterate($args)
    {
        $quoteItemId  = $args['quote_item_id'];
        $productId    = $args['product_id'];
        $requestedQty = $this->checkoutProducts[$quoteItemId];
Severity: Minor
Found in app/code/community/Demac/MultiLocationInventory/Model/Observer.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 _getSearchableProducts has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    protected function _getSearchableProducts($storeId, array $staticFields, $productIds = null, $lastProductId = 0,
                                              $limit = 100)

Function items has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function items($locationId, $filters)
    {
        $collection = Mage::getResourceModel('demac_multilocationinventory/stock_collection');
        if(isset($locationId) && !is_null($locationId)) {
            $collection->addFieldToFilter('location_id', $locationId);
Severity: Minor
Found in app/code/community/Demac/MultiLocationInventory/Model/Stock/Api.php - About 35 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

Severity
Category
Status
Source
Language