components-web-app/api-components-bundle

View on GitHub

Showing 108 of 108 total issues

File services.php has 1301 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/*
 * This file is part of the Silverback API Components Bundle Project
 *
Severity: Major
Found in src/Resources/config/services.php - About 3 days to fix

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

    <?php
    
    /*
     * This file is part of the Silverback API Components Bundle Project
     *
    Severity: Major
    Found in src/Serializer/ContextBuilder/TimestampedContextBuilder.php and 1 other location - About 7 hrs to fix
    src/Serializer/ContextBuilder/UploadableContextBuilder.php on lines 1..49

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

    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

    <?php
    
    /*
     * This file is part of the Silverback API Components Bundle Project
     *
    Severity: Major
    Found in src/Serializer/ContextBuilder/UploadableContextBuilder.php and 1 other location - About 7 hrs to fix
    src/Serializer/ContextBuilder/TimestampedContextBuilder.php on lines 1..49

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

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

        public function calculateSortValue(ComponentPosition $componentPosition, ?int $originalSortValue): void
        {
            $sortCollection = $componentPosition->getSortCollection();
            $sortValueSet = null !== $componentPosition->sortValue;
            if (!$sortCollection) {
    Severity: Minor
    Found in src/Helper/ComponentPosition/ComponentPositionSortValueHelper.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

    AbstractUser has 36 functions (exceeds 20 allowed). Consider refactoring.
    Open

    #[Silverback\Timestamped]
    #[UniqueEntity(fields: ['username'], message: 'Sorry, that user already exists in the database.', errorPath: 'username')]
    #[UniqueEntity(fields: ['emailAddress'], message: 'Sorry, that email address already exists in the database.', errorPath: 'emailAddress')]
    #[AcbAssert\NewEmailAddress(groups: ['User:emailAddress', 'Default'])]
    abstract class AbstractUser implements SymfonyUserInterface, PasswordAuthenticatedUserInterface, JWTUserInterface
    Severity: Minor
    Found in src/Entity/User/AbstractUser.php - About 4 hrs to fix

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

      <?php
      
      /*
       * This file is part of the Silverback API Components Bundle Project
       *
      Severity: Major
      Found in src/Factory/User/Mailer/PasswordResetEmailFactory.php and 1 other location - About 4 hrs to fix
      src/Factory/User/Mailer/VerifyEmailFactory.php on lines 1..60

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

      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

      <?php
      
      /*
       * This file is part of the Silverback API Components Bundle Project
       *
      Severity: Major
      Found in src/Factory/User/Mailer/VerifyEmailFactory.php and 1 other location - About 4 hrs to fix
      src/Factory/User/Mailer/PasswordResetEmailFactory.php on lines 1..60

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

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

          private function addUserNode(ArrayNodeDefinition $rootNode): void
          {
              $rootNode
                  ->children()
                      ->arrayNode('user')
      Severity: Major
      Found in src/DependencyInjection/Configuration.php - About 3 hrs to fix

        Method load has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function load(array $configs, ContainerBuilder $container): void
            {
                $configuration = new Configuration();
                $config = $this->processConfiguration($configuration, $configs);
        
        
        Severity: Major
        Found in src/DependencyInjection/SilverbackApiComponentsExtension.php - About 2 hrs to fix

          File AbstractUser.php has 277 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          /*
           * This file is part of the Silverback API Components Bundle Project
           *
          Severity: Minor
          Found in src/Entity/User/AbstractUser.php - About 2 hrs to fix

            File SilverbackApiComponentsExtension.php has 273 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            /*
             * This file is part of the Silverback API Components Bundle Project
             *
            Severity: Minor
            Found in src/DependencyInjection/SilverbackApiComponentsExtension.php - About 2 hrs to fix

              Method filterProperty has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
                  {
                      if (
                          null === $value
                          || !$this->isPropertyEnabled($property, $resourceClass)
              Severity: Major
              Found in src/Filter/OrSearchFilter.php - About 2 hrs to fix

                Method calculateSortValue has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function calculateSortValue(ComponentPosition $componentPosition, ?int $originalSortValue): void
                    {
                        $sortCollection = $componentPosition->getSortCollection();
                        $sortValueSet = null !== $componentPosition->sortValue;
                        if (!$sortCollection) {
                Severity: Major
                Found in src/Helper/ComponentPosition/ComponentPositionSortValueHelper.php - About 2 hrs to fix

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

                      public function create(string $resourceClass): ResourceMetadataCollection
                      {
                          $resourceMetadata = $this->decorated->create($resourceClass);
                          $interfaces = class_implements($resourceClass);
                          if (!\in_array(ComponentInterface::class, $interfaces, true)) {

                  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

                  ResourceMetadata has 21 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class ResourceMetadata implements ResourceMetadataInterface
                  {
                      // for page data
                      #[Groups('cwa_resource:metadata')]
                      private ?PageDataMetadata $pageDataMetadata = null;
                  Severity: Minor
                  Found in src/Serializer/ResourceMetadata/ResourceMetadata.php - About 2 hrs to fix

                    Function getResourceIrisFromArray has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function getResourceIrisFromArray(array $resource, array $iris = []): array
                        {
                            $resourceId = $resource['@id'] ?? null;
                            if (
                                $resourceId
                    Severity: Minor
                    Found in src/Serializer/Normalizer/RouteNormalizer.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 prependApiPlatformConfig has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function prependApiPlatformConfig(ContainerBuilder $container, array $config): void
                        {
                            $srcBase = __DIR__ . '/..';
                            $mappingPaths = [$srcBase . '/Entity/Core'];
                            $this->appendMappingPaths($mappingPaths, $srcBase, 'uploadable');
                    Severity: Minor
                    Found in src/DependencyInjection/SilverbackApiComponentsExtension.php - About 1 hr to fix

                      Method transform has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function transform(Collection $object): Collection
                          {
                              $parameters = $this->resourceRouteFinder->findByIri($object->getResourceIri());
                              $attributes = AttributesExtractor::extractAttributes($parameters);
                              $request = $this->requestStack->getMainRequest();
                      Severity: Minor
                      Found in src/EventListener/Api/CollectionApiEventListener.php - About 1 hr to fix

                        Method loadClassMetadata has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void
                            {
                                /** @var ClassMetadataInfo $metadata */
                                $metadata = $eventArgs->getClassMetadata();
                                if (!$this->publishableStatusChecker->isConfigured($metadata->getName())) {
                        Severity: Minor
                        Found in src/EventListener/Doctrine/PublishableListener.php - About 1 hr to fix

                          Method buildForm has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function buildForm(FormBuilderInterface $builder, array $options): void
                              {
                                  $builder
                                      ->add(
                                          'username',
                          Severity: Minor
                          Found in src/Form/Type/User/UserRegisterType.php - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language