components-web-app/api-components-bundle

View on GitHub

Showing 108 of 108 total issues

Method __invoke has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function __invoke(object $data, string $property, Request $request, UploadableAttributeReader $annotationReader, UploadableFileManager $uploadableFileManager)
Severity: Minor
Found in src/Action/Uploadable/DownloadAction.php - About 35 mins to fix

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

            private MediaObjectFactory $mediaObjectFactory,
            private UploadableAttributeReader $annotationReader,
            private UploadableFileManager $uploadableFileManager,
            ManagerRegistry $registry,
            private ResourceMetadataProvider $resourceMetadataProvider
    Severity: Minor
    Found in src/Serializer/Normalizer/UploadableNormalizer.php - About 35 mins to fix

      Function mergeDraftIntoPublished has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private function mergeDraftIntoPublished(string $identifierFieldName, object $draftResource, object $publishedResource, bool $flushDatabase): void
          {
              $draftReflection = new \ReflectionClass($draftResource);
              $publishedReflection = new \ReflectionClass($publishedResource);
              $properties = $publishedReflection->getProperties();
      Severity: Minor
      Found in src/EventListener/Api/PublishableEventListener.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 getFilterQueries has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private function getFilterQueries(?array $filters, Expr $expr, QueryBuilder $queryBuilder): array
          {
              $filterQueries = [];
              if (null !== $filters) {
                  foreach ($filters as $filterIndex => $filter) {
      Severity: Minor
      Found in src/Repository/Core/FileInfoRepository.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 storeFilesMetadata has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function storeFilesMetadata(object $object): void
          {
              $configuredProperties = $this->annotationReader->getConfiguredProperties($object, true);
              $classMetadata = $this->getClassMetadata($object);
      
      
      Severity: Minor
      Found in src/Helper/Uploadable/UploadableFileManager.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 persistFiles has a Cognitive Complexity of 7 (exceeds 5 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 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 createFromRequest has a Cognitive Complexity of 7 (exceeds 5 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 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 convertVarToArray has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private function convertVarToArray($var): void
          {
              if (\in_array($var, self::ARRAY_OUTPUT_VARS, true)) {
                  /** @var iterable $choices */
                  $choices = $this->vars[$var];
      Severity: Minor
      Found in src/Model/Form/FormView.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 publish has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function publish(Update $update): string
          {
              if ($update->getData() && $data = json_decode($update->getData(), true, 512, \JSON_THROW_ON_ERROR)) {
                  try {
                      $resource = $this->iriConverter->getResourceFromIri($data['@id']);
      Severity: Minor
      Found in src/Mercure/PublishableAwareHub.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 applyToItem has a Cognitive Complexity of 7 (exceeds 5 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 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

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

      <?php
      
      /*
       * This file is part of the Silverback API Components Bundle Project
       *
      Severity: Minor
      Found in src/AttributeReader/PublishableAttributeReader.php and 1 other location - About 30 mins to fix
      src/AttributeReader/TimestampedAttributeReader.php on lines 1..32

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

      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: Minor
      Found in src/AttributeReader/TimestampedAttributeReader.php and 1 other location - About 30 mins to fix
      src/AttributeReader/PublishableAttributeReader.php on lines 1..35

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

      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

      Avoid too many return statements within this method.
      Open

                  return;
      Severity: Major
      Found in src/Filter/OrSearchFilter.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return;
        Severity: Major
        Found in src/Filter/OrSearchFilter.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return;
          Severity: Major
          Found in src/Helper/ComponentPosition/ComponentPositionSortValueHelper.php - About 30 mins to fix

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

                private function removeResources(OpenApi $openApi, array $resourceClassNames): void
                {
                    $shortNames = $this->getResourceClassShortNames($resourceClassNames);
                    $openApiPaths = $openApi->getPaths();
                    $paths = $openApiPaths->getPaths();
            Severity: Minor
            Found in src/OpenApi/OpenApiFactory.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 createFromRequest has a Cognitive Complexity of 6 (exceeds 5 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/PublishableContextBuilder.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 validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function validate($password, Constraint $constraint): void
                {
                    if (!$constraint instanceof UserPassword) {
                        throw new UnexpectedTypeException($constraint, UserPassword::class);
                    }
            Severity: Minor
            Found in src/Validator/Constraints/UserPasswordValidator.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 addWhereByStrategy has a Cognitive Complexity of 6 (exceeds 5 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 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 getUrlPrefix has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                private function getUrlPrefix(string $url, string $headerName): string
                {
                    $defaults = [
                        'host' => null,
                        'scheme' => null,
            Severity: Minor
            Found in src/Helper/RefererUrlResolver.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