AJenbo/php-tracer-weaver

View on GitHub

Showing 30 of 30 total issues

Function getFilesToProcess has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function getFilesToProcess(array $pathsToWeave): array
    {
        $filesToWeave = [];

        foreach ($pathsToWeave as $pathToWeave) {
Severity: Minor
Found in src/PHPWeaver/Command/WeaveCommand.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 execute has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $tracefile = $input->getOption('tracefile');
        if (!is_string($tracefile)) {
            return self::RETURN_CODE_ERROR;
Severity: Minor
Found in src/PHPWeaver/Command/TraceCommand.php - About 1 hr to fix

    Function parseType has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public function parseType(string $type): string
        {
            if (isset($this->typeMapping[$type])) {
                return $this->typeMapping[$type];
            }
    Severity: Minor
    Found in src/PHPWeaver/Xtrace/TraceSignatureLogger.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 setupFileProcesser has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function setupFileProcesser(Signatures $sigs): void
        {
            $this->scanner = new ScannerMultiplexer();
            $parametersScanner = new FunctionParametersScanner();
            $functionBodyScanner = new FunctionBodyScanner();
    Severity: Minor
    Found in src/PHPWeaver/Command/WeaveCommand.php - About 1 hr to fix

      Method generateDoc has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function generateDoc(string $func, string $class = '', array $params = [], string $namespace = ''): ?string
          {
              if ((!$params && ('__construct' === $func || '__destruct' === $func))
                  || !$this->signatures->has($func, $class, $namespace)
              ) {
      Severity: Minor
      Found in src/PHPWeaver/Transform/TracerDocBlockEditor.php - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

                if ($token->isA(T_DOC_COMMENT)) {
                    $this->state = 1;
                    $this->raiseBuffer();
                } elseif (0 === $this->state && ($this->modifiersScanner->isActive() || $token->isA(T_FUNCTION))) {
                    $this->state = 1;
        Severity: Major
        Found in src/PHPWeaver/Transform/DocCommentEditorTransformer.php - About 1 hr to fix

          Function accept has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public function accept(Token $token): void
              {
                  if ($token->isA(T_FUNCTION)) {
                      $this->state = 1;
                  } elseif (1 === $this->state && '(' === $token->getText()) {
          Severity: Minor
          Found in src/PHPWeaver/Scanner/FunctionParametersScanner.php - About 55 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 generateDoc has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public function generateDoc(string $func, string $class = '', array $params = [], string $namespace = ''): ?string
              {
                  if ((!$params && ('__construct' === $func || '__destruct' === $func))
                      || !$this->signatures->has($func, $class, $namespace)
                  ) {
          Severity: Minor
          Found in src/PHPWeaver/Transform/TracerDocBlockEditor.php - About 55 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 accept has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public function accept(Token $token): void
              {
                  if ($token->isA(T_DOC_COMMENT)) {
                      $this->state = 1;
                      $this->raiseBuffer();
          Severity: Minor
          Found in src/PHPWeaver/Transform/DocCommentEditorTransformer.php - About 55 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 variables with short names like $id. Configured minimum length is 3.
          Open

              public function markCallAsExited(int $id): 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 $id. Configured minimum length is 3.
          Open

              public function getArgumentById(int $id): FunctionArgument

          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 $id. Configured minimum length is 3.
          Open

              public function functionCall(int $id, string $function, array $arguments): 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 $id. Configured minimum length is 3.
          Open

              public function returnValue(int $id, string $value = 'void'): 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

          The class WeaveCommand has a coupling between objects value of 26. Consider to reduce the number of dependencies under 13.
          Open

          class WeaveCommand extends Command
          {
              const RETURN_CODE_OK = 0;
              const RETURN_CODE_ERROR = 1;
              const REFRESH_RATE_INTERVAL = 0.033333334; // 30hz

          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

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

                  Signatures $signatures,
                  ClassScanner $classScanner,
                  FunctionBodyScanner $functionBodyScanner,
                  FunctionParametersScanner $parametersScanner,
                  NamespaceScanner $namespaceScanner
          Severity: Minor
          Found in src/PHPWeaver/Transform/TracerDocBlockEditor.php - About 35 mins to fix

            Function scan has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function scan(string $source): TokenStream
                {
                    //todo: track indentation
                    $stream = new TokenStream();
                    $depth = 0;
            Severity: Minor
            Found in src/PHPWeaver/Scanner/TokenStreamParser.php - About 35 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

            The method getArrayType has a boolean flag argument $xdebug3, which is a certain sign of a Single Responsibility Principle violation.
            Open

                public function getArrayType(string $arrayType, bool $xdebug3 = false): string

            BooleanArgumentFlag

            Since: 1.4.0

            A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

            Example

            class Foo {
                public function bar($flag = true) {
                }
            }

            Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

            Avoid too many return statements within this method.
            Open

                    return self::RETURN_CODE_OK;
            Severity: Major
            Found in src/PHPWeaver/Command/TraceCommand.php - About 30 mins to fix

              The method getArrayElements has a boolean flag argument $xdebug3, which is a certain sign of a Single Responsibility Principle violation.
              Open

                  private function getArrayElements(string $type, bool $xdebug3 = false): array

              BooleanArgumentFlag

              Since: 1.4.0

              A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

              Example

              class Foo {
                  public function bar($flag = true) {
                  }
              }

              Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

              Avoid too many return statements within this method.
              Open

                          return 'string';
              Severity: Major
              Found in src/PHPWeaver/Xtrace/TraceSignatureLogger.php - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language