Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix retrieving composer binary path in SyntaxCheck #505

Merged

Conversation

Jibbarth
Copy link
Collaborator

Q A
Bug fix? yes
New feature? no
Fixed tickets Fix #504

As @tarlepp indicate in #504, when we install phpinsights through bamarni composer plugin, the SyntaxCheck Insight is unable to find the correct path for using parallel-lint.

This PR should fix that

@Jibbarth Jibbarth added the bug Something isn't working label Jun 21, 2021
@jeremyFreeAgent
Copy link

Thanks!

@Jibbarth Jibbarth merged commit 2f16695 into nunomaduro:master Jul 11, 2021
@Jibbarth Jibbarth deleted the fix/find-parallel-lint-with-bamarni-plugin branch July 11, 2021 13:21
@deleugpn
Copy link
Contributor

Any chance this patch has not been included on the Docker images?

[12:01 PM]-[root@alpine314]-[/home/workspace/project]-[git extra-segments]
# docker run -it --rm -v "$(pwd):/app" nunomaduro/phpinsights -v

 594/597 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░]  99% 4 secs

In SyntaxCheck.php line 56:

  [JsonException (4)]
  Syntax error


Exception trace:
  at /phpinsights/src/Domain/Insights/SyntaxCheck.php:56
 json_decode() at /phpinsights/src/Domain/Insights/SyntaxCheck.php:56
 NunoMaduro\PhpInsights\Domain\Insights\SyntaxCheck->process() at /phpinsights/src/Domain/Runner.php:164
 NunoMaduro\PhpInsights\Domain\Runner->run() at /phpinsights/src/Domain/Insights/InsightFactory.php:98
 NunoMaduro\PhpInsights\Domain\Insights\InsightFactory->runInsightCollector() at /phpinsights/src/Domain/Insights/InsightFactory.php:69
 NunoMaduro\PhpInsights\Domain\Insights\InsightFactory->makeFrom() at /phpinsights/src/Domain/Insights/InsightCollectionFactory.php:67
 NunoMaduro\PhpInsights\Domain\Insights\InsightCollectionFactory::NunoMaduro\PhpInsights\Domain\Insights\{closure}() at n/a:n/a
 array_map() at /phpinsights/src/Domain/Insights/InsightCollectionFactory.php:68
 NunoMaduro\PhpInsights\Domain\Insights\InsightCollectionFactory->get() at /phpinsights/src/Application/Console/Analyser.php:36
 NunoMaduro\PhpInsights\Application\Console\Analyser->analyse() at /phpinsights/src/Application/Console/Commands/AnalyseCommand.php:65
 NunoMaduro\PhpInsights\Application\Console\Commands\AnalyseCommand->__invoke() at n/a:n/a
 call_user_func() at /phpinsights/src/Application/Console/Commands/InvokableCommand.php:41
 NunoMaduro\PhpInsights\Application\Console\Commands\InvokableCommand->execute() at /phpinsights/vendor/symfony/console/Command/Command.php:299
 Symfony\Component\Console\Command\Command->run() at /phpinsights/vendor/symfony/console/Application.php:978
 Symfony\Component\Console\Application->doRunCommand() at /phpinsights/vendor/symfony/console/Application.php:295
 Symfony\Component\Console\Application->doRun() at /phpinsights/vendor/symfony/console/Application.php:167
 Symfony\Component\Console\Application->run() at /phpinsights/bin/phpinsights:42
 {closure}() at /phpinsights/bin/phpinsights:43

analyse [-c|--config-path [CONFIG-PATH]] [-s|--summary] [--min-quality [MIN-QUALITY]] [--min-complexity [MIN-COMPLEXITY]] [--min-architecture [MIN-ARCHITECTURE]] [--min-style [MIN-STYLE]] [--disable-security-check] [--format FORMAT] [--composer [COMPOSER]] [--fix] [--flush-cache] [--] [<paths>...]
# docker images | grep insights
12:nunomaduro/phpinsights                                          latest    0dd2deddd099   2 weeks ago    120MB

$baseProjectPath = \dirname(__DIR__, 3);
if (file_exists($baseProjectPath . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php')) {
return $baseProjectPath;
$composerBinaryFolder = DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vendor/bin shouldn't be hardcoded, it should respect composer's config.bin-dir setting.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/nunomaduro/phpinsights/pull/505/files#R44
Maybe use composer exec -- <bin> here to ensure parallel-lint is in the $PATH and let composer handle finding the bin dir?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Syntax error - In SyntaxCheck.php line 57
4 participants