DemacMedia/Magento-Multi-Location-Inventory

View on GitHub

Showing 49 of 49 total issues

File upgrade-1.2.5-1.2.6.php has 812 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
$installer = $this;

$installer->startSetup();

Function checkQuoteItemQty has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
Open

    public function checkQuoteItemQty($observer)
    {
        $quoteItem = $observer->getEvent()->getItem();
        /* @var $quoteItem Mage_Sales_Model_Quote_Item */
        if(!$quoteItem || !$quoteItem->getProductId() || !$quoteItem->getQuote()

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

File upgrade-1.2.3-1.2.4.php has 525 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
$installer = $this;

$installer->startSetup();

File upgrade-1.2.4-1.2.5.php has 521 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
$installer = $this;

$installer->startSetup();

Method checkQuoteItemQty has 183 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function checkQuoteItemQty($observer)
    {
        $quoteItem = $observer->getEvent()->getItem();
        /* @var $quoteItem Mage_Sales_Model_Quote_Item */
        if(!$quoteItem || !$quoteItem->getProductId() || !$quoteItem->getQuote()

Method _prepareForm has 99 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function _prepareForm()
    {
        $form = new Varien_Data_Form();

        $form->setFieldNameSuffix('simple_product');

Function importMultiLocationInventory has a Cognitive Complexity of 24 (exceeds 5 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) {

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

    protected function removeStockFromLocations($order, $quote)
    {
        $orderId = $order->getId();

        foreach ($this->checkoutProducts as $checkoutProductQuoteItemId => $checkoutProductQuantity) {
Severity: Major
Found in app/code/community/Demac/MultiLocationInventory/Model/Observer.php - About 3 hrs to fix

File Observer.php has 296 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Class Demac_MultiLocationInventory_Model_CatalogInventory_Observer
 */
class Demac_MultiLocationInventory_Model_CatalogInventory_Observer extends Mage_CatalogInventory_Model_Observer

Method _prepareColumns has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function _prepareColumns()
    {
        // Add the columns that should appear in the grid
        $this->addColumn('id',
                         array(

Function _prepareForm has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    protected function _prepareForm()
    {
        $form = new Varien_Data_Form();

        $form->setFieldNameSuffix('simple_product');

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

    protected function removeStockFromLocations($order, $quote)
    {
        $orderId = $order->getId();

        foreach ($this->checkoutProducts as $checkoutProductQuoteItemId => $checkoutProductQuantity) {
Severity: Minor
Found in app/code/community/Demac/MultiLocationInventory/Model/Observer.php - About 2 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

Method _prepareFormAddressFields has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function _prepareFormAddressFields($fieldset)
    {
        $fieldset->addField('address', 'text', array(
            'label'    => $this->__('Address'),
            'class'    => 'required-entry',

Function getAddressInformation has a Cognitive Complexity of 14 (exceeds 5 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();

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

$table = $installer->getConnection()
    ->newTable($installer->getTable('demac_multilocationinventory/stores'))
    ->addColumn('location_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
        'unsigned' => true,
        'nullable' => false,
app/code/community/Demac/MultiLocationInventory/sql/demac_multilocationinventory_setup/upgrade-1.1.1-1.1.2.php on lines 16..28

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 115.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

$table = $installer->getConnection()
    ->newTable($installer->getTable('demac_multilocationinventory/quote'))
    ->addColumn('item_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
        'unsigned' => true,
        'nullable' => false,
app/code/community/Demac/MultiLocationInventory/sql/demac_multilocationinventory_setup/install-1.0.0.php on lines 63..79

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 115.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method joinStockDataOnProductAndStoreView has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function joinStockDataOnProductAndStoreView($productId = false, $storeViewId = false)
    {
        $this
            ->getSelect()
            ->join(

Method multiLocationInventoryProductSave has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function multiLocationInventoryProductSave($observer)
    {
        $productId       = $observer->getEvent()->getProduct()->getId();
        $this->inputData = Mage::app()->getRequest()->getPost('multilocationinventory');
        if($productId) {

Method createMissingStockRows has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function createMissingStockRows($productIds)
    {
        $productFilter = '';
        if($productIds !== false) {
            $productFilter = ' AND e.entity_id IN(' . implode(',', $productIds) . ')';

Method refundOrderInventory has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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