oc-shopaholic/oc-shopaholic-plugin

View on GitHub
classes/item/TaxItem.php

Summary

Maintainability
A
3 hrs
Test Coverage

Reduce the number of returns of this function 4, down to the maximum allowed 3.
Open

    public function isAvailableForCategory($obCategoryItem) : bool
Severity: Major
Found in classes/item/TaxItem.php by sonar-php

Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

Noncompliant Code Example

With the default threshold of 3:

function myFunction(){ // Noncompliant as there are 4 return statements
  if (condition1) {
    return true;
  } else {
    if (condition2) {
      return false;
    } else {
      return true;
    }
  }
  return false;
}

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

    public function isAvailableForCountry($obCountry) : bool
    {
        $arCountryIDList = (array) $this->country_id_list;

        $bResult = !empty($arCountryIDList) && !empty($obCountry) && in_array($obCountry->id, $arCountryIDList);
Severity: Major
Found in classes/item/TaxItem.php and 2 other locations - About 1 hr to fix
classes/item/TaxItem.php on lines 61..68
classes/item/TaxItem.php on lines 89..96

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 57.

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 3 locations. Consider refactoring.
Open

    public function isAvailableForProduct($obProductItem) : bool
    {
        $arProductIDList = (array) $this->product_id_list;

        $bResult = !empty($arProductIDList) && !empty($obProductItem) && in_array($obProductItem->id, $arProductIDList);
Severity: Major
Found in classes/item/TaxItem.php and 2 other locations - About 1 hr to fix
classes/item/TaxItem.php on lines 75..82
classes/item/TaxItem.php on lines 89..96

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 57.

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 3 locations. Consider refactoring.
Open

    public function isAvailableForState($obState) : bool
    {
        $arStateIDList = (array) $this->state_id_list;

        $bResult = !empty($arStateIDList) && !empty($obState) && in_array($obState->id, $arStateIDList);
Severity: Major
Found in classes/item/TaxItem.php and 2 other locations - About 1 hr to fix
classes/item/TaxItem.php on lines 61..68
classes/item/TaxItem.php on lines 75..82

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 57.

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

Variable "country_id_list" is not in valid camel caps format
Open

        $arCountryIDList = (array) $this->country_id_list;
Severity: Minor
Found in classes/item/TaxItem.php by phpcodesniffer

Variable "state_id_list" is not in valid camel caps format
Open

        $arStateIDList = (array) $this->state_id_list;
Severity: Minor
Found in classes/item/TaxItem.php by phpcodesniffer

Variable "product_id_list" is not in valid camel caps format
Open

        $arProductIDList = (array) $this->product_id_list;
Severity: Minor
Found in classes/item/TaxItem.php by phpcodesniffer

Variable "category_id_list" is not in valid camel caps format
Open

        $arCategoryIDList = (array) $this->category_id_list;
Severity: Minor
Found in classes/item/TaxItem.php by phpcodesniffer

There are no issues that match your filters.

Category
Status