Aerendir/bundle-features

View on GitHub

Showing 56 of 56 total issues

Function findDifferences has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    private function findDifferences(SubscribedFeaturesCollection $newFeatures)
    {
        // Get the features from the cloned subscription
        $oldFeatures = $this->oldSubscription->getFeatures();

Severity: Minor
Found in src/Manager/FeaturesManager.php - About 5 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

File FeaturesManager.php has 396 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

/*
Severity: Minor
Found in src/Manager/FeaturesManager.php - About 5 hrs to fix

    File Configuration.php has 375 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    declare(strict_types=1);
    
    /*
    Severity: Minor
    Found in src/DependencyInjection/Configuration.php - About 5 hrs to fix

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

                      if ($(this).is(':checked')) {
                          grossInstantAmount += $(this).data('gross-instant-amount');
                          netInstantAmount += $(this).data('net-instant-amount');
                      } else {
                          grossInstantAmount -= $(this).data('gross-instant-amount');
      Severity: Major
      Found in src/Resources/public/js/Cart.js and 1 other location - About 4 hrs to fix
      src/Resources/public/js/Cart.js on lines 51..62

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

      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

                  if ($(this).is(':checked')) {
                      grossAmount += $(this).data('gross-amount');
                      netAmount += $(this).data('net-amount');
                  } else {
                      grossAmount -= $(this).data('gross-amount');
      Severity: Major
      Found in src/Resources/public/js/Cart.js and 1 other location - About 4 hrs to fix
      src/Resources/public/js/Cart.js on lines 34..45

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

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

          public function getConfigTreeBuilder(): TreeBuilder
          {
              $treeBuilder = new TreeBuilder('shq_features');
              $rootNode    = $treeBuilder->getRootNode();
      
      
      Severity: Major
      Found in src/DependencyInjection/Configuration.php - About 3 hrs to fix

        Subscription has 29 functions (exceeds 20 allowed). Consider refactoring.
        Open

        abstract class Subscription implements SubscriptionInterface
        {
            /** @ORM\Column(name="currency", type="currency", nullable=true) */
            private ?Currency $currency = null;
        
        
        Severity: Minor
        Found in src/Model/Subscription.php - About 3 hrs to fix

          Function isFree has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              public function isFree(): bool
              {
                  if (empty($this->netPrices) && empty($this->grossPrices)) {
                      return true;
                  }
          Severity: Minor
          Found in src/Model/Feature/Property/CanBeFreeProperty.php - About 3 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

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

          final class Configuration implements ConfigurationInterface
          {
              /** @var string[] The allowed drawers */
              private const ALLOWED_DRAWERS = ['plain_text'];
          
          
          Severity: Minor
          Found in src/DependencyInjection/Configuration.php - About 3 hrs to fix

            Method findDifferences has 70 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function findDifferences(SubscribedFeaturesCollection $newFeatures)
                {
                    // Get the features from the cloned subscription
                    $oldFeatures = $this->oldSubscription->getFeatures();
            
            
            Severity: Major
            Found in src/Manager/FeaturesManager.php - About 2 hrs to fix

              Invoice has 22 functions (exceeds 20 allowed). Consider refactoring.
              Open

              abstract class Invoice implements InvoiceInterface
              {
                  private const SECTION_DEFAULT = '_default';
              
                  /** @ORM\Column(name="currency", type="currency") */
              Severity: Minor
              Found in src/Model/Invoice.php - About 2 hrs to fix

                Function setPrices has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function setPrices(array $settingPrices, string $pricesType)
                    {
                        $this->pricesType = $pricesType;
                        $priceProperty    = FeatureInterface::PRICE_NET === $this->pricesType ? 'netPrices' : 'grossPrices';
                        $setPrices        = $this->$priceProperty;
                Severity: Minor
                Found in src/Model/Feature/Property/HasRecurringPricesProperty.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

                Function calculateTotalChargesForNewFeatures has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function calculateTotalChargesForNewFeatures(SubscribedFeaturesCollection $newFeatures): MoneyInterface
                    {
                        $totalCharges = new Money([MoneyInterface::BASE_AMOUNT => 0, MoneyInterface::CURRENCY => $this->getSubscription()->getCurrency()]);
                
                        // Calculate the added and removed Boolean features and the changed packages in Countable features
                Severity: Minor
                Found in src/Manager/FeaturesManager.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

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

                    private function recalculateTotal()
                    {
                        $this->grossTotal = new Money([MoneyInterface::BASE_AMOUNT => 0, MoneyInterface::CURRENCY => $this->getCurrency()]);
                        $this->netTotal   = new Money([MoneyInterface::BASE_AMOUNT => 0, MoneyInterface::CURRENCY => $this->getCurrency()]);
                
                
                Severity: Major
                Found in src/Model/Invoice.php and 1 other location - About 2 hrs to fix
                src/Model/InvoiceSection.php on lines 173..183

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

                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

                    private function recalculateTotal(): void
                    {
                        $this->grossTotal = new Money([MoneyInterface::BASE_AMOUNT => 0, MoneyInterface::CURRENCY => $this->getCurrency()]);
                        $this->netTotal   = new Money([MoneyInterface::BASE_AMOUNT => 0, MoneyInterface::CURRENCY => $this->getCurrency()]);
                
                
                Severity: Major
                Found in src/Model/InvoiceSection.php and 1 other location - About 2 hrs to fix
                src/Model/Invoice.php on lines 258..268

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

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

                    private function buildInvoiceTextTable(InvoiceSection $section): string
                    {
                        $tableData = [
                            [
                                'quantity'    => \mb_strtoupper($this->getTranslator()->trans('shq_features.invoice.quantity.label', [], 'Invoice')),
                Severity: Minor
                Found in src/InvoiceDrawer/PlainTextDrawer.php - About 1 hr to fix

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

                      private function refreshCountableFeatures(): void
                      {
                          $refreshInterval = SubscriptionInterface::MONTHLY;
                          /** @var SubscribedCountableFeature $feature */
                          foreach ($this->getSubscription()->getFeatures()->getValues() as $feature) {
                  Severity: Minor
                  Found in src/Manager/FeaturesManager.php - About 1 hr to fix

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

                            switch (\gettype($id)) {
                                case 'string':
                                case 'integer':
                                    if ($this->hasLine($id)) {
                                        throw new \LogicException(sprintf('The section "%s" already exists. You cannot add it again', $id));
                    Severity: Major
                    Found in src/Model/InvoiceSection.php and 1 other location - About 1 hr to fix
                    src/Model/Invoice.php on lines 138..154

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

                    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

                            switch (\gettype($id)) {
                                case 'string':
                                case 'integer':
                                    if ($this->hasSection($id)) {
                                        throw new \LogicException(sprintf('The section "%s" already exists. You cannot add it again', $id));
                    Severity: Major
                    Found in src/Model/Invoice.php and 1 other location - About 1 hr to fix
                    src/Model/InvoiceSection.php on lines 74..90

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

                    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

                    Function __construct has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function __construct(string $kind, ?array $elements = [])
                        {
                            if (false === \in_array($kind, [ConfiguredFeaturesCollection::KIND, SubscribedFeaturesCollection::KIND])) {
                                throw new \InvalidArgumentException(sprintf('Features kind can be only "configured" or "subscribed". You passed "%s".', $kind));
                            }
                    Severity: Minor
                    Found in src/Model/Feature/AbstractFeaturesCollection.php - About 1 hr 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

                    Severity
                    Category
                    Status
                    Source
                    Language