ongr-io/ElasticsearchBundle

View on GitHub

Showing 31 of 31 total issues

IndexService has 42 functions (exceeds 20 allowed). Consider refactoring.
Open

class IndexService
{
    private $client;
    private $namespace;
    private $converter;
Severity: Minor
Found in Service/IndexService.php - About 5 hrs to fix

    File IndexService.php has 392 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /*
     * This file is part of the ONGR package.
     *
    Severity: Minor
    Found in Service/IndexService.php - About 5 hrs to fix

      Function getPropertyMetadata has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getPropertyMetadata(\ReflectionClass $class, bool $subClass = false): array
          {
              if ($class->isTrait() || (!$this->reader->getClassAnnotation($class, Index::class) && !$subClass)) {
                  return [];
              }
      Severity: Minor
      Found in Mapping/DocumentParser.php - About 3 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

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

          protected function denormalize(array $raw, string $namespace)
          {
              $metadata = $this->propertyMetadata[$namespace];
              $object = new $namespace();
      
      
      Severity: Minor
      Found in Mapping/Converter.php - About 3 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

      Method handleDirectoryMapping has 73 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function handleDirectoryMapping(ContainerBuilder $container, string $dir): void
          {
              /** @var DocumentParser $parser */
              $parser = $container->get(DocumentParser::class);
              $indexesOverride = $container->getParameter(Configuration::ONGR_INDEXES_OVERRIDE);
      Severity: Major
      Found in DependencyInjection/Compiler/MappingPass.php - About 2 hrs to fix

        Method execute has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function execute(InputInterface $input, OutputInterface $output)
            {
                $io = new SymfonyStyle($input, $output);
                $index = $this->getIndex($input->getOption(parent::INDEX_OPTION));
                $indexName = $aliasName = $index->getIndexName();
        Severity: Major
        Found in Command/IndexCreateCommand.php - About 2 hrs to fix

          File DocumentParser.php has 283 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          /*
           * This file is part of the ONGR package.
           *
          Severity: Minor
          Found in Mapping/DocumentParser.php - About 2 hrs to fix

            Function getClassMetadata has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                private function getClassMetadata(\ReflectionClass $class): array
                {
                    $mapping = [];
                    $objFields = null;
                    $arrayFields = null;
            Severity: Minor
            Found in Mapping/DocumentParser.php - About 2 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

            AbstractResultsIterator has 22 functions (exceeds 20 allowed). Consider refactoring.
            Open

            abstract class AbstractResultsIterator implements \Countable, \Iterator
            {
                private $count = 0;
                private $raw;
                private $scrollId;
            Severity: Minor
            Found in Result/AbstractResultsIterator.php - About 2 hrs to fix

              Function normalize has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function normalize($document, $metadata = null)
                  {
                      if ($document === null) {
                          return null;
                      }
              Severity: Minor
              Found in Mapping/Converter.php - About 2 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

              Method getPropertyMetadata has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getPropertyMetadata(\ReflectionClass $class, bool $subClass = false): array
                  {
                      if ($class->isTrait() || (!$this->reader->getClassAnnotation($class, Index::class) && !$subClass)) {
                          return [];
                      }
              Severity: Minor
              Found in Mapping/DocumentParser.php - About 1 hr to fix

                Method exportIndex has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function exportIndex(
                        IndexService $index,
                        $filename,
                        $chunkSize,
                        OutputInterface $output,
                Severity: Minor
                Found in Service/ExportService.php - About 1 hr to fix

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

                      public function getConfigTreeBuilder()
                      {
                  
                          $treeBuilder = new TreeBuilder('ongr_elasticsearch');
                  
                  
                  Severity: Minor
                  Found in DependencyInjection/Configuration.php - About 1 hr to fix

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

                        private function getClassMetadata(\ReflectionClass $class): array
                        {
                            $mapping = [];
                            $objFields = null;
                            $arrayFields = null;
                    Severity: Minor
                    Found in Mapping/DocumentParser.php - About 1 hr to fix

                      Function handleDirectoryMapping has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function handleDirectoryMapping(ContainerBuilder $container, string $dir): void
                          {
                              /** @var DocumentParser $parser */
                              $parser = $container->get(DocumentParser::class);
                              $indexesOverride = $container->getParameter(Configuration::ONGR_INDEXES_OVERRIDE);
                      Severity: Minor
                      Found in DependencyInjection/Compiler/MappingPass.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 commit has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function commit($commitMode = 'refresh', array $params = []): array
                          {
                              $bulkResponse = [];
                              if (!empty($this->bulkQueries)) {
                                  $this->eventDispatcher->dispatch(
                      Severity: Minor
                      Found in Service/IndexService.php - About 1 hr to fix

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

                            protected function denormalize(array $raw, string $namespace)
                            {
                                $metadata = $this->propertyMetadata[$namespace];
                                $object = new $namespace();
                        
                        
                        Severity: Minor
                        Found in Mapping/Converter.php - About 1 hr to fix

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

                              public function getAnalysisConfig(\ReflectionClass $class): array
                              {
                                  $config = [];
                                  $mapping = $this->getClassMetadata($class);
                          
                          
                          Severity: Minor
                          Found in Mapping/DocumentParser.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 configure has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function configure()
                              {
                                  parent::configure();
                          
                                  $this
                          Severity: Minor
                          Found in Command/IndexCreateCommand.php - About 1 hr to fix

                            Method getAnalysisNode has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private function getAnalysisNode(): NodeDefinition
                                {
                                    $builder = new TreeBuilder('analysis');
                            
                                    if (method_exists($builder, 'getRootNode')) {
                            Severity: Minor
                            Found in DependencyInjection/Configuration.php - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language