Showing 3,272 of 4,939 total issues
Method encodeValue
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function encodeValue($value, int $max_depth = 2): string
{
if (is_object($value)) {
if ($value instanceof IssueInstance) {
return "IssueInstance($value)";
Method fromNode
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function fromNode(
Context $context,
CodeBase $code_base,
Node $node
): Parameter {
Method createSwitchConditionAnalyzer
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function createSwitchConditionAnalyzer($switch_case_node): array
{
$switch_kind = ($switch_case_node->kind ?? null);
try {
if ($switch_kind === ast\AST_VAR) {
Method analyzeClassConstantTypes
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function analyzeClassConstantTypes(CodeBase $code_base, Clazz $clazz): void
{
foreach ($clazz->getConstantMap($code_base) as $constant) {
// This phase is done before the analysis phase, so there aren't any dynamic properties to filter out.
Method load
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function load(): void
{
if (!class_exists('\ast\Node')) {
// Fix for https://github.com/phan/phan/issues/2287
require_once __DIR__ . '/ast_shim.php';
Method visitMagicConst
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitMagicConst(Node $node): UnionType
{
$flags = $node->flags;
switch ($flags) {
case ast\flags\MAGIC_CLASS:
Method phpParserTypeToAstNode
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected static function phpParserTypeToAstNode($type, int $line): ?ast\Node
{
if (\is_null($type)) {
return null;
}
Method handleTraitPrecedence
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function handleTraitPrecedence(array $adaptations_map, Node $adaptation_node): void
{
// TODO: Should also verify that the original method exists, in a future PR?
$trait_method_node = $adaptation_node->children['method'];
if (!$trait_method_node instanceof Node) {
Method dump_main
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
function dump_main(): void
{
$print_help = static function (int $exit_code): void {
global $argv;
$help = <<<"EOB"
Method astNodeToPrimitive
has 69 lines of code (exceeds 25 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);
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
Function extractParamTagsFromDocComment
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public static function extractParamTagsFromDocComment(AddressableElementInterface $element, bool $with_param_details = true): array
{
$doc_comment = $element->getDocComment();
if (!\is_string($doc_comment)) {
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
Function __construct
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function __construct(
int $comment_flags,
array $variable_list,
array $parameter_list,
array $template_type_list,
- 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 canCastToNonNullableType
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
protected function canCastToNonNullableType(Type $type): bool
{
if ($type instanceof ScalarType) {
switch ($type::NAME) {
case 'float':
- 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 getKeyTypeOfArrayNode
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public static function getKeyTypeOfArrayNode(CodeBase $code_base, Context $context, Node $node, bool $should_catch_issue_exception = true): int
{
$key_type_enum = GenericArrayType::KEY_EMPTY;
// Check the all elements for key types.
foreach ($node->children as $child) {
- 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 canCastToGenericArrayKeys
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function canCastToGenericArrayKeys(GenericArrayType $type, bool $ignore_config = false): bool
{
if ($type instanceof ListType) {
$i = 0;
$has_possibly_undefined = false;
- 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 withFlattenedArrayShapeTypeInstancesForSet
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private static function withFlattenedArrayShapeTypeInstancesForSet(array $type_set): array
{
$result = [];
$has_other_array_type = false;
$empty_array_shape_type = null;
- 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 canCastToNonNullableType
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
protected function canCastToNonNullableType(Type $type): bool
{
if ($type instanceof ScalarType) {
switch ($type::NAME) {
case 'string':
- 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 hasSubtypeOf
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function hasSubtypeOf(
UnionType $target
): bool {
// Fast-track most common cases first
$type_set = $this->type_set;
- 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 visitForeach
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function visitForeach(Node $node): Context
{
$code_base = $this->code_base;
$context = $this->context;
$context->setLineNumberStart($node->lineno);
- 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"