Aerendir/bundle-features

View on GitHub

Showing 56 of 56 total issues

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/Subscribed/SubscribedBooleanFeature.php and 1 other location - About 55 mins to fix
src/Model/Feature/Configured/ConfiguredBooleanFeature.php on lines 31..44

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

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

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

          private function getRechargeableFeaturePacksOptions(SubscriptionInterface $subscription, SubscribedRechargeableFeature $subscribedFeature): array
          {
              return [
                  self::KEY_REQUIRED => true,
                  self::KEY_ATTR     => [
      Severity: Minor
      Found in src/Form/Type/FeaturesType.php and 1 other location - About 35 mins to fix
      src/Form/Type/FeaturesType.php on lines 107..118

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

      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 getCountableFeaturePacksOptions(SubscriptionInterface $subscription, SubscribedCountableFeature $subscribedFeature): array
          {
              return [
                  self::KEY_REQUIRED => true,
                  self::KEY_ATTR     => [
      Severity: Minor
      Found in src/Form/Type/FeaturesType.php and 1 other location - About 35 mins to fix
      src/Form/Type/FeaturesType.php on lines 120..131

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

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

                  Function setTax has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function setTax(float $rate, string $name): HasUnatantumPricesInterface
                      {
                          $this->taxName = $name;
                          $this->taxRate = $rate;
                  
                  
                  Severity: Minor
                  Found in src/Model/Feature/Property/HasUnatantumPricesProperty.php - About 25 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 calculateInstantPrice has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function calculateInstantPrice(string $currency, string $subscriptionInterval, string $pricesType): MoneyInterface
                      {
                          if ( ! $this->subscription instanceof SubscriptionInterface) {
                              throw new \RuntimeException('Before you can get instant prices you have to set a Subscription with setSubscription().');
                          }
                  Severity: Minor
                  Found in src/Model/Feature/Property/HasRecurringPricesProperty.php - About 25 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

                  Severity
                  Category
                  Status
                  Source
                  Language