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();
- Create a ticketCreate a ticket
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()
- Read upRead up
- Create a ticketCreate a ticket
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();
- Create a ticketCreate a ticket
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();
- Create a ticketCreate a ticket
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()
- Create a ticketCreate a ticket
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');
- Create a ticketCreate a ticket
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) {
- Read upRead up
- Create a ticketCreate a ticket
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) {
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
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(
- Create a ticketCreate a ticket
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');
- Read upRead up
- Create a ticketCreate a ticket
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) {
- Read upRead up
- Create a ticketCreate a ticket
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',
- Create a ticketCreate a ticket
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();
- Read upRead up
- Create a ticketCreate a ticket
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,
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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,
- Read upRead up
- Create a ticketCreate a ticket
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method joinStockDataOnProductAndStoreView
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function joinStockDataOnProductAndStoreView($productId = false, $storeViewId = false)
{
$this
->getSelect()
->join(
- Create a ticketCreate a ticket
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) {
- Create a ticketCreate a ticket
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) . ')';
- Create a ticketCreate a ticket
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();
- Create a ticketCreate a ticket