File LanguageServer.php
has 595 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Phan\LanguageServer;
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");
}
LanguageServer
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class LanguageServer extends AdvancedJsonRpc\Dispatcher
{
/**
* Handles workspace/* method calls
*
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) {
- Read upRead up
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) {
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");
}
- Read upRead up
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();
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) {
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) {
- Read upRead up
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 [[], []];
- Read upRead up
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:
Avoid too many return
statements within this method. Open
return $most_recent_request;
Avoid too many return
statements within this method. Open
return $file_path_list;