vaimo/composer-patches

View on GitHub
src/Patch/File/Applier.php

Summary

Maintainability
C
7 hrs
Test Coverage

Method applyFile has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function applyFile($filename, $cwd, array $config = array())
    {
        $applierConfig = $this->applierUtils->mergeApplierConfig($this->config, array_filter($config));
        $applierConfig = $this->applierUtils->sortApplierConfig($applierConfig);
        $patchers = $this->extractArrayValue($applierConfig, PluginConfig::PATCHER_APPLIERS);
Severity: Major
Found in src/Patch/File/Applier.php - About 2 hrs to fix

    Method resolveOperationOutput has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function resolveOperationOutput($applierOperations, $args, $operationFailures)
        {
            $variableFormats = array(
                '{{%s}}' => array('escapeshellarg'),
                '[[%s]]' => array()
    Severity: Minor
    Found in src/Patch/File/Applier.php - About 1 hr to fix

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

          private function resolveOperationOutput($applierOperations, $args, $operationFailures)
          {
              $variableFormats = array(
                  '{{%s}}' => array('escapeshellarg'),
                  '[[%s]]' => array()
      Severity: Minor
      Found in src/Patch/File/Applier.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 validateOutput has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function validateOutput($output, $operationFailures)
          {
              $pathMarker = '\|\+\+\+\s(?P<match>.*?)(\t|$)';
              $pathMatcher = sprintf('/^%s/', $pathMarker);
      
      
      Severity: Minor
      Found in src/Patch/File/Applier.php - About 1 hr to fix

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

            private function processOperationItems($patcher, $operations, $args, $failures)
            {
                $operationResults = array_fill_keys(array_keys($operations), '');
                $result = true;
        
        
        Severity: Minor
        Found in src/Patch/File/Applier.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 validateOutput has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            private function validateOutput($output, $operationFailures)
            {
                $pathMarker = '\|\+\+\+\s(?P<match>.*?)(\t|$)';
                $pathMatcher = sprintf('/^%s/', $pathMarker);
        
        
        Severity: Minor
        Found in src/Patch/File/Applier.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

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

            private function executeOperations(
                array $patchers,
                array $operations,
                array $args = array(),
                array $failures = array()
        Severity: Minor
        Found in src/Patch/File/Applier.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 applyFile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function applyFile($filename, $cwd, array $config = array())
            {
                $applierConfig = $this->applierUtils->mergeApplierConfig($this->config, array_filter($config));
                $applierConfig = $this->applierUtils->sortApplierConfig($applierConfig);
                $patchers = $this->extractArrayValue($applierConfig, PluginConfig::PATCHER_APPLIERS);
        Severity: Minor
        Found in src/Patch/File/Applier.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

        Missing class import via use statement (line '64', column '28').
        Open

                $this->shell = new \Vaimo\ComposerPatches\Shell($logger);
        Severity: Minor
        Found in src/Patch/File/Applier.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 '104', column '23').
        Open

                    throw new \Vaimo\ComposerPatches\Exceptions\RuntimeException($message);
        Severity: Minor
        Found in src/Patch/File/Applier.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 '304', column '24').
        Open

                $failure = new \Vaimo\ComposerPatches\Exceptions\OperationFailure('Output analysis failed');
        Severity: Minor
        Found in src/Patch/File/Applier.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 '203', column '28').
        Open

                    $failure = new \Vaimo\ComposerPatches\Exceptions\OperationFailure($operationCode);
        Severity: Minor
        Found in src/Patch/File/Applier.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 '65', column '35').
        Open

                $this->applierUtils = new \Vaimo\ComposerPatches\Utils\ConfigUtils();
        Severity: Minor
        Found in src/Patch/File/Applier.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 '66', column '36').
        Open

                $this->templateUtils = new \Vaimo\ComposerPatches\Utils\TemplateUtils();
        Severity: Minor
        Found in src/Patch/File/Applier.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 '67', column '37').
        Open

                $this->outputAnalyser = new \Vaimo\ComposerPatches\Console\OutputAnalyser();
        Severity: Minor
        Found in src/Patch/File/Applier.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 '68', column '42').
        Open

                $this->applierErrorFactory = new \Vaimo\ComposerPatches\Factories\ApplierErrorFactory();
        Severity: Minor
        Found in src/Patch/File/Applier.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 '131', column '24').
        Open

                $failure = new \Vaimo\ComposerPatches\Exceptions\ApplierFailure(
        Severity: Minor
        Found in src/Patch/File/Applier.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

        Argument 2 (vars) is array but \sprintf() takes float|int|string
        Open

                    $resultKey = sprintf('%s | %s', $cwd, $command);
        Severity: Minor
        Found in src/Patch/File/Applier.php by phan

        Argument 2 (str) is false but \explode() takes string
        Open

                    $failure->setOutput(explode(PHP_EOL, $output));
        Severity: Minor
        Found in src/Patch/File/Applier.php by phan

        Argument 2 (cwd) is array but \Vaimo\ComposerPatches\Shell::execute() takes null|string defined at /code/src/Shell.php:37
        Open

                        $this->resultCache[$resultKey] = $this->shell->execute($command, $cwd);
        Severity: Minor
        Found in src/Patch/File/Applier.php by phan

        There are no issues that match your filters.

        Category
        Status