oc-shopaholic/oc-shopaholic-plugin

View on GitHub
classes/item/OfferItem.php

Summary

Maintainability
C
1 day
Test Coverage

OfferItem has 26 functions (exceeds 20 allowed). Consider refactoring.
Open

class OfferItem extends ElementItem
{
    use PriceHelperTrait;

    const MODEL_CLASS = Offer::class;
Severity: Minor
Found in classes/item/OfferItem.php - About 3 hrs to fix

    Class "OfferItem" has 26 methods, which is greater than 20 authorized. Split it into smaller classes.
    Open

    class OfferItem extends ElementItem
    Severity: Major
    Found in classes/item/OfferItem.php by sonar-php

    A class that grows too much tends to aggregate too many responsibilities and inevitably becomes harder to understand and therefore to maintain. Above a specific threshold, it is strongly advised to refactor the class into smaller ones which focus on well defined topics.

    Rename "$iActivePriceType" which has the same name as the field declared at line 146.
    Open

            $iActivePriceType = $this->getActivePriceType();
    Severity: Major
    Found in classes/item/OfferItem.php by sonar-php

    Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

    Noncompliant Code Example

    class Foo {
      public $myField;
    
      public function doSomething() {
        $myField = 0;
        ...
      }
    }
    

    See

    Rename "$iActivePriceType" which has the same name as the field declared at line 146.
    Open

            $iActivePriceType = $this->getActivePriceType();
    Severity: Major
    Found in classes/item/OfferItem.php by sonar-php

    Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

    Noncompliant Code Example

    class Foo {
      public $myField;
    
      public function doSomething() {
        $myField = 0;
        ...
      }
    }
    

    See

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

        protected function getOldPriceValueAttribute()
        {
            $iActivePriceType = $this->getActivePriceType();
            if (empty($iActivePriceType)) {
                $fPrice = $this->getAttribute('old_price_value');
    Severity: Major
    Found in classes/item/OfferItem.php and 1 other location - About 2 hrs to fix
    classes/item/OfferItem.php on lines 212..224

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

    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

        protected function getPriceValueAttribute()
        {
            $iActivePriceType = $this->getActivePriceType();
            if (empty($iActivePriceType)) {
                $fPrice = $this->getAttribute('price_value');
    Severity: Major
    Found in classes/item/OfferItem.php and 1 other location - About 2 hrs to fix
    classes/item/OfferItem.php on lines 230..242

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

    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

        protected function getCurrencyAttribute()
        {
            if (empty($this->sActiveCurrency)) {
                return CurrencyHelper::instance()->getActiveCurrencySymbol();
            }
    Severity: Major
    Found in classes/item/OfferItem.php and 1 other location - About 1 hr to fix
    classes/item/OfferItem.php on lines 283..293

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

        protected function getCurrencyCodeAttribute()
        {
            if (empty($this->sActiveCurrency)) {
                return CurrencyHelper::instance()->getActiveCurrencyCode();
            }
    Severity: Major
    Found in classes/item/OfferItem.php and 1 other location - About 1 hr to fix
    classes/item/OfferItem.php on lines 267..277

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

        public $arRelationList = [
            'product'         => [
                'class' => ProductItem::class,
                'field' => 'product_id',
            ],
    Severity: Minor
    Found in classes/item/OfferItem.php and 1 other location - About 30 mins to fix
    classes/item/CategoryItem.php on lines 72..81

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

    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 "old_price_without_tax_value" is not in valid camel caps format
    Open

            $fPrice = PriceHelper::round($this->old_price_with_tax_value - $this->old_price_without_tax_value);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = TaxHelper::instance()->getPriceWithoutTax($this->discount_price_value, $this->tax_percent);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = $this->price_value;
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = TaxHelper::instance()->getPriceWithTax($this->old_price_value, $this->tax_percent);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = TaxHelper::instance()->getPriceWithTax($this->price_value, $this->tax_percent);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = PriceHelper::round($this->discount_price_with_tax_value - $this->discount_price_without_tax_value);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

                $bSkipTax = !$obTaxItem->is_global
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = TaxHelper::instance()->getPriceWithTax($this->discount_price_value, $this->tax_percent);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = TaxHelper::instance()->getPriceWithoutTax($this->price_value, $this->tax_percent);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = PriceHelper::round($this->price_with_tax_value - $this->price_without_tax_value);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = TaxHelper::instance()->getPriceWithoutTax($this->discount_price_value, $this->tax_percent);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = TaxHelper::instance()->getPriceWithoutTax($this->price_value, $this->tax_percent);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

                $fPrice = array_get($this->price_list, $iActivePriceType.'.old_price');
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

                $fPrice = array_get($this->price_list, $iActivePriceType.'.price');
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fOldPrice = $this->old_price_value;
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = PriceHelper::round($this->old_price_with_tax_value - $this->old_price_without_tax_value);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = TaxHelper::instance()->getPriceWithTax($this->price_value, $this->tax_percent);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

                $fTaxPercent = TaxHelper::instance()->getTaxPercent($this->tax_list);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = PriceHelper::round($this->price_with_tax_value - $this->price_without_tax_value);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = TaxHelper::instance()->getPriceWithoutTax($this->old_price_value, $this->tax_percent);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = TaxHelper::instance()->getPriceWithTax($this->discount_price_value, $this->tax_percent);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = TaxHelper::instance()->getPriceWithoutTax($this->old_price_value, $this->tax_percent);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = TaxHelper::instance()->getPriceWithTax($this->old_price_value, $this->tax_percent);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $iMeasureID = $this->measure_of_unit_id;
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

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

            $fPrice = PriceHelper::round($this->discount_price_with_tax_value - $this->discount_price_without_tax_value);
    Severity: Minor
    Found in classes/item/OfferItem.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status