phug-php/dev-tool

View on GitHub
src/Phug/DevTool/Command/CodeStyleCheckCommand.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method execute has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $helper = $this->getHelper('question');
        $args = [
            '--standard'   => $this->getApplication()->getConfigFilePath('phpcs.xml'),
Severity: Minor
Found in src/Phug/DevTool/Command/CodeStyleCheckCommand.php - About 1 hr to fix

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

        protected function execute(InputInterface $input, OutputInterface $output)
        {
            $helper = $this->getHelper('question');
            $args = [
                '--standard'   => $this->getApplication()->getConfigFilePath('phpcs.xml'),
    Severity: Minor
    Found in src/Phug/DevTool/Command/CodeStyleCheckCommand.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 $code;
    Severity: Major
    Found in src/Phug/DevTool/Command/CodeStyleCheckCommand.php - About 30 mins to fix

      Avoid assigning values to variables in if clauses and the like (line '67', column '14').
      Open

          protected function execute(InputInterface $input, OutputInterface $output)
          {
              $helper = $this->getHelper('question');
              $args = [
                  '--standard'   => $this->getApplication()->getConfigFilePath('phpcs.xml'),

      IfStatementAssignment

      Since: 2.7.0

      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($foo = 'bar') { // possible typo
                  // ...
              }
              if ($baz = 0) { // always false
                  // ...
              }
          }
      }

      Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

      Avoid assigning values to variables in if clauses and the like (line '40', column '14').
      Open

          protected function execute(InputInterface $input, OutputInterface $output)
          {
              $helper = $this->getHelper('question');
              $args = [
                  '--standard'   => $this->getApplication()->getConfigFilePath('phpcs.xml'),

      IfStatementAssignment

      Since: 2.7.0

      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($foo = 'bar') { // possible typo
                  // ...
              }
              if ($baz = 0) { // always false
                  // ...
              }
          }
      }

      Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

      Call to method __construct from undeclared class \Symfony\Component\Console\Question\ConfirmationQuestion
      Open

              if (!$helper->ask($input, $output, new ConfirmationQuestion(

      Reference to constant VALUE_NONE from undeclared class \Symfony\Component\Console\Input\InputOption
      Open

                  ->addOption('ignore-tests', null, InputOption::VALUE_NONE, 'Ignore /tests/ directories')

      Call to method __construct from undeclared class \Symfony\Component\Console\Question\ConfirmationQuestion
      Open

              if (!$helper->ask($input, $output, new ConfirmationQuestion(

      Reference to constant VALUE_NONE from undeclared class \Symfony\Component\Console\Input\InputOption
      Open

                  ->addOption('ignore-debug', null, InputOption::VALUE_NONE, 'Ignore /debug/ directories')

      Parameter $input has undeclared type \Symfony\Component\Console\Input\InputInterface
      Open

          protected function execute(InputInterface $input, OutputInterface $output)

      Call to method writeln from undeclared class \Symfony\Component\Console\Output\OutputInterface
      Open

                  $output->writeln('<fg=green>Code looks great. Go on!</>');

      Call to undeclared method \Phug\DevTool\Command\CodeStyleCheckCommand::setName
      Open

              $this->setName('code-style:check')

      Call to method writeln from undeclared class \Symfony\Component\Console\Output\OutputInterface
      Open

                  $output->writeln('You can always fix code-style problems by running the [code-style:fix] command.');

      Call to method writeln from undeclared class \Symfony\Component\Console\Output\OutputInterface
      Open

              $output->writeln('<fg=green>All fixable problems have been fixed.</>');

      Parameter $output has undeclared type \Symfony\Component\Console\Output\OutputInterface
      Open

          protected function execute(InputInterface $input, OutputInterface $output)

      Call to undeclared method \Phug\DevTool\Command\CodeStyleCheckCommand::getHelper
      Open

              $helper = $this->getHelper('question');

      Call to method writeln from undeclared class \Symfony\Component\Console\Output\OutputInterface
      Open

              $output->writeln(

      Call to method getOption from undeclared class \Symfony\Component\Console\Input\InputInterface
      Open

              if ($input->getOption('ignore-tests')) {

      Call to method getOption from undeclared class \Symfony\Component\Console\Input\InputInterface
      Open

              if ($input->getOption('ignore-debug')) {

      Call to method writeln from undeclared class \Symfony\Component\Console\Output\OutputInterface
      Open

                  $output->writeln('<fg=green>Code looks great. Go on!</>');

      There are no issues that match your filters.

      Category
      Status