components-web-app/api-components-bundle

View on GitHub

Showing 108 of 108 total issues

Function filterProperty has a Cognitive Complexity of 14 (exceeds 5 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: Minor
Found in src/Filter/OrSearchFilter.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 create has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function create(string $resourceClass): ResourceMetadataCollection
    {
        $resourceMetadata = $this->decorated->create($resourceClass);
        if (!$this->uploadableFileManager->isConfigured($resourceClass)) {
            return $resourceMetadata;

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 buildForm has 38 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/UserLoginType.php - About 1 hr to fix

    Method onPostRespond has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function onPostRespond(ResponseEvent $event): void
        {
            $request = $event->getRequest();
    
            $attributes = $this->getAttributes($request);
    Severity: Minor
    Found in src/EventListener/Api/PublishableEventListener.php - About 1 hr to fix

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

          public function buildForm(FormBuilderInterface $builder, array $options): void
          {
              /** @var UserInterface|null $user */
              $user = $builder->getEmptyData();
      
      
      Severity: Minor
      Found in src/Form/Type/User/ChangePasswordType.php - About 1 hr to fix

        Method createEmailMessage has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function createEmailMessage(array $context = []): ?TemplatedEmail
            {
                if (!$this->enabled) {
                    return null;
                }
        Severity: Minor
        Found in src/Factory/User/Mailer/AbstractUserEmailFactory.php - About 1 hr to fix

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

              public function denormalize($data, $type, $format = null, array $context = []): mixed
              {
                  $context[self::ALREADY_CALLED] = true;
          
                  foreach ($data as $fieldName => $value) {
          Severity: Minor
          Found in src/Serializer/Normalizer/UploadableNormalizer.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 create has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function create(string $resourceClass): ResourceMetadataCollection
              {
                  $resourceMetadata = $this->decorated->create($resourceClass);
          
                  $refl = new \ReflectionClass($resourceClass);

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

              public function create(string $resourceClass): ResourceMetadataCollection
              {
                  $resourceMetadata = $this->decorated->create($resourceClass);
                  if (!$this->uploadableFileManager->isConfigured($resourceClass)) {
                      return $resourceMetadata;

            Method __invoke has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function __invoke(?object $data, Request $request, UploadableFileManager $uploadableFileManager, PublishableStatusChecker $publishableStatusChecker)
                {
                    $contentType = $request->headers->get('CONTENT_TYPE');
                    if (null === $contentType) {
                        throw new UnsupportedMediaTypeHttpException('The "Content-Type" header must exist.');
            Severity: Minor
            Found in src/Action/Uploadable/UploadAction.php - About 1 hr to fix

              Method setMailerServiceArguments has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function setMailerServiceArguments(ContainerBuilder $container, array $config): void
                  {
                      $definition = $container->getDefinition(UserMailer::class);
                      $definition->setArgument(
                          '$context',
              Severity: Minor
              Found in src/DependencyInjection/SilverbackApiComponentsExtension.php - About 1 hr to fix

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

                    $services
                        ->set(UploadableEventListener::class)
                        ->args(
                            [
                                new Reference(UploadableAttributeReader::class),
                Severity: Major
                Found in src/Resources/config/services.php and 1 other location - About 1 hr to fix
                src/Resources/config/services.php on lines 1129..1138

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

                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

                    $services
                        ->set(UserEventListener::class)
                        ->args(
                            [
                                new Reference(UserMailer::class),
                Severity: Major
                Found in src/Resources/config/services.php and 1 other location - About 1 hr to fix
                src/Resources/config/services.php on lines 1025..1034

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

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

                    protected function addWhereByStrategy(string $strategy, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $alias, string $field, $value, bool $caseSensitive): void
                    {
                        $wrapCase = $this->createWrapCase($caseSensitive);
                        $valueParameter = $queryNameGenerator->generateParameterName($field);
                        switch ($strategy) {
                Severity: Minor
                Found in src/Filter/OrSearchFilter.php - About 1 hr to fix

                  Function loadClassMetadata has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
                      {
                          $reflectionClass = $classMetadata->getReflectionClass();
                          $reflectionClassName = $reflectionClass->getName();
                          if (
                  Severity: Minor
                  Found in src/Serializer/MappingLoader/CwaResourceLoader.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 transform has a Cognitive Complexity of 11 (exceeds 5 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

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

                      private function findGetCollectionOperation(string $resourceClass): ?HttpOperation
                      {
                          $metadata = $this->resourceMetadataCollectionFactory->create($resourceClass);
                          $it = $metadata->getIterator();
                          /** @var ApiResource $apiResource */
                  Severity: Minor
                  Found in src/EventListener/Api/CollectionApiEventListener.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 remove has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function remove(array $paths, array $filters): void
                      {
                          if (empty($paths) && empty($filters)) {
                              return;
                          }
                  Severity: Minor
                  Found in src/Imagine/FlysystemCacheResolver.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 __invoke has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function __invoke(?object $data, Request $request, UploadableFileManager $uploadableFileManager, PublishableStatusChecker $publishableStatusChecker)
                      {
                          $contentType = $request->headers->get('CONTENT_TYPE');
                          if (null === $contentType) {
                              throw new UnsupportedMediaTypeHttpException('The "Content-Type" header must exist.');
                  Severity: Minor
                  Found in src/Action/Uploadable/UploadAction.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 __invoke has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function __invoke(FormSuccessEvent $event): void
                      {
                          // This is not a sub-request because forms have greater permissions to create entitites with whatever properties wanted.
                  
                          if (
                  Severity: Minor
                  Found in src/EventListener/Form/EntityPersistFormListener.php - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language