AJenbo/php-tracer-weaver

View on GitHub

Showing 20 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 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_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 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

          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

            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

              Avoid too many return statements within this method.
              Open

                          return 'float';
              Severity: Major
              Found in src/PHPWeaver/Xtrace/TraceSignatureLogger.php - About 30 mins to fix

                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

                  Avoid too many return statements within this method.
                  Open

                                  return 'int';
                  Severity: Major
                  Found in src/PHPWeaver/Xtrace/TraceSignatureLogger.php - About 30 mins to fix

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

                        public function processLine(string $line): void
                        {
                            /** @var array<int, string> */
                            $entry = str_getcsv($line, "\t");
                    
                    
                    Severity: Minor
                    Found in src/PHPWeaver/Xtrace/TraceReader.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 parseTrace has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function parseTrace(string $tracefile): Signatures
                        {
                            $sigs = new Signatures();
                            if (is_file($tracefile)) {
                                $traceFile = new SplFileObject($tracefile);
                    Severity: Minor
                    Found in src/PHPWeaver/Command/WeaveCommand.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 accept has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function accept(Token $token): void
                        {
                            if ($token->isA(T_INTERFACE) || $token->isA(T_CLASS)) {
                                $this->state = 1;
                    
                    
                    Severity: Minor
                    Found in src/PHPWeaver/Scanner/ClassScanner.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 accept has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function accept(Token $token): void
                        {
                            if ($token->isA(T_FUNCTION)) {
                                $this->currentClassScope = $token->getDepth();
                                $this->state = 1;
                    Severity: Minor
                    Found in src/PHPWeaver/Scanner/FunctionBodyScanner.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 transformFiles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function transformFiles(array $filesToWeave, Signatures $sigs): void
                        {
                            $this->progressBarStart(count($filesToWeave), '<info>Updating source files …</info>');
                    
                            foreach ($filesToWeave as $fileToWeave) {
                    Severity: Minor
                    Found in src/PHPWeaver/Command/WeaveCommand.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

                    Severity
                    Category
                    Status
                    Source
                    Language