Skip to content

Commit

Permalink
SDK-2492 update checker
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyspryker committed Jul 31, 2023
1 parent 85bf019 commit 9fcdd8c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions config/checkers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ parameters:
minimum_allowed_shop_version_checker_doc_url: https://docs.spryker.com/docs/scos/dev/guidelines/keeping-a-project-upgradable/upgradability-guidelines/minimum-allowed-shop-version.html
minimum_allowed_shop_version_checker_version: '202204.0'
minimum_allowed_shop_version_checker_file: '%evaluator_dir%/data/minimum-allowed-package-versions.json'

# Npm checker
npm_checker_doc_url: https://docs.spryker.com/docs/scos/dev/guidelines/keeping-a-project-upgradable/upgradability-guidelines/npm-checker.html
4 changes: 4 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ services:
arguments:
$checkerDocUrl: '%single_plugin_argument_checker_doc_url%'

SprykerSdk\Evaluator\Checker\NpmChecker\NpmChecker:
arguments:
$checkerDocUrl: '%npm_checker_doc_url%'

# Third-party
PhpParser\ParserFactory: ~
Symfony\Component\Finder\Finder: ~
Expand Down
10 changes: 5 additions & 5 deletions src/Checker/NpmChecker/NpmAuditExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ public function executeNpmAudit(): array
return [];

Check warning on line 76 in src/Checker/NpmChecker/NpmAuditExecutor.php

View check run for this annotation

Codecov / codecov/patch

src/Checker/NpmChecker/NpmAuditExecutor.php#L75-L76

Added lines #L75 - L76 were not covered by tests
}

$stdOut = $process->getOutput();
$stdErr = $process->getErrorOutput();
$stdOut = trim($process->getOutput());
$stdErr = trim($process->getErrorOutput());

Check warning on line 80 in src/Checker/NpmChecker/NpmAuditExecutor.php

View check run for this annotation

Codecov / codecov/patch

src/Checker/NpmChecker/NpmAuditExecutor.php#L79-L80

Added lines #L79 - L80 were not covered by tests

if ($stdErr) {
throw new NpmExecutorException(sprintf('Out: %s Err: %s', $stdOut, $stdErr));
if ($stdErr && !$stdOut) {
throw new NpmExecutorException($stdErr);

Check warning on line 83 in src/Checker/NpmChecker/NpmAuditExecutor.php

View check run for this annotation

Codecov / codecov/patch

src/Checker/NpmChecker/NpmAuditExecutor.php#L82-L83

Added lines #L82 - L83 were not covered by tests
}

try {
Expand Down Expand Up @@ -149,7 +149,7 @@ protected function processViolationSource(array $violationSource, string $severi
$message = $violationSource[static::TITLE_KEY];

Check warning on line 149 in src/Checker/NpmChecker/NpmAuditExecutor.php

View check run for this annotation

Codecov / codecov/patch

src/Checker/NpmChecker/NpmAuditExecutor.php#L149

Added line #L149 was not covered by tests

if (isset($violationSource[static::URL_KEY])) {
$message .= PHP_EOL . $violationSource[static::TITLE_KEY];
$message .= PHP_EOL . $violationSource[static::URL_KEY];

Check warning on line 152 in src/Checker/NpmChecker/NpmAuditExecutor.php

View check run for this annotation

Codecov / codecov/patch

src/Checker/NpmChecker/NpmAuditExecutor.php#L151-L152

Added lines #L151 - L152 were not covered by tests
}

return new ViolationDto(sprintf('[%s] %s', $severity, $message), $target);

Check warning on line 155 in src/Checker/NpmChecker/NpmAuditExecutor.php

View check run for this annotation

Codecov / codecov/patch

src/Checker/NpmChecker/NpmAuditExecutor.php#L155

Added line #L155 was not covered by tests
Expand Down
2 changes: 1 addition & 1 deletion src/Checker/NpmChecker/NpmChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function check(CheckerInputDataDto $inputData): CheckerResponseDto
try {
$violations = $this->npmAuditExecutor->executeNpmAudit();
} catch (NpmExecutorException $e) {
$violations = [new ViolationDto(sprintf('Internal error: %s', $e->getMessage()))];
$violations = [new ViolationDto(sprintf('Npm issue: %s', $e->getMessage()))];

Check warning on line 69 in src/Checker/NpmChecker/NpmChecker.php

View check run for this annotation

Codecov / codecov/patch

src/Checker/NpmChecker/NpmChecker.php#L67-L69

Added lines #L67 - L69 were not covered by tests
}

return new CheckerResponseDto($violations, $this->checkerDocUrl);

Check warning on line 72 in src/Checker/NpmChecker/NpmChecker.php

View check run for this annotation

Codecov / codecov/patch

src/Checker/NpmChecker/NpmChecker.php#L72

Added line #L72 was not covered by tests
Expand Down

0 comments on commit 9fcdd8c

Please sign in to comment.