components-web-app/api-components-bundle

View on GitHub

Showing 108 of 108 total issues

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

              Method confirmNewEmailAddress has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function confirmNewEmailAddress(string $username, string $email, string $token): void
                  {
                      if ('' === $email) {
                          throw new InvalidArgumentException('User not found');
                      }
              Severity: Minor
              Found in src/Helper/User/EmailAddressManager.php - About 1 hr to fix

                Function getPageDataTotal has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function getPageDataTotal(ComponentInterface $component): int
                    {
                        /** @var \Generator $pageDataLocations */
                        $pageDataLocations = $this->pageDataProvider->findPageDataComponentMetadata($component);
                        $pageDataCount = 0;
                Severity: Minor
                Found in src/Metadata/Factory/ComponentUsageMetadataFactory.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 voteOnAttribute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function voteOnAttribute(string $attribute, $routable, TokenInterface $token): bool
                    {
                        if (!$this->securityStr) {
                            return true;
                        }
                Severity: Minor
                Found in src/Security/Voter/RoutableVoter.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 onPreWrite has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function onPreWrite(ViewEvent $event): void
                    {
                        $request = $event->getRequest();
                        $data = $request->attributes->get('data');
                        $resourceClass = $request->attributes->get('_api_resource_class');
                Severity: Minor
                Found in src/EventListener/Api/OrphanedComponentEventListener.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 getFileResponse has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getFileResponse(object $object, string $property, bool $forceDownload = false): Response
                    {
                        try {
                            $reflectionProperty = new \ReflectionProperty($object, $property);
                        } catch (\ReflectionException $exception) {
                Severity: Minor
                Found in src/Helper/Uploadable/UploadableFileManager.php - About 1 hr to fix

                  Method create has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function create(RoutableInterface $object, ?Route $route = null): Route
                      {
                          $entityManager = $this->registry->getManagerForClass($className = $object::class);
                          if (!$entityManager) {
                              throw new InvalidArgumentException(sprintf('Could not find entity manager for %s', $className));
                  Severity: Minor
                  Found in src/Helper/Route/RouteGenerator.php - About 1 hr to fix

                    Method createFromRequest has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function createFromRequest(Request $request, bool $normalization, ?array $extractedAttributes = null): array
                        {
                            $context = $this->decorated->createFromRequest($request, $normalization, $extractedAttributes);
                    
                            if (
                    Severity: Minor
                    Found in src/Serializer/ContextBuilder/CwaResourceContextBuilder.php - About 1 hr to fix

                      Method normalize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function normalize($object, $format = null, array $context = []): float|array|\ArrayObject|bool|int|string|null
                          {
                              $context[self::ALREADY_CALLED] = true;
                      
                              $finalRoute = $object;
                      Severity: Minor
                      Found in src/Serializer/Normalizer/RouteNormalizer.php - About 1 hr to fix

                        Method validate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function validate($componentPosition, Constraint $constraint): void
                            {
                                $collection = $componentPosition->componentGroup;
                                if (!$collection) {
                                    return;
                        Severity: Minor
                        Found in src/Validator/Constraints/ComponentPositionValidator.php - About 1 hr to fix

                          Method applyToItem has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function applyToItem(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, array $identifiers, ?Operation $operation = null, array $context = []): void
                              {
                                  $configuration = $this->getConfiguration($resourceClass);
                          
                                  if (!$configuration || !$this->requestStack->getCurrentRequest()) {
                          Severity: Minor
                          Found in src/Doctrine/Extension/ORM/PublishableExtension.php - About 1 hr to fix

                            Method __construct has 8 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                    ApiResourceRouteFinder $resourceRouteFinder,
                                    ProviderInterface $provider,
                                    RequestStack $requestStack,
                                    SerializerContextBuilderInterface $serializerContextBuilder,
                                    NormalizerInterface $itemNormalizer,
                            Severity: Major
                            Found in src/EventListener/Api/CollectionApiEventListener.php - About 1 hr to fix

                              Function prefixRoute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  private function prefixRoute(string $resourceClass, array $routePrefixParts, ResourceMetadataCollection $resourceMetadata): ResourceMetadataCollection
                                  {
                                      $resources = [];
                                      /** @var ApiResource $resourceMetadatum */
                                      foreach ($resourceMetadata as $i => $resourceMetadatum) {

                              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 onPostRespond has a Cognitive Complexity of 9 (exceeds 5 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 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

                              Method filterProperty has 7 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
                              Severity: Major
                              Found in src/Filter/OrSearchFilter.php - About 50 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language