Aerendir/bundle-features

View on GitHub

Showing 42 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

      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

                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

                    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

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

                        private function validatePackages(string $set, string $feature, array $packs, string $subscriptionType): void
                        {
                            // If empty, may be because it doesn't exist and the TreeBuilder created it as an empty array, else...
                            if (false === empty($packs)) {
                                // ... It contains packages: validate the number of units and their prices
                    Severity: Minor
                    Found in src/DependencyInjection/Configuration.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

                    Function refreshCountableFeatures has a Cognitive Complexity of 12 (exceeds 5 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

                    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 buildPopulatingFeatures has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function buildPopulatingFeatures(?array $addedFeatures): array
                        {
                            $populatingFeatures = [];
                    
                            // If we $added features is not null, then we have to add only them to the Invoice section as the invoice is
                    Severity: Minor
                    Found in src/Manager/InvoicesManager.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

                    Method populateSection has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function populateSection(InvoiceSection $section, array $addedFeatures = null): void
                        {
                            /** @var SubscribedBooleanFeature $feature */
                            foreach ($this->buildPopulatingFeatures($addedFeatures) as $feature) {
                                $grossPrice = null;
                    Severity: Minor
                    Found in src/Manager/InvoicesManager.php - About 1 hr to fix

                      Method calculateTotalChargesForNewFeatures has 30 lines of code (exceeds 25 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 1 hr to fix

                        Method draw has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function draw(InvoiceInterface $invoice): array
                            {
                                $detailsTables = [];
                                foreach ($invoice->getSections() as $sectionId => $section) {
                                    $detailsTables[$sectionId] = $this->buildInvoiceTextTable($section);
                        Severity: Minor
                        Found in src/InvoiceDrawer/PlainTextDrawer.php - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language