Showing 3,272 of 4,939 total issues

Function parseMultiPartRegularString has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private static function parseMultiPartRegularString(PhpParser\Node\StringLiteral $n, array $children): ast\Node
    {
        $inner_node_parts = [];
        $start_quote_text = static::tokenToString($n->startQuote);
        $end_quote_text = $n->endQuote->getText(self::$file_contents);
Severity: Minor
Found in src/Phan/AST/TolerantASTConverter/TolerantASTConverter.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 phpParserVisibilityToAstVisibility has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private static function phpParserVisibilityToAstVisibility(array $visibility, bool $automatically_add_public = true): int
    {
        $ast_visibility = 0;
        foreach ($visibility as $token) {
            switch ($token->kind) {
Severity: Minor
Found in src/Phan/AST/TolerantASTConverter/TolerantASTConverter.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 visitClassName has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitClassName(Node $node): UnionType
    {
        $class_node = $node->children['class'];
        try {
            $class_list = (new ContextNode(
Severity: Minor
Found in src/Phan/AST/UnionTypeVisitor.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 parseFile has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public static function parseFile(CodeBase $code_base, string $file_path, bool $suppress_parse_errors = false, string $override_contents = null, bool $is_php_internal_stub = false, ?Request $request = null): Context
    {
        $original_file_path = $file_path;
        $code_base->setCurrentParsedFile($file_path);
        if ($is_php_internal_stub) {
Severity: Minor
Found in src/Phan/Analysis.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 getParametersCountsFromPhan has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function getParametersCountsFromPhan(array $fields): array
{
    $num_required = 0;
    unset($fields[0]);
    $num_optional = count($fields);
Severity: Minor
Found in internal/sanitycheck.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 visitMethod has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitMethod(Node $node): void
    {
        $stmts_node = $node->children['stmts'] ?? null;

        if (!$stmts_node || $stmts_node->children) {
Severity: Minor
Found in .phan/plugins/EmptyMethodAndFunctionPlugin.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 containsFFICDataType has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private static function containsFFICDataType(UnionType $union_type): int
    {
        foreach ($union_type->getTypeSet() as $type) {
            if (strcasecmp('\FFI', $type->getNamespace()) !== 0) {
                continue;
Severity: Minor
Found in .phan/plugins/FFIAnalysisPlugin.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 visitIf has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function visitIf(Node $node): void
    {
        if (count($node->children) <= 1) {
            // There can't be any duplicates.
            return;
Severity: Minor
Found in .phan/plugins/DuplicateExpressionPlugin.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 __clone has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function __clone()
    {
        $this->fqsen_class_map =
            $this->fqsen_class_map->deepCopyValues();

Severity: Minor
Found in src/Phan/CodeBase.php - About 1 hr to fix

    Method generateDefaultNodeRepresentation has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function generateDefaultNodeRepresentation(bool $is_internal = true): string
        {
            if (is_string($this->default_value_representation)) {
                return $this->default_value_representation;
            }
    Severity: Minor
    Found in src/Phan/Language/Element/Parameter.php - About 1 hr to fix

      Method getGenericConstructorBuilder has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getGenericConstructorBuilder(CodeBase $code_base): array
          {
              return $this->memoize(
                  'template_type_resolvers',
                  /**
      Severity: Minor
      Found in src/Phan/Language/Element/Clazz.php - About 1 hr to fix

        Method canCastToNonNullableType has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function canCastToNonNullableType(Type $type): bool
            {
                if ($type instanceof ArrayType) {
                    if ($type instanceof GenericArrayType) {
                        if (!$this->element_type->canCastToType($type->element_type)) {
        Severity: Minor
        Found in src/Phan/Language/Type/GenericArrayType.php - About 1 hr to fix

          Method canCastToNonNullableTypeWithoutConfig has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function canCastToNonNullableTypeWithoutConfig(Type $type): bool
              {
                  if ($type instanceof ArrayType) {
                      if ($type instanceof GenericArrayType) {
                          if (!$this->element_type->canCastToTypeWithoutConfig($type->element_type)) {
          Severity: Minor
          Found in src/Phan/Language/Type/GenericArrayType.php - About 1 hr to fix

            Method combineArrayShapeTypes has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private static function combineArrayShapeTypes(array $types, bool $add_mixed): ArrayShapeType
                {
                    $is_nullable = false;
                    $field_types_list = [];
                    $common_field_types = [];
            Severity: Minor
            Found in src/Phan/Language/UnionType.php - About 1 hr to fix

              Method canCastTraversableToIterable has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function canCastTraversableToIterable(GenericIterableType $type): bool
                  {
                      $template_types = $this->template_parameter_type_list;
                      $count = count($template_types);
                      $name = $this->name;
              Severity: Minor
              Found in src/Phan/Language/Type.php - About 1 hr to fix

                Method suggestSimilarProperty has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function suggestSimilarProperty(CodeBase $code_base, Context $context, Clazz $class, string $wanted_property_name, bool $is_static): ?Suggestion
                    {
                        if (Config::getValue('disable_suggestions')) {
                            return null;
                        }
                Severity: Minor
                Found in src/Phan/IssueFixSuggester.php - About 1 hr to fix

                  Method sanityCheckErrorList has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private static function sanityCheckErrorList(array $error_list): void
                      {
                          $error_map = [];
                          $unique_type_id_set = [];
                          foreach ($error_list as $error) {
                  Severity: Minor
                  Found in src/Phan/Issue.php - About 1 hr to fix

                    Method generateSuppressIssueSummary has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function generateSuppressIssueSummary(string $baseline_summary_type): string
                        {
                            if ($baseline_summary_type === 'none') {
                                return '';
                            }
                    Severity: Minor
                    Found in src/Phan/Plugin/Internal/BaselineSavingPlugin.php - About 1 hr to fix

                      Method checkImpossibleComparison has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function checkImpossibleComparison(Node $node, bool $strict): void
                          {
                              $left = UnionTypeVisitor::unionTypeFromNode($this->code_base, $this->context, $node->children['left']);
                              if (!$left->hasRealTypeSet()) {
                                  return;
                      Severity: Minor
                      Found in src/Phan/Plugin/Internal/RedundantConditionVisitor.php - About 1 hr to fix

                        Method withoutCaughtUnionTypes has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function withoutCaughtUnionTypes(UnionType $union_type, bool $is_raw_throw): UnionType
                            {
                                if ($union_type->isEmpty()) {
                                    if (!$is_raw_throw) {
                                        return $union_type;
                        Severity: Minor
                        Found in src/Phan/Plugin/Internal/ThrowAnalyzerPlugin.php - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language