components-web-app/api-components-bundle

View on GitHub

Showing 100 of 108 total issues

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

      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

      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

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

              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

              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

                Method checkMergeDraftIntoPublished has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function checkMergeDraftIntoPublished(Request $request, object $data, bool $flushDatabase = false): object
                    {
                        if (!$this->publishableStatusChecker->isActivePublishedAt($data)) {
                            return $data;
                        }
                Severity: Minor
                Found in src/EventListener/Api/PublishableEventListener.php - About 1 hr to fix

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

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

                        public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
                        {
                            $reflectionClass = $classMetadata->getReflectionClass();
                            $attributes = $reflectionClass->getAttributes(Publishable::class);
                            if (!\count($attributes)) {
                    Severity: Minor
                    Found in src/Serializer/MappingLoader/PublishableLoader.php - About 1 hr to fix

                      Method configure has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function configure(): void
                          {
                              $this
                                  ->setDescription('Create a user.')
                                  ->setDefinition(
                      Severity: Minor
                      Found in src/Command/UserCreateCommand.php - About 1 hr to fix

                        Method persistFiles has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function persistFiles(object $object): void
                            {
                                $propertyAccessor = PropertyAccess::createPropertyAccessor();
                                $classMetadata = $this->getClassMetadata($object);
                        
                        
                        Severity: Minor
                        Found in src/Helper/Uploadable/UploadableFileManager.php - About 1 hr to fix

                          Method create has 29 lines of code (exceeds 25 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)) {
                            Severity
                            Category
                            Status
                            Source
                            Language