Showing 4,939 of 4,939 total issues
File FallbackUnionTypeVisitor.php
has 411 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Phan\AST;
GenericArrayType
has 43 functions (exceeds 20 allowed). Consider refactoring. Open
class GenericArrayType extends ArrayType implements GenericArrayInterface
{
/** @phan-override */
public const NAME = 'array';
BlockExitStatusChecker
has 43 functions (exceeds 20 allowed). Consider refactoring. Open
final class BlockExitStatusChecker extends KindVisitorImplementation
{
// These should be at most 1 << 31, in order to work in 32-bit php.
// NOTE: Any exit status must be a combination of at least one of these bits
// E.g. if STATUS_PROCEED is mixed with STATUS_RETURN, it would mean it is possible both to go to completion or return.
Method analyzeParameterList
has 144 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function analyzeParameterList(
CodeBase $code_base,
FunctionInterface $method,
Node $node,
Context $context
Function astNodeToPrimitive
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
protected function astNodeToPrimitive(CodeBase $code_base, Context $context, $ast_node): ?PrimitiveValue
{
// Base case: convert primitive tokens such as numbers and strings.
if (!($ast_node instanceof Node)) {
return new PrimitiveValue($ast_node);
- 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 analyzeParameterTypesInner
has 143 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function analyzeParameterTypesInner(
CodeBase $code_base,
FunctionInterface $method
): void {
if (Config::getValue('check_docblock_signature_param_type_match')) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
public static function fromElementType(
Type $type,
bool $is_nullable,
int $key_type = GenericArrayType::KEY_INT
): GenericArrayType {
- Read upRead up
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 198.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public static function fromElementType(
Type $type,
bool $is_nullable,
int $key_type = GenericArrayType::KEY_MIXED
): GenericArrayType {
- Read upRead up
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 198.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method
has 42 functions (exceeds 20 allowed). Consider refactoring. Open
class Method extends ClassElement implements FunctionInterface
{
use Analyzable;
use Memoize;
use FunctionTrait;
File CompletionResolver.php
has 400 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Phan\LanguageServer;
Method createPhanSettingsForComposerSettings
has 140 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function createPhanSettingsForComposerSettings(array $composer_settings, ?string $vendor_path, array $opts): InitializedSettings
{
$level = $opts['init-level'] ?? 3;
$level = self::LEVEL_MAP[\strtolower((string)$level)] ?? $level;
if (\filter_var($level, FILTER_VALIDATE_INT) === false) {
Function finalizeProcess
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
public function finalizeProcess(CodeBase $code_base): void
{
if (empty($this->elements)) {
\fwrite(\STDERR, "Nothing to analyze - please run pdep from your top-level project directory" . \PHP_EOL);
exit(\EXIT_FAILURE);
- 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 visitVar
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
public function visitVar(Node $node): Context
{
try {
$variable_name = (new ContextNode(
$this->code_base,
- 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 visitStmtList
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
public function visitStmtList(Node $node): void
{
$child_nodes = $node->children;
$last_node_index = count($child_nodes) - 1;
- 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 checkCall
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
private function checkCall(FunctionInterface $function, array $args, Node $node): void
{
$arg_names = [];
foreach ($args as $i => $arg_node) {
$name = self::extractName($arg_node);
- 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 isRedundantFunctionComment
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
private static function isRedundantFunctionComment(FunctionInterface $method, string $doc_comment): bool
{
$lines = explode("\n", $doc_comment);
foreach ($lines as $line) {
$line = trim($line, " \r\n\t*/");
- 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 hasInternalFunctionWithFQSEN
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
private function hasInternalFunctionWithFQSEN(
FullyQualifiedFunctionName $fqsen
): bool {
$canonical_fqsen = $fqsen->withAlternateId(0);
$found = isset($this->internal_function_fqsen_set[$canonical_fqsen]);
- 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 checkInvalidArrayShapeCombination
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
public static function checkInvalidArrayShapeCombination(
CodeBase $code_base,
Context $context,
Node $node,
UnionType $left,
- 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 createClosureForMethod
has 135 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function createClosureForMethod(CodeBase $code_base, Method $method, string $name): ?Closure
{
// TODO: Add a helper method which will convert a doc comment and a stub php function source code to a closure for a param index (or indices)
switch (\strtolower($name)) {
case 'asserttrue':
File ReferenceCountsAnalyzer.php
has 391 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Phan\Analysis;