Aerendir/bundle-features

View on GitHub

Showing 56 of 56 total issues

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

        Method buildDefaultSubscriptionFeatures has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function buildDefaultSubscriptionFeatures(string $subscriptionInterval): SubscribedFeaturesCollection
            {
                $activeUntil = Subscription::calculateActiveUntil($subscriptionInterval);
                $features    = [];
        
        
        Severity: Minor
        Found in src/Manager/FeaturesManager.php - About 1 hr to fix

          Function calculateSubscriptionAmount has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              private function calculateSubscriptionAmount(): MoneyInterface
              {
                  $total = new Money([MoneyInterface::BASE_AMOUNT => 0, MoneyInterface::CURRENCY => $this->getSubscription()->getCurrency()]);
          
                  /** @var FeatureInterface $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 setTax has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              public function setTax(float $rate, string $name): HasRecurringPricesInterface
              {
                  $this->taxName = $name;
                  $this->taxRate = $rate;
          
          
          Severity: Minor
          Found in src/Model/Feature/Property/HasRecurringPricesProperty.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 setPrices has 27 lines of code (exceeds 25 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 1 hr to fix

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

              Method __construct has 26 lines of code (exceeds 25 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

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

                            if (typeof deselected.data('already-subscribed') === 'undefined') {
                                grossInstantAmount -= deselected.data('gross-instant-amount');
                                netInstantAmount -= deselected.data('net-instant-amount');
                            }
                Severity: Major
                Found in src/Resources/public/js/Cart.js and 1 other location - About 1 hr to fix
                src/Resources/public/js/Cart.js on lines 119..122

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

                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 (typeof selected.data('already-subscribed') === 'undefined') {
                                grossInstantAmount += selected.data('gross-instant-amount');
                                netInstantAmount += selected.data('net-instant-amount');
                            }
                Severity: Major
                Found in src/Resources/public/js/Cart.js and 1 other location - About 1 hr to fix
                src/Resources/public/js/Cart.js on lines 113..116

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

                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 (isset($price[SubscriptionInterface::YEARLY])) {
                                    $amount = $price[SubscriptionInterface::YEARLY];
                                    if ( ! $amount instanceof MoneyInterface) {
                                        $amount = new Money([
                                            MoneyInterface::BASE_AMOUNT => $price[SubscriptionInterface::YEARLY], MoneyInterface::CURRENCY => $currency,
                Severity: Minor
                Found in src/Model/Feature/Property/HasRecurringPricesProperty.php and 1 other location - About 55 mins to fix
                src/Model/Feature/Property/HasRecurringPricesProperty.php on lines 217..226

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

                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 (isset($price[SubscriptionInterface::MONTHLY])) {
                                    $amount = $price[SubscriptionInterface::MONTHLY];
                                    if ( ! $amount instanceof MoneyInterface) {
                                        $amount = new Money([
                                            MoneyInterface::BASE_AMOUNT => $price[SubscriptionInterface::MONTHLY], MoneyInterface::CURRENCY => $currency,
                Severity: Minor
                Found in src/Model/Feature/Property/HasRecurringPricesProperty.php and 1 other location - About 55 mins to fix
                src/Model/Feature/Property/HasRecurringPricesProperty.php on lines 228..237

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

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

                    public function setPacks(array $packs, string $packClass): HasConfiguredPacksInterface
                    {
                        $pricesType = $packs[HasConfiguredPacksInterface::_PRICES_TYPES];
                        unset($packs[HasConfiguredPacksInterface::_PRICES_TYPES]);
                
                
                Severity: Minor
                Found in src/Model/Feature/Property/HasConfiguredPacksProperty.php - About 55 mins 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 updateSubscription has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function updateSubscription(SubscribedFeaturesCollection $newFeatures = null): void
                    {
                        if (null !== $newFeatures) {
                            /**
                             * Before all, update the features, setting the new enabled status or adding the feature if not already present.
                Severity: Minor
                Found in src/Manager/FeaturesManager.php - About 55 mins 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 refreshSubscription has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function refreshSubscription(): void
                    {
                        $subscription = $this->getSubscription();
                
                        /** @var FeatureInterface $feature */
                Severity: Minor
                Found in src/Manager/FeaturesManager.php - About 55 mins 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

                    public function __construct(string $name, array $details = [])
                    {
                        // Set the type
                        $details[self::FIELD_TYPE] = self::TYPE_BOOLEAN;
                
                
                Severity: Minor
                Found in src/Model/Feature/Configured/ConfiguredBooleanFeature.php and 1 other location - About 55 mins to fix
                src/Model/Feature/Subscribed/SubscribedBooleanFeature.php on lines 34..47

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

                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

                Severity
                Category
                Status
                Source
                Language