Method collectRates
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
Varien_Profiler::start($this->_name . '_collect_rate');
if (!$this->getType()) {
Method processType
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
Function processType
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
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 collectRates
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
Varien_Profiler::start($this->_name . '_collect_rate');
if (!$this->getType()) {
- Read upRead up
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
The method collectRates uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$quote = $this->getQuote();
$cartItems = $quote->getAllVisibleItems();
Mage::helper($this->_name)->addLog('Found ' . count($cartItems) . ' items in quote');
- Read upRead up
- Exclude checks
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
The class Mygento_Yandexdelivery_Model_Shipping is not named in CamelCase. Open
class Mygento_Yandexdelivery_Model_Shipping extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface
{
protected $_name = 'yandexdelivery';
protected $_isFixed = false;
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
The property $_isFixed is not named in camelCase. Open
class Mygento_Yandexdelivery_Model_Shipping extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface
{
protected $_name = 'yandexdelivery';
protected $_isFixed = false;
- Read upRead up
- Exclude checks
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 $_name is not named in camelCase. Open
class Mygento_Yandexdelivery_Model_Shipping extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface
{
protected $_name = 'yandexdelivery';
protected $_isFixed = false;
- Read upRead up
- Exclude checks
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 variable $processed_dimensions is not named in camelCase. Open
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
Varien_Profiler::start($this->_name . '_collect_rate');
if (!$this->getType()) {
- Read upRead up
- Exclude checks
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 $carrier_offer is not named in camelCase. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
- Exclude checks
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 $carrier_offer is not named in camelCase. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
- Exclude checks
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 $carrier_offer is not named in camelCase. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
- Exclude checks
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 collectRates(Mage_Shipping_Model_Rate_Request $request)
{
Varien_Profiler::start($this->_name . '_collect_rate');
if (!$this->getType()) {
- Read upRead up
- Exclude checks
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 $carrier_offer is not named in camelCase. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
- Exclude checks
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 $carrier_offer is not named in camelCase. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
- Exclude checks
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 $carrier_offer is not named in camelCase. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
- Exclude checks
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 $carrier_offer is not named in camelCase. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
- Exclude checks
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 $carrier_offer is not named in camelCase. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
- Exclude checks
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 collectRates(Mage_Shipping_Model_Rate_Request $request)
{
Varien_Profiler::start($this->_name . '_collect_rate');
if (!$this->getType()) {
- Read upRead up
- Exclude checks
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 $carrier_offer is not named in camelCase. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
- Exclude checks
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 $carrier_offer is not named in camelCase. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
- Exclude checks
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 $carrier_offer is not named in camelCase. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
- Exclude checks
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 $carrier_offer is not named in camelCase. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
- Exclude checks
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 $processed_dimensions is not named in camelCase. Open
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
Varien_Profiler::start($this->_name . '_collect_rate');
if (!$this->getType()) {
- Read upRead up
- Exclude checks
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 $processed_dimensions is not named in camelCase. Open
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
Varien_Profiler::start($this->_name . '_collect_rate');
if (!$this->getType()) {
- Read upRead up
- Exclude checks
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 $carrier_offer is not named in camelCase. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
- Exclude checks
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 $carrier_offer is not named in camelCase. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
- Exclude checks
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 collectRates(Mage_Shipping_Model_Rate_Request $request)
{
Varien_Profiler::start($this->_name . '_collect_rate');
if (!$this->getType()) {
- Read upRead up
- Exclude checks
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 $carrier_offer is not named in camelCase. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
- Exclude checks
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 $carrier_offer is not named in camelCase. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
- Exclude checks
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 $carrier_offer is not named in camelCase. Open
private function processType($response, $type, $request, $result)
{
foreach ($response->data as $carrier_offer) {
$price = $request->getFreeShipping() ? 0 : $carrier_offer->cost;
- Read upRead up
- Exclude checks
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();
}
}