Aerendir/bundle-features

View on GitHub

Showing 42 of 56 total issues

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

          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

          Function processPackages has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              private function processPackages(array $packs, $subscriptionType): array
              {
                  $subscriptionHasFreePackage = false;
                  foreach ($packs as $numOfUnits => $prices) {
                      switch ($subscriptionType) {
          Severity: Minor
          Found in src/DependencyInjection/Configuration.php - About 45 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

          Method createFeaturesService has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              private function createFeaturesService(string $name, array $setConfig, ContainerBuilder $containerBuilder, Definition $invoicesManagerDefinition, Reference $formFactoryReference): void
          Severity: Minor
          Found in src/DependencyInjection/SHQFeaturesExtension.php - About 35 mins to fix

            Method createInvoicesService has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                private function createInvoicesService(string $name, array $setConfig, ContainerBuilder $containerBuilder, array $drawers, Definition $arrayWriterDefinition): Definition
            Severity: Minor
            Found in src/DependencyInjection/SHQFeaturesExtension.php - About 35 mins to fix

              Function populateSection has a Cognitive Complexity of 7 (exceeds 5 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 35 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 updateUntilDates has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function updateUntilDates(): void
                  {
                      $validUntil = $this->getSubscription()->getNextRenewOn();
              
                      /** @var array $feature */
              Severity: Minor
              Found in src/Manager/FeaturesManager.php - About 35 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

              Avoid too many return statements within this method.
              Open

                      return $treeBuilder;
              Severity: Major
              Found in src/DependencyInjection/Configuration.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                    return $this->processTree($tree);
                Severity: Major
                Found in src/DependencyInjection/Configuration.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return $diff->y >= 1;
                  Severity: Major
                  Found in src/Model/Feature/Subscribed/SubscribedCountableFeature.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return true;
                    Severity: Major
                    Found in src/Model/Feature/Subscribed/SubscribedCountableFeature.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                          return $this->validateTree($tree);
                      Severity: Major
                      Found in src/DependencyInjection/Configuration.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return $diff->m >= 1;
                        Severity: Major
                        Found in src/Model/Feature/Subscribed/SubscribedCountableFeature.php - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language