TikiWiki/tiki-manager

View on GitHub
src/Command/ImportInstanceCommand.php

Summary

Maintainability
C
1 day
Test Coverage

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

    protected function configure()
    {
        parent::configure();

        $this
Severity: Major
Found in src/Command/ImportInstanceCommand.php - About 4 hrs to fix

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

        protected function execute(InputInterface $input, OutputInterface $output)
        {
            $instance = new Instance();
            try {
                if ($input->isInteractive()) {
    Severity: Minor
    Found in src/Command/ImportInstanceCommand.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)
          {
              $instance = new Instance();
              try {
                  if ($input->isInteractive()) {
      Severity: Minor
      Found in src/Command/ImportInstanceCommand.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 configure() has 107 lines of code. Current threshold is set to 100. Avoid really long methods.
      Open

          protected function configure()
          {
              parent::configure();
      
              $this
      Severity: Minor
      Found in src/Command/ImportInstanceCommand.php by phpmd

      Missing class import via use statement (line '154', column '27').
      Open

                      throw new \Exception($error);
      Severity: Minor
      Found in src/Command/ImportInstanceCommand.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

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

      Missing class import via use statement (line '163', column '27').
      Open

                      throw new \Exception($error);
      Severity: Minor
      Found in src/Command/ImportInstanceCommand.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

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

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

          protected function execute(InputInterface $input, OutputInterface $output)
          {
              $instance = new Instance();
              try {
                  if ($input->isInteractive()) {
      Severity: Minor
      Found in src/Command/ImportInstanceCommand.php by phpmd

      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

      Argument 2 (log) is \Monolog\Logger but \TikiManager\Command\ImportInstanceCommand::isMissingPHPRequirements() takes \Psr\Log\LoggerInterface defined at /code/src/Command/Traits/InstanceConfigure.php:626
      Open

                  if (! $skipPhpCheck && $this->isMissingPHPRequirements($instance, $this->logger)) {
      Severity: Minor
      Found in src/Command/ImportInstanceCommand.php by phan

      Possibly zero references to use statement for classlike/namespace CommandHelper (\TikiManager\Command\Helper\CommandHelper)
      Open

      use TikiManager\Command\Helper\CommandHelper;
      Severity: Minor
      Found in src/Command/ImportInstanceCommand.php by phan

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

              $this
                  ->setName('instance:import')
                  ->setDescription('Import instance')
                  ->setHelp('This command allows you to import instances not yet managed by Tiki Manager')
                  ->addOption(
      Severity: Major
      Found in src/Command/ImportInstanceCommand.php and 1 other location - About 4 hrs to fix
      src/Command/EditInstanceCommand.php on lines 19..82

      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 182.

      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

      Further Reading

      There are no issues that match your filters.

      Category
      Status