src/Phan/LanguageServer/LanguageServer.php

Summary

Maintainability
F
4 days
Test Coverage

File LanguageServer.php has 595 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Phan\LanguageServer;
Severity: Major
Found in src/Phan/LanguageServer/LanguageServer.php - About 1 day to fix

    Method run has 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function run(CodeBase $code_base, Closure $file_path_lister, array $options): ?Request
        {
            if (!$code_base->isUndoTrackingEnabled()) {
                throw new AssertionError("Expected undo tracking to be enabled");
            }
    Severity: Major
    Found in src/Phan/LanguageServer/LanguageServer.php - About 3 hrs to fix

      LanguageServer has 25 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class LanguageServer extends AdvancedJsonRpc\Dispatcher
      {
          /**
           * Handles workspace/* method calls
           *
      Severity: Minor
      Found in src/Phan/LanguageServer/LanguageServer.php - About 2 hrs to fix

        Function finalizeAnalyzingURIs has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            private function finalizeAnalyzingURIs(): void
            {
                [$uris_to_analyze, $file_path_list] = $this->getFilteredURIsToAnalyze();
                // TODO: Add a better abstraction of
                if (\count($uris_to_analyze) === 0) {
        Severity: Minor
        Found in src/Phan/LanguageServer/LanguageServer.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 finalizeAnalyzingURIs has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function finalizeAnalyzingURIs(): void
            {
                [$uris_to_analyze, $file_path_list] = $this->getFilteredURIsToAnalyze();
                // TODO: Add a better abstraction of
                if (\count($uris_to_analyze) === 0) {
        Severity: Major
        Found in src/Phan/LanguageServer/LanguageServer.php - About 2 hrs to fix

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

              public static function run(CodeBase $code_base, Closure $file_path_lister, array $options): ?Request
              {
                  if (!$code_base->isUndoTrackingEnabled()) {
                      throw new AssertionError("Expected undo tracking to be enabled");
                  }
          Severity: Minor
          Found in src/Phan/LanguageServer/LanguageServer.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 __construct has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function __construct(ProtocolReader $reader, ProtocolWriter $writer, CodeBase $code_base, Closure $file_path_lister)
              {
                  parent::__construct($this, '/');
                  $this->protocolReader = $reader;
                  $this->file_mapping = new FileMapping();
          Severity: Major
          Found in src/Phan/LanguageServer/LanguageServer.php - About 2 hrs to fix

            Method handleJSONResponseFromWorker has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function handleJSONResponseFromWorker(array $uris_to_analyze, array $response_data): void
                {
                    $most_recent_node_info_request = $this->most_recent_node_info_request;
                    if ($most_recent_node_info_request) {
                        if ($most_recent_node_info_request instanceof GoToDefinitionRequest) {
            Severity: Minor
            Found in src/Phan/LanguageServer/LanguageServer.php - About 1 hr to fix

              Function handleJSONResponseFromWorker has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function handleJSONResponseFromWorker(array $uris_to_analyze, array $response_data): void
                  {
                      $most_recent_node_info_request = $this->most_recent_node_info_request;
                      if ($most_recent_node_info_request) {
                          if ($most_recent_node_info_request instanceof GoToDefinitionRequest) {
              Severity: Minor
              Found in src/Phan/LanguageServer/LanguageServer.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 getFilteredURIsToAnalyze has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function getFilteredURIsToAnalyze(): array
                  {
                      $uris_to_analyze = $this->analyze_request_set;
                      if (\count($uris_to_analyze) === 0) {
                          return [[], []];
              Severity: Minor
              Found in src/Phan/LanguageServer/LanguageServer.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 finishAnalyzingURIsWithoutPcntl has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function finishAnalyzingURIsWithoutPcntl(array $uris_to_analyze): void
                  {
                      $paths_to_analyze = \array_keys($uris_to_analyze);
                      Logger::logInfo('in ' . __METHOD__ . ' paths: ' . StringUtil::jsonEncode($paths_to_analyze));
                      // When there is no pcntl:
              Severity: Minor
              Found in src/Phan/LanguageServer/LanguageServer.php - About 1 hr to fix

                Avoid too many return statements within this method.
                Open

                            return $most_recent_request;
                Severity: Major
                Found in src/Phan/LanguageServer/LanguageServer.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return $file_path_list;
                  Severity: Major
                  Found in src/Phan/LanguageServer/LanguageServer.php - About 30 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status