Skip to content

Commit

Permalink
[CI] Adds psalm to CI (#708)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasnorre authored Jan 16, 2021
1 parent 466ecec commit ce0ea8d
Show file tree
Hide file tree
Showing 16 changed files with 109 additions and 107 deletions.
53 changes: 37 additions & 16 deletions .github/workflows/StaticAnalysis.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Static Analysis

on: [push, pull_request]
on: [ push, pull_request ]

jobs:
phpstan:
Expand All @@ -27,21 +27,21 @@ jobs:
name: Rector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
- run: composer install --no-progress
- run: composer rector
- uses: actions/checkout@v2
- id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
- run: composer install --no-progress
- run: composer rector

code-style:
name: Code Style
Expand All @@ -62,3 +62,24 @@ jobs:
coverage: none
- run: composer install --no-progress
- run: composer cs-fix

Psalm:
name: Psalm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none

- run: composer install --no-scripts --no-progress
- run: .Build/bin/psalm --shepherd
3 changes: 3 additions & 0 deletions Classes/Backend/Helper/ResultHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public static function getResultLog($resultRow)
return $content;
}

/**
* @param array|bool $requestContent
*/
public static function getResStatus($requestContent): string
{
if (empty($requestContent)) {
Expand Down
8 changes: 5 additions & 3 deletions Classes/Backend/RequestForm/LogRequestForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ public function __construct(StandaloneView $view, InfoModuleController $infoModu
$this->queueRepository = $objectManager->get(QueueRepository::class);
}

public function render($id, string $currentValue, array $menuItems): string
public function render($id, string $elementName, array $menuItems): string
{
$quiPart = GeneralUtility::_GP('qid_details') ? '&qid_details=' . (int) GeneralUtility::_GP('qid_details') : '';
$setId = (int) GeneralUtility::_GP('setID');
$this->pageId = $id;

return $this->getDepthDropDownHtml($id, $currentValue, $menuItems)
return $this->getDepthDropDownHtml($id, $elementName, $menuItems)
. $this->showLogAction($setId, $quiPart);
}

Expand Down Expand Up @@ -313,8 +313,10 @@ private function getShowFeVarsCheckBoxHtml(int $setId, string $quiPart): string
*
* @param array $logEntriesOfPage Log items of one page
* @param string $titleString Title string
* @return string HTML <tr> content (one or more)
*
* @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
*
* @psalm-return non-empty-list<array{titleRowSpan: positive-int, colSpan: int, title: string, noEntries?: string, trClass?: string, qid?: array{link: \TYPO3\CMS\Core\Http\Uri, link-text: string}, refresh?: array{link: \TYPO3\CMS\Core\Http\Uri, link-text: Icon, warning: Icon|string}, columns?: array{url: mixed|string, scheduled: string, exec_time: string, result_log: string, result_status: string, feUserGroupList: string, procInstructions: string, set_id: string, tsfe_id: string, tsfe_gr_list: string}}>
*/
private function drawLog_addRows(array $logEntriesOfPage, string $titleString): array
{
Expand Down
1 change: 1 addition & 0 deletions Classes/Backend/RequestForm/MultiProcessRequestForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use AOE\Crawler\Domain\Repository\ProcessRepository;
use AOE\Crawler\Domain\Repository\QueueRepository;
use AOE\Crawler\Exception\ProcessException;
use AOE\Crawler\Hooks\CrawlerHookInterface;
use AOE\Crawler\Service\ProcessService;
use AOE\Crawler\Utility\MessageUtility;
use Psr\Http\Message\UriInterface;
Expand Down
6 changes: 3 additions & 3 deletions Classes/Command/BuildQueueCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$crawlerController->registerQueueEntriesInternallyOnly = true;
}

$pageId = MathUtility::forceIntegerInRange($input->getArgument('page'), 0);
$pageId = MathUtility::forceIntegerInRange((int) $input->getArgument('page'), 0);
if ($pageId === 0) {
$message = "Page ${pageId} is not a valid page, please check you root page id and try again.";
MessageUtility::addErrorMessage($message);
Expand Down Expand Up @@ -160,9 +160,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$crawlerController->setID = (int) GeneralUtility::md5int(microtime());
$crawlerController->getPageTreeAndUrls(
$pageId,
MathUtility::forceIntegerInRange($input->getOption('depth'), 0, 99),
MathUtility::forceIntegerInRange((int) $input->getOption('depth'), 0, 99),
$crawlerController->getCurrentTime(),
MathUtility::forceIntegerInRange($input->getOption('number') ?: 30, 1, 1000),
MathUtility::forceIntegerInRange((int) $input->getOption('number') ?: 30, 1, 1000),
$mode === 'queue' || $mode === 'exec',
$mode === 'url',
[],
Expand Down
3 changes: 2 additions & 1 deletion Classes/Configuration/ExtensionConfigurationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ class ExtensionConfigurationProvider implements LoggerAwareInterface

/**
* Return full extension configuration array.
* @return mixed|array
*/
public function getExtensionConfiguration(): array
public function getExtensionConfiguration()
{
try {
return GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('crawler');
Expand Down
5 changes: 3 additions & 2 deletions Classes/Controller/CrawlerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ public function drawURLs_PIfilter($piString, array $incomingProcInstructions)
return false;
}

public function getPageTSconfigForId($id): array
public function getPageTSconfigForId(int $id): array
{
if (! $this->MP) {
$pageTSconfig = BackendUtility::getPagesTSconfig($id);
Expand Down Expand Up @@ -1175,7 +1175,8 @@ public function getCurrentTime()
*
* @param integer $queueId
* @param boolean $force If set, will process even if exec_time has been set!
* @return integer
*
* @return int|null
*/
public function readUrl($queueId, $force = false)
{
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function setBaseUrl($baseUrl): void
$this->baseUrl = $baseUrl;
}

public function getPidsOnly()
public function getPidsOnly(): string
{
return $this->pidsonly;
}
Expand Down
3 changes: 2 additions & 1 deletion Classes/Hooks/IndexedSearchCrawlerHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,8 @@ public function getUidRootLineForClosestTemplate($id)
* Generate the unix time stamp for next visit.
*
* @param array $cfgRec Index configuration record
* @return int The next time stamp
*
* @return float|int The next time stamp
*/
public function generateNextIndexingTime($cfgRec)
{
Expand Down
2 changes: 1 addition & 1 deletion Classes/Hooks/ProcessCleanUpHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private function doProcessStillExists($pid)
} else {
// Windows
exec('tasklist | find "' . $pid . '"', $returnArray, $returnValue);
if (count($returnArray) > 0 && preg_match('/php/i', $returnValue[0])) {
if (count($returnArray) > 0 && stripos($returnArray[0], 'php') !== false) {
$doProcessStillExists = true;
}
}
Expand Down
1 change: 1 addition & 0 deletions Classes/QueueExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use AOE\Crawler\Controller\CrawlerController;
use AOE\Crawler\Converter\JsonCompatibilityConverter;
use AOE\Crawler\CrawlStrategy\CallbackExecutionStrategy;
use AOE\Crawler\CrawlStrategy\CrawlStrategy;
use AOE\Crawler\CrawlStrategy\CrawlStrategyFactory;
use AOE\Crawler\Utility\SignalSlotUtility;
use TYPO3\CMS\Core\Http\Uri;
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/AOEpeople/crawler/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/AOEpeople/crawler/?branch=main)
[![Code Coverage](https://scrutinizer-ci.com/g/AOEpeople/crawler/badges/coverage.png?b=main)](https://scrutinizer-ci.com/g/AOEpeople/crawler/?branch=main)
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FAOEpeople%2Fcrawler%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/AOEpeople/crawler/main)
![Psalm coverage](https://shepherd.dev/github/psalm/shepherd/coverage.svg)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/aoepeople/crawler.svg)](http://isitmaintained.com/project/aoepeople/crawler "Average time to resolve an issue")
[![Percentage of issues still open](http://isitmaintained.com/badge/open/aoepeople/crawler.svg)](http://isitmaintained.com/project/aoepeople/crawler "Percentage of issues still open")

Expand Down
13 changes: 12 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"slam/phpstan-extensions": "^5.0",
"symfony/yaml": "^4.4 || ^5.0",
"symplify/easy-coding-standard": "^8.3",
"typo3/testing-framework": "^4.14 || ^5.0"
"typo3/testing-framework": "^4.14 || ^5.0",
"vimeo/psalm": "^4.4"
},
"config": {
"bin-dir": ".Build/bin",
Expand Down Expand Up @@ -123,6 +124,16 @@
"[ -e .Build/bin/rector ] || composer update",
".Build/bin/rector process --dry-run --config rector-ci.php"
],
"psalm": [
"[ -e .Build/bin/psalm ] || composer update",
".Build/bin/psalm"
],
"static": [
"@analyse",
"@psalm",
"@cs-fix",
"@rector"
],
"test:acceptance": [
"[ -e .Build/bin/codecept ] || composer update",
".Build/bin/codecept run"
Expand Down
Loading

0 comments on commit ce0ea8d

Please sign in to comment.