Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .phpqa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ psalm:
deptrac:
depfile: null # depfile.yml (https://github.com/qossmic/deptrac#the-depfile)

security-checker:
composerLock: null # use it if composer.lock is not in current working directory or analyzed directory

# paths are relative to .phpqa.yml, so don't copy-paste this section if you don't have custom templates
report:
phploc: app/report/phploc.xsl
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ Tool | Settings | Default Value | Your value
[psalm.showInfo](https://github.com/vimeo/psalm/wiki/Running-Psalm#command-line-options) | Display or not information (non-error) messages (option `--show-info=` of psalm) | `true` | Boolean value
[psalm.memoryLimit](https://github.com/vimeo/psalm/issues/842) | Custom memory limit, ignore unless you are getting `Fatal error: Allowed memory size of ... bytes exhausted` | `null` | String value, e.g. `'1024M'`, `'1G'`
[deptrac.depfile](https://github.com/vimeo/psalm/wiki/Configuration) | Complete [deptract config](https://github.com/qossmic/deptrac#getting-started) _(phpqa won't update source and excluded files)_ | `null` | Path to `depfile.yml` file
[composer.lock](https://github.com/EdgedesignCZ/phpqa/blob/master/.phpqa.yml#L94) | Use it if composer.lock is not in current working directory or analyzed directory | `null` | Path to `composer.lock` file

## HTML reports

Expand Down
22 changes: 15 additions & 7 deletions src/Tools/Analyzer/SecurityChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,26 @@ class SecurityChecker extends \Edge\QA\Tools\Tool

public function __invoke()
{
$composerLock = getcwd() . "/composer.lock";
$composerLockFromConfig = $this->config->path('security-checker.composerLock');
$composerLock = file_exists($composerLockFromConfig)
? $composerLockFromConfig
: $this->detectComposerLock();

return [
'security:check',
$composerLock,
];
}

private function detectComposerLock()
{
foreach ($this->options->getAnalyzedDirs() as $escapedDir) {
$dir = rtrim(trim($escapedDir, '"'), '/');
$path = "{$dir}/composer.lock";
if (file_exists($path)) {
$composerLock = $path;
break;
return $path;
}
}
return [
'security:check',
$composerLock,
];
return getcwd() . '/composer.lock';
}
}
1 change: 1 addition & 0 deletions tests/Config/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function testLoadDefaultConfig()
assertThat($config->value('phpmetrics.git'), identicalTo(false));
assertThat($config->value('pdepend.coverageReport'), is(nullValue()));
assertThat($config->value('deptrac.depfile'), is(nullValue()));
assertThat($config->value('security-checker.composerLock'), is(nullValue()));
}

public function testBuildAbsolutePath()
Expand Down