-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from nextcloud/enh/add-psalm
Add psalm check action
- Loading branch information
Showing
49 changed files
with
417 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# This workflow is provided via the organization template repository | ||
# | ||
# https://github.com/nextcloud/.github | ||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization | ||
|
||
name: Psalm static analysis | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- .github/workflows/psalm.yml | ||
- appinfo/** | ||
- composer.* | ||
- lib/** | ||
- templates/** | ||
- tests/** | ||
push: | ||
branches: | ||
- main | ||
- stable* | ||
- test | ||
paths: | ||
- .github/workflows/psalm.yml | ||
- appinfo/** | ||
- composer.* | ||
- lib/** | ||
- templates/** | ||
- tests/** | ||
|
||
concurrency: | ||
group: psalm-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
static-analysis: | ||
runs-on: ubuntu-latest | ||
|
||
name: Psalm check | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | ||
|
||
- name: Set up php | ||
uses: shivammathur/setup-php@c5fc0d8281aba02c7fda07d3a70cc5371548067d # v2 | ||
with: | ||
php-version: 8.2 | ||
coverage: none | ||
ini-file: development | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Install dependencies | ||
run: composer i | ||
|
||
- name: Run coding standards check | ||
run: composer run psalm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,18 +3,18 @@ | |
// SPDX-FileCopyrightText: Sami Finnilä <[email protected]> | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
namespace OCA\TPAssistant\Command; | ||
namespace OCA\TpAssistant\Command; | ||
|
||
use Exception; | ||
use OCA\TPAssistant\AppInfo\Application; | ||
use OCA\TPAssistant\Service\Text2Image\CleanUpService; | ||
use OC\Core\Command\Base; | ||
use OCA\TpAssistant\AppInfo\Application; | ||
use OCA\TpAssistant\Service\Text2Image\CleanUpService; | ||
use OCP\IConfig; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class CleanupImageGenerations extends Command { | ||
class CleanupImageGenerations extends Base { | ||
public function __construct( | ||
private CleanUpService $cleanUpService, | ||
private IConfig $config | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,10 @@ | |
// SPDX-FileCopyrightText: Sami Finnilä <[email protected]> | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
namespace OCA\TPAssistant\Controller; | ||
namespace OCA\TpAssistant\Controller; | ||
|
||
use Exception; | ||
use OCA\TPAssistant\Service\FreePrompt\FreePromptService; | ||
use OCA\TpAssistant\Service\FreePrompt\FreePromptService; | ||
use OCP\AppFramework\Controller; | ||
use OCP\AppFramework\Http; | ||
use OCP\AppFramework\Http\Attribute\NoAdminRequired; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,11 @@ | |
// SPDX-FileCopyrightText: Sami Finnilä <[email protected]> | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
namespace OCA\TPAssistant\Controller; | ||
namespace OCA\TpAssistant\Controller; | ||
|
||
use Exception; | ||
use OCA\TPAssistant\AppInfo\Application; | ||
use OCA\TPAssistant\Service\Text2Image\Text2ImageHelperService; | ||
use OCA\TpAssistant\AppInfo\Application; | ||
use OCA\TpAssistant\Service\Text2Image\Text2ImageHelperService; | ||
use OCP\AppFramework\Controller; | ||
use OCP\AppFramework\Http; | ||
use OCP\AppFramework\Http\Attribute\AnonRateLimit; | ||
|
@@ -83,8 +83,8 @@ public function getImage(string $imageGenId, int $fileNameId): DataDisplayRespon | |
try { | ||
$result = $this->text2ImageHelperService->getImage($imageGenId, $fileNameId); | ||
} catch (Exception $e) { | ||
$response = new DataResponse(['error' => $e->getMessage()], $e->getCode()); | ||
if ($e->getCode() === Http::STATUS_BAD_REQUEST | Http::STATUS_UNAUTHORIZED) { | ||
$response = new DataResponse(['error' => $e->getMessage()], (int) $e->getCode()); | ||
if ($e->getCode() === Http::STATUS_BAD_REQUEST || $e->getCode() === Http::STATUS_UNAUTHORIZED) { | ||
// Throttle brute force attempts | ||
$response->throttle(['action' => 'imageGenId']); | ||
} | ||
|
@@ -114,8 +114,8 @@ public function getGenerationInfo(string $imageGenId): DataResponse { | |
try { | ||
$result = $this->text2ImageHelperService->getGenerationInfo($imageGenId, true); | ||
} catch (Exception $e) { | ||
$response = new DataResponse(['error' => $e->getMessage()], $e->getCode()); | ||
if ($e->getCode() === Http::STATUS_BAD_REQUEST | Http::STATUS_UNAUTHORIZED) { | ||
$response = new DataResponse(['error' => $e->getMessage()], (int) $e->getCode()); | ||
if ($e->getCode() === Http::STATUS_BAD_REQUEST || $e->getCode() === Http::STATUS_UNAUTHORIZED) { | ||
// Throttle brute force attempts | ||
$response->throttle(['action' => 'imageGenId']); | ||
} | ||
|
@@ -140,8 +140,8 @@ public function setVisibilityOfImageFiles(string $imageGenId, array $fileVisStat | |
try { | ||
$this->text2ImageHelperService->setVisibilityOfImageFiles($imageGenId, $fileVisStatusArray); | ||
} catch (Exception $e) { | ||
$response = new DataResponse(['error' => $e->getMessage()], $e->getCode()); | ||
if($e->getCode() === Http::STATUS_BAD_REQUEST | Http::STATUS_UNAUTHORIZED) { | ||
$response = new DataResponse(['error' => $e->getMessage()], (int) $e->getCode()); | ||
if($e->getCode() === Http::STATUS_BAD_REQUEST || $e->getCode() === Http::STATUS_UNAUTHORIZED) { | ||
// Throttle brute force attempts | ||
$response->throttle(['action' => 'imageGenId']); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,11 @@ | |
// SPDX-FileCopyrightText: Sami Finnilä <[email protected]> | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
namespace OCA\TPAssistant\Cron; | ||
namespace OCA\TpAssistant\Cron; | ||
|
||
use Exception; | ||
use OCA\TPAssistant\Db\Text2Image\ImageGenerationMapper; | ||
use OCA\TPAssistant\Service\Text2Image\CleanUpService; | ||
use OCA\TpAssistant\Db\Text2Image\ImageGenerationMapper; | ||
use OCA\TpAssistant\Service\Text2Image\CleanUpService; | ||
use OCP\AppFramework\Utility\ITimeFactory; | ||
use OCP\BackgroundJob\TimedJob; | ||
use Psr\Log\LoggerInterface; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
// SPDX-FileCopyrightText: Sami Finnilä <[email protected]> | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
namespace OCA\TPAssistant\Db\FreePrompt; | ||
namespace OCA\TpAssistant\Db\FreePrompt; | ||
|
||
use OCP\AppFramework\Db\Entity; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
// SPDX-FileCopyrightText: Sami Finnilä <[email protected]> | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
namespace OCA\TPAssistant\Db\Text2Image; | ||
namespace OCA\TpAssistant\Db\Text2Image; | ||
|
||
use OCP\AppFramework\Db\Entity; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,17 +4,18 @@ | |
// SPDX-FileCopyrightText: Sami Finnilä <[email protected]> | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
namespace OCA\TPAssistant\Db\Text2Image; | ||
namespace OCA\TpAssistant\Db\Text2Image; | ||
|
||
use OCP\AppFramework\Db\DoesNotExistException; | ||
use OCP\AppFramework\Db\Entity; | ||
use OCP\AppFramework\Db\MultipleObjectsReturnedException; | ||
use OCP\AppFramework\Db\QBMapper; | ||
use OCP\DB\Exception; | ||
use OCP\DB\QueryBuilder\IQueryBuilder; | ||
use OCP\IDBConnection; | ||
|
||
/** | ||
* @implements QBMapper<ImageFileName> | ||
* @extends QBMapper<ImageFileName> | ||
*/ | ||
class ImageFileNameMapper extends QBMapper { | ||
public function __construct(IDBConnection $db) { | ||
|
@@ -81,11 +82,9 @@ public function setFileNameHidden(int $fileNameId, bool $hidden = true): int { | |
/** | ||
* @param int $generationId | ||
* @param int $fileNameId | ||
* @return ImageFileName|null | ||
* | ||
* @return ImageFileName|Entity|null | ||
*/ | ||
|
||
public function getImageFileNameOfGenerationId(int $generationId, int $fileNameId): ImageFileName | null { | ||
public function getImageFileNameOfGenerationId(int $generationId, int $fileNameId): ImageFileName|Entity|null { | ||
$qb = $this->db->getQueryBuilder(); | ||
|
||
$qb->select('file_name') | ||
|
@@ -106,21 +105,16 @@ public function getImageFileNameOfGenerationId(int $generationId, int $fileNameI | |
/** | ||
* @param int $generationId | ||
* @param string $fileName | ||
* @param string $prompt | ||
* @return ImageFileName | ||
* @return ImageFileName|Entity | ||
* @throws Exception | ||
*/ | ||
public function createImageFileName(int $generationId, string $fileName): ImageFileName { | ||
public function createImageFileName(int $generationId, string $fileName): ImageFileName|Entity { | ||
$imageFile = new ImageFileName(); | ||
$imageFile->setGenerationId($generationId); | ||
$imageFile->setFileName($fileName); | ||
return $this->insert($imageFile); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
|
||
/** | ||
* @param int $generationId | ||
* @return void | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
// SPDX-FileCopyrightText: Sami Finnilä <[email protected]> | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
namespace OCA\TPAssistant\Db\Text2Image; | ||
namespace OCA\TpAssistant\Db\Text2Image; | ||
|
||
use OCP\AppFramework\Db\Entity; | ||
|
||
|
Oops, something went wrong.