# etsy/phan

src/Phan/Language/Element/Comment/Builder.php

### Summary

F
1 wk

#### File Builder.php has 1164 lines of code (exceeds 250 allowed). Consider refactoring. Open

<?php

declare(strict_types=1);

namespace Phan\Language\Element\Comment;
Found in src/Phan/Language/Element/Comment/Builder.php - About 2 days to fix

#### Builder has 44 functions (exceeds 20 allowed). Consider refactoring. Open

final class Builder
{
/** @var string the original raw comment */
public $comment; /** @var list<string> the list of lines of the doc comment */ Found in src/Phan/Language/Element/Comment/Builder.php - About 6 hrs to fix #### Function parseCommentLine has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open  private function parseCommentLine(int$i, string $line): void { // https://secure.php.net/manual/en/regexp.reference.internal-options.php // (?i) makes this case-sensitive, (?-1) makes it case-insensitive // phpcs:ignore Generic.Files.LineLength.MaxExceeded Found in src/Phan/Language/Element/Comment/Builder.php - About 5 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 maybeParsePhanCustomAnnotation has 134 lines of code (exceeds 25 allowed). Consider refactoring. Open  private function maybeParsePhanCustomAnnotation(int$i, string $line, string$type, string $case_sensitive_type): void { switch ($type) {
case 'phan-forbid-undeclared-magic-properties':
if ($this->checkCompatible('@phan-forbid-undeclared-magic-properties', [Comment::ON_CLASS],$i)) {
Found in src/Phan/Language/Element/Comment/Builder.php - About 5 hrs to fix

#### Method parseCommentLine has 102 lines of code (exceeds 25 allowed). Consider refactoring. Open

    private function parseCommentLine(int $i, string$line): void
{
// https://secure.php.net/manual/en/regexp.reference.internal-options.php
// (?i) makes this case-sensitive, (?-1) makes it case-insensitive
// phpcs:ignore Generic.Files.LineLength.MaxExceeded
Found in src/Phan/Language/Element/Comment/Builder.php - About 4 hrs to fix

#### The class Builder has 42 non-getter- and setter-methods. Consider refactoring Builder to keep number of methods under 25. Open

final class Builder
{
/** @var string the original raw comment */
public $comment; /** @var list<string> the list of lines of the doc comment */ ## TooManyMethods ### Since: 0.1 A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects. By default it ignores methods starting with 'get' or 'set'. The default was changed from 10 to 25 in PHPMD 2.3. ## Example ### Source https://phpmd.org/rules/codesize.html#toomanymethods #### The class Builder has an overall complexity of 256 which is very high. The configured complexity threshold is 50. Open final class Builder { /** @var string the original raw comment */ public$comment;
/** @var list<string> the list of lines of the doc comment */

#### Function parameterFromCommentLine has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open

    private function parameterFromCommentLine(
string $line, bool$is_var,
int $i ): Parameter { Found in src/Phan/Language/Element/Comment/Builder.php - About 3 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 #### Consider simplifying this complex logical expression. Open  if (!$this->comment_flags &&
!$this->return_comment && !$this->parameter_list &&
!$this->variable_list && !$this->template_type_list &&
Found in src/Phan/Language/Element/Comment/Builder.php - About 3 hrs to fix

#### Function magicMethodFromCommentLine has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open

    private function magicMethodFromCommentLine(
string $line, int$comment_line_offset
): ?Method {
// https://phpdoc.org/docs/latest/references/phpdoc/tags/method.html
Found in src/Phan/Language/Element/Comment/Builder.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"

#### Method parameterFromCommentLine has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open

    private function parameterFromCommentLine(
string $line, bool$is_var,
int $i ): Parameter { Found in src/Phan/Language/Element/Comment/Builder.php - About 2 hrs to fix #### Function mergeMethodParts has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open  private static function mergeMethodParts(array$parts): array
{
$prev_parts = [];$delta = 0;
$results = []; Found in src/Phan/Language/Element/Comment/Builder.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 #### Function maybeParsePhanCustomAnnotation has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open  private function maybeParsePhanCustomAnnotation(int$i, string $line, string$type, string $case_sensitive_type): void { switch ($type) {
case 'phan-forbid-undeclared-magic-properties':
if ($this->checkCompatible('@phan-forbid-undeclared-magic-properties', [Comment::ON_CLASS],$i)) {
Found in src/Phan/Language/Element/Comment/Builder.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"

#### Method magicMethodFromCommentLine has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open

    private function magicMethodFromCommentLine(
string $line, int$comment_line_offset
): ?Method {
// https://phpdoc.org/docs/latest/references/phpdoc/tags/method.html
Found in src/Phan/Language/Element/Comment/Builder.php - About 2 hrs to fix

#### Method build has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open

    public function build(): Comment
{
foreach ($this->lines as$i => $line) { if (\strpos($line, '@') === false) {
continue;
Found in src/Phan/Language/Element/Comment/Builder.php - About 1 hr to fix

    private function guessActualLineLocation(int $i): int {$path = Config::projectPath($this->context->getFile());$entry = FileCache::getEntry($path);$declaration_lineno = $this->lineno; Found in src/Phan/Language/Element/Comment/Builder.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 #### The class Builder has 22 fields. Consider redesigning Builder to keep the number of fields under 15. Open final class Builder { /** @var string the original raw comment */ public$comment;
/** @var list<string> the list of lines of the doc comment */

## TooManyFields

### Since: 0.1

Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

## Example

class Person {
protected $one; private$two;
private $three; [... many more fields ...] } ### Source https://phpmd.org/rules/codesize.html#toomanyfields #### Function findLineNumberOfCommentForElement has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open  public static function findLineNumberOfCommentForElement(AddressableElementInterface$element, array $lines, int$i): int
{
$context =$element->getContext();

$entry = FileCache::getOrReadEntry(Config::projectPath($context->getFile()));
Found in src/Phan/Language/Element/Comment/Builder.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"

#### Method magicPropertyFromCommentLine has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open

    private function magicPropertyFromCommentLine(
string $line, int$i
): ?Property {
// Note that the type of a property can be left out (@property $myVar) - This is equivalent to @property mixed$myVar
Found in src/Phan/Language/Element/Comment/Builder.php - About 1 hr to fix

#### Method returnTypeFromCommentLine has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open

    private function returnTypeFromCommentLine(
string $line, int$i
): UnionType {
$return_union_type_string = ''; Found in src/Phan/Language/Element/Comment/Builder.php - About 1 hr to fix #### Method magicParamFromMagicMethodParamString has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open  private function magicParamFromMagicMethodParamString( string$param_string,
int $param_index, int$comment_line_offset
): ?Parameter {
Found in src/Phan/Language/Element/Comment/Builder.php - About 1 hr to fix

#### Method mergeMethodParts has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open

    private static function mergeMethodParts(array $parts): array {$prev_parts = [];
$delta = 0;$results = [];
Found in src/Phan/Language/Element/Comment/Builder.php - About 1 hr to fix

#### Function build has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open

    public function build(): Comment
{
foreach ($this->lines as$i => $line) { if (\strpos($line, '@') === false) {
continue;
Found in src/Phan/Language/Element/Comment/Builder.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"

#### Function magicParamFromMagicMethodParamString has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open

    private function magicParamFromMagicMethodParamString(
string $param_string, int$param_index,
int $comment_line_offset ): ?Parameter { Found in src/Phan/Language/Element/Comment/Builder.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 parseMixin has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open  private function parseMixin(int$i, string $line, string$annotation_name): void
{
return;
}
Found in src/Phan/Language/Element/Comment/Builder.php - About 1 hr to fix

#### Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring. Open

        string $comment, CodeBase$code_base,
Context $context, int$lineno,
int $i ): ?Property { // Note that the type of a property can be left out (@property$myVar) - This is equivalent to @property mixed $myVar Found in src/Phan/Language/Element/Comment/Builder.php - About 45 mins 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 #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Avoid too many return statements within this method. Open  return; Found in src/Phan/Language/Element/Comment/Builder.php - About 30 mins to fix #### Function maybeParseTemplateType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open  private function maybeParseTemplateType(int$i, string $line): void { // Make sure support for generic types is enabled if (Config::getValue('generic_types_enabled')) { if ($this->checkCompatible('@template', Comment::HAS_TEMPLATE_ANNOTATION, $i)) { Found in src/Phan/Language/Element/Comment/Builder.php - About 25 mins 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 parseMixin has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open  private function parseMixin(int$i, string $line, string$annotation_name): void
{
return;
}
Found in src/Phan/Language/Element/Comment/Builder.php - About 25 mins 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"

#### Function maybeParseVarLine has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open

    private function maybeParseVarLine(int $i, string$line): void
{
if (!$this->checkCompatible('@var', Comment::HAS_VAR_ANNOTATION,$i)) {
return;
}
Found in src/Phan/Language/Element/Comment/Builder.php - About 25 mins 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"

#### The class Builder has 1492 lines of code. Current threshold is 1000. Avoid really long classes. Open

final class Builder
{
/** @var string the original raw comment */
public $comment; /** @var list<string> the list of lines of the doc comment */ #### The method parseCommentLine() has an NPath complexity of 360. The configured NPath complexity threshold is 200. Open  private function parseCommentLine(int$i, string $line): void { // https://secure.php.net/manual/en/regexp.reference.internal-options.php // (?i) makes this case-sensitive, (?-1) makes it case-insensitive // phpcs:ignore Generic.Files.LineLength.MaxExceeded ## NPathComplexity ### Since: 0.1 The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity. ## Example class Foo { function bar() { // lots of complicated code } } ### Source https://phpmd.org/rules/codesize.html#npathcomplexity #### The method maybeParsePhanCustomAnnotation() has 146 lines of code. Current threshold is set to 100. Avoid really long methods. Open  private function maybeParsePhanCustomAnnotation(int$i, string $line, string$type, string $case_sensitive_type): void { switch ($type) {
case 'phan-forbid-undeclared-magic-properties':
if ($this->checkCompatible('@phan-forbid-undeclared-magic-properties', [Comment::ON_CLASS],$i)) {

#### The method build() has an NPath complexity of 252. The configured NPath complexity threshold is 200. Open

    public function build(): Comment
{
foreach ($this->lines as$i => $line) { if (\strpos($line, '@') === false) {
continue;

## NPathComplexity

### Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

## Example

class Foo {
function bar() {
// lots of complicated code
}
}

### Source https://phpmd.org/rules/codesize.html#npathcomplexity

#### The method parseCommentLine() has 112 lines of code. Current threshold is set to 100. Avoid really long methods. Open

    private function parseCommentLine(int $i, string$line): void
{
// https://secure.php.net/manual/en/regexp.reference.internal-options.php
// (?i) makes this case-sensitive, (?-1) makes it case-insensitive
// phpcs:ignore Generic.Files.LineLength.MaxExceeded

#### The method build() has a Cyclomatic Complexity of 19. The configured cyclomatic complexity threshold is 10. Open

    public function build(): Comment
{
foreach ($this->lines as$i => $line) { if (\strpos($line, '@') === false) {
continue;

## CyclomaticComplexity

### Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

## Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a ==$b) {
3           if ($a1 ==$b1) {
fiddle();
4           } elseif ($a2 ==$b2) {
fiddle();
} else {
fiddle();
}
5       } elseif ($c ==$d) {
6           while ($c ==$d) {
fiddle();
}
7        } elseif ($e ==$f) {
8           for ($n = 0;$n < $h;$n++) {
fiddle();
}
} else {
switch ($z) { 9 case 1: fiddle(); break; 10 case 2: fiddle(); break; 11 case 3: fiddle(); break; default: fiddle(); break; } } } } ### Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity #### The method parameterFromCommentLine() has a Cyclomatic Complexity of 16. The configured cyclomatic complexity threshold is 10. Open  private function parameterFromCommentLine( string$line,
bool $is_var, int$i
): Parameter {

## CyclomaticComplexity

### Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

## Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a ==$b) {
3           if ($a1 ==$b1) {
fiddle();
4           } elseif ($a2 ==$b2) {
fiddle();
} else {
fiddle();
}
5       } elseif ($c ==$d) {
6           while ($c ==$d) {
fiddle();
}
7        } elseif ($e ==$f) {
8           for ($n = 0;$n < $h;$n++) {
fiddle();
}
} else {
switch ($z) { 9 case 1: fiddle(); break; 10 case 2: fiddle(); break; 11 case 3: fiddle(); break; default: fiddle(); break; } } } } ### Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity #### The method parseCommentLine() has a Cyclomatic Complexity of 35. The configured cyclomatic complexity threshold is 10. Open  private function parseCommentLine(int$i, string $line): void { // https://secure.php.net/manual/en/regexp.reference.internal-options.php // (?i) makes this case-sensitive, (?-1) makes it case-insensitive // phpcs:ignore Generic.Files.LineLength.MaxExceeded ## CyclomaticComplexity ### Since: 0.1 Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity. ## Example // Cyclomatic Complexity = 11 class Foo { 1 public function example() { 2 if ($a == $b) { 3 if ($a1 == $b1) { fiddle(); 4 } elseif ($a2 == $b2) { fiddle(); } else { fiddle(); } 5 } elseif ($c == $d) { 6 while ($c == $d) { fiddle(); } 7 } elseif ($e == $f) { 8 for ($n = 0; $n <$h; $n++) { fiddle(); } } else { switch ($z) {
9               case 1:
fiddle();
break;
10              case 2:
fiddle();
break;
11              case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}

### Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

#### The method maybeParsePhanCustomAnnotation() has a Cyclomatic Complexity of 49. The configured cyclomatic complexity threshold is 10. Open

    private function maybeParsePhanCustomAnnotation(int $i, string$line, string $type, string$case_sensitive_type): void
{
switch ($type) { case 'phan-forbid-undeclared-magic-properties': if ($this->checkCompatible('@phan-forbid-undeclared-magic-properties', [Comment::ON_CLASS], $i)) { ## CyclomaticComplexity ### Since: 0.1 Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity. ## Example // Cyclomatic Complexity = 11 class Foo { 1 public function example() { 2 if ($a == $b) { 3 if ($a1 == $b1) { fiddle(); 4 } elseif ($a2 == $b2) { fiddle(); } else { fiddle(); } 5 } elseif ($c == $d) { 6 while ($c == $d) { fiddle(); } 7 } elseif ($e == $f) { 8 for ($n = 0; $n <$h; $n++) { fiddle(); } } else { switch ($z) {
9               case 1:
fiddle();
break;
10              case 2:
fiddle();
break;
11              case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}

### Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

#### The class Builder has a coupling between objects value of 25. Consider to reduce the number of dependencies under 13. Open

final class Builder
{
/** @var string the original raw comment */
public $comment; /** @var list<string> the list of lines of the doc comment */ ## CouplingBetweenObjects ### Since: 1.1.0 A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability ## Example class Foo { /** * @var \foo\bar\X */ private$x = null;

/**
* @var \foo\bar\Y
*/
private $y = null; /** * @var \foo\bar\Z */ private$z = null;

public function setFoo(\Foo $foo) {} public function setBar(\Bar$bar) {}
public function setBaz(\Baz $baz) {} /** * @return \SplObjectStorage * @throws \OutOfRangeException * @throws \InvalidArgumentException * @throws \ErrorException */ public function process(\Iterator$it) {}

// ...
}

### Source https://phpmd.org/rules/design.html#couplingbetweenobjects

#### Similar blocks of code found in 2 locations. Consider refactoring. Open

    private static function mergeMethodParts(array $parts): array {$prev_parts = [];
$delta = 0;$results = [];
Found in src/Phan/Language/Element/Comment/Builder.php and 1 other location - About 1 day to fix
src/Phan/Language/UnionType.php on lines 530..562

## 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 355.

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

#### Similar blocks of code found in 2 locations. Consider refactoring. Open

    private function parsePhanProperty(int $i, string$line): void
{
if (!$this->checkCompatible('@phan-property', [Comment::ON_CLASS],$i)) {
return;
}
Found in src/Phan/Language/Element/Comment/Builder.php and 1 other location - About 50 mins to fix
src/Phan/Language/Element/Comment/Builder.php on lines 960..973

## 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 97.

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

#### Similar blocks of code found in 2 locations. Consider refactoring. Open

    private function parsePhanMethod(int $i, string$line): void
{
if (!$this->checkCompatible('@phan-method', [Comment::ON_CLASS],$i)) {
return;
}
Found in src/Phan/Language/Element/Comment/Builder.php and 1 other location - About 50 mins to fix
src/Phan/Language/Element/Comment/Builder.php on lines 945..958

## 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 97.

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

#### Similar blocks of code found in 2 locations. Consider refactoring. Open

    private static function extractMethodParts(string $type_string): array {$parts = [];
foreach (\explode(',', $type_string) as$part) {
$parts[] = \trim($part);
Found in src/Phan/Language/Element/Comment/Builder.php and 1 other location - About 50 mins to fix
src/Phan/Language/UnionType.php on lines 490..504

## 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 97.

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.

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local
for (int $i = 0;$i < 10; $i++) { // Not a Violation (inside FOR)$r += $this->q; } } } ### Source https://phpmd.org/rules/naming.html#shortvariable #### Avoid variables with short names like$i. Configured minimum length is 3. Open

    private function parsePhanProperty(int $i, string$line): void

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local

    private function guessActualLineLocation(int $i): int ## ShortVariable ### Since: 0.2 Detects when a field, local, or parameter has a very short name. ## Example class Something { private$q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal$r = 20 + $this->q; // VIOLATION - Local for (int$i = 0; $i < 10;$i++) { // Not a Violation (inside FOR)
$r +=$this->q;
}
}
}

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local
for (int $i = 0;$i < 10; $i++) { // Not a Violation (inside FOR)$r += $this->q; } } } ### Source https://phpmd.org/rules/naming.html#shortvariable #### Avoid variables with short names like$i. Configured minimum length is 3. Open

    private function maybeParsePhanAssert(int $i, string$line): void

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local
for (int $i = 0;$i < 10; $i++) { // Not a Violation (inside FOR)$r += $this->q; } } } ### Source https://phpmd.org/rules/naming.html#shortvariable #### Avoid variables with short names like$i. Configured minimum length is 3. Open

    private function maybeParseReturn(int $i, string$line): void

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local
for (int $i = 0;$i < 10; $i++) { // Not a Violation (inside FOR)$r += $this->q; } } } ### Source https://phpmd.org/rules/naming.html#shortvariable #### Avoid variables with short names like$i. Configured minimum length is 3. Open

    private function parsePhanMethod(int $i, string$line): void

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local
for (int $i = 0;$i < 10; $i++) { // Not a Violation (inside FOR)$r += $this->q; } } } ### Source https://phpmd.org/rules/naming.html#shortvariable #### Avoid variables with short names like$i. Configured minimum length is 3. Open

    private function maybeParseTemplateType(int $i, string$line): void

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local
for (int $i = 0;$i < 10; $i++) { // Not a Violation (inside FOR)$r += $this->q; } } } ### Source https://phpmd.org/rules/naming.html#shortvariable #### Avoid variables with short names like$i. Configured minimum length is 3. Open

    private function parseUnusedParamLine(int $i, string$line): void

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local

    private function maybeParsePhanInherits(int $i, string$line, string $type): void ## ShortVariable ### Since: 0.2 Detects when a field, local, or parameter has a very short name. ## Example class Something { private$q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal$r = 20 + $this->q; // VIOLATION - Local for (int$i = 0; $i < 10;$i++) { // Not a Violation (inside FOR)
$r +=$this->q;
}
}
}

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local
for (int $i = 0;$i < 10; $i++) { // Not a Violation (inside FOR)$r += $this->q; } } } ### Source https://phpmd.org/rules/naming.html#shortvariable #### Avoid variables with short names like$j. Configured minimum length is 3. Open

                $j =$i - ($lineno_search -$check_lineno);

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local
for (int $i = 0;$i < 10; $i++) { // Not a Violation (inside FOR)$r += $this->q; } } } ### Source https://phpmd.org/rules/naming.html#shortvariable #### Avoid variables with short names like$i. Configured minimum length is 3. Open

    private function maybeParseVarLine(int $i, string$line): void

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local
for (int $i = 0;$i < 10; $i++) { // Not a Violation (inside FOR)$r += $this->q; } } } ### Source https://phpmd.org/rules/naming.html#shortvariable #### Avoid variables with short names like$i. Configured minimum length is 3. Open

    private function maybeParseMethod(int $i, string$line): void

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local

    public static function findLineNumberOfCommentForElement(AddressableElementInterface $element, array$lines, int $i): int ## ShortVariable ### Since: 0.2 Detects when a field, local, or parameter has a very short name. ## Example class Something { private$q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal$r = 20 + $this->q; // VIOLATION - Local for (int$i = 0; $i < 10;$i++) { // Not a Violation (inside FOR)
$r +=$this->q;
}
}
}

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local

    private function maybeParseInherits(int $i, string$line, string $type): void ## ShortVariable ### Since: 0.2 Detects when a field, local, or parameter has a very short name. ## Example class Something { private$q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal$r = 20 + $this->q; // VIOLATION - Local for (int$i = 0; $i < 10;$i++) { // Not a Violation (inside FOR)
$r +=$this->q;
}
}
}

### Source https://phpmd.org/rules/naming.html#shortvariable

#### Avoid variables with short names like $i. Configured minimum length is 3. Open  private function maybeParsePhanClosureScope(int$i, string $line): void ## ShortVariable ### Since: 0.2 Detects when a field, local, or parameter has a very short name. ## Example class Something { private$q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal$r = 20 + $this->q; // VIOLATION - Local for (int$i = 0; $i < 10;$i++) { // Not a Violation (inside FOR)
$r +=$this->q;
}
}
}

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local
for (int $i = 0;$i < 10; $i++) { // Not a Violation (inside FOR)$r += $this->q; } } } ### Source https://phpmd.org/rules/naming.html#shortvariable #### Avoid variables with short names like$i. Configured minimum length is 3. Open

    private function maybeParseThrows(int $i, string$line): void

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local
for (int $i = 0;$i < 10; $i++) { // Not a Violation (inside FOR)$r += $this->q; } } } ### Source https://phpmd.org/rules/naming.html#shortvariable #### Avoid variables with short names like$i. Configured minimum length is 3. Open

    private function maybeParseSuppress(int $i, string$line): void

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local

        int $i ## ShortVariable ### Since: 0.2 Detects when a field, local, or parameter has a very short name. ## Example class Something { private$q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal$r = 20 + $this->q; // VIOLATION - Local for (int$i = 0; $i < 10;$i++) { // Not a Violation (inside FOR)
$r +=$this->q;
}
}
}

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local
for (int $i = 0;$i < 10; $i++) { // Not a Violation (inside FOR)$r += $this->q; } } } ### Source https://phpmd.org/rules/naming.html#shortvariable #### Avoid variables with short names like$i. Configured minimum length is 3. Open

    private function parseParamLine(int $i, string$line): void

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local
for (int $i = 0;$i < 10; $i++) { // Not a Violation (inside FOR)$r += $this->q; } } } ### Source https://phpmd.org/rules/naming.html#shortvariable #### Avoid variables with short names like$i. Configured minimum length is 3. Open

    private function maybeParsePhanCustomAnnotation(int $i, string$line, string $type, string$case_sensitive_type): void

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local
for (int $i = 0;$i < 10; $i++) { // Not a Violation (inside FOR)$r += $this->q; } } } ### Source https://phpmd.org/rules/naming.html#shortvariable #### Avoid variables with short names like$i. Configured minimum length is 3. Open

    private function parseCommentLine(int $i, string$line): void

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local
for (int $i = 0;$i < 10; $i++) { // Not a Violation (inside FOR)$r += $this->q; } } } ### Source https://phpmd.org/rules/naming.html#shortvariable #### Avoid variables with short names like$i. Configured minimum length is 3. Open

    private function maybeParseProperty(int $i, string$line): void

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local
for (int $i = 0;$i < 10; $i++) { // Not a Violation (inside FOR)$r += $this->q; } } } ### Source https://phpmd.org/rules/naming.html#shortvariable #### Avoid variables with short names like$j. Configured minimum length is 3. Open

                $j =$i - ($lineno_search -$check_lineno);

## ShortVariable

### Since: 0.2

Detects when a field, local, or parameter has a very short name.

## Example

class Something {
private $q = 15; // VIOLATION - Field public static function main( array$as ) { // VIOLATION - Formal
$r = 20 +$this->q; // VIOLATION - Local
for (int $i = 0;$i < 10; $i++) { // Not a Violation (inside FOR)$r += \$this->q;
}
}
}