diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0c9d8ce389562b51049bb3c73f9f1fb8421d779a..0000000000000000000000000000000000000000 --- a/.editorconfig +++ /dev/null @@ -1,64 +0,0 @@ -# EditorConfig is awesome: http://EditorConfig.org - -# top-most EditorConfig file -root = true - -# Unix-style newlines with a newline ending every file -[*] -charset = utf-8 -end_of_line = lf -indent_style = space -indent_size = 4 -insert_final_newline = true -trim_trailing_whitespace = true - -# TS/JS-Files -[*.{ts,js}] -indent_size = 2 - -# JSON-Files -[*.json] -indent_style = tab - -# ReST-Files -[*.{rst,rst.txt}] -indent_size = 4 -max_line_length = 80 - -# Markdown-Files -[*.md] -max_line_length = 80 - -# YAML-Files -[*.{yaml,yml}] -indent_size = 2 - -# CSS/SCSS-Files -[*.{css,scss}] -indent_size = 2 - -# NEON-Files -[*.neon] -indent_size = 2 -indent_style = tab - -# package.json -[package.json] -indent_size = 2 - -# TypoScript -[*.{typoscript,tsconfig}] -indent_size = 2 - -# XLF-Files -[*.xlf] -indent_style = tab - -# SQL-Files -[*.sql] -indent_style = tab -indent_size = 2 - -# .htaccess -[{_.htaccess,.htaccess}] -indent_style = tab diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d37c13256545d311d99855ab68bcd1365f9123de..22ded272c481fd03e7101f15525960a68e5b6835 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,13 +1,9 @@ +--- stages: - - build - lint + - build-app - test - - semver - release - - trigger include: - - project: 'gsb11/gitlab-scripts' - ref: main - file: 'default-extension.yml' - + - component: ${CI_SERVER_HOST}/gsb11/gitlab-ci-cd-components/gsb-extensions/build@1.0.4 diff --git a/.releaserc.yml b/.releaserc.yml index 454bcd80f4f6f2b7ca62c8272ce29dbb03eff099..769d194e4178fdf62af91354cb39b3ae9b56834c 100644 --- a/.releaserc.yml +++ b/.releaserc.yml @@ -1,3 +1,4 @@ +--- plugins: - - "@semantic-release/commit-analyzer" - preset: 'conventionalcommits' diff --git a/Classes/Configuration/ExtensionConfiguration.php b/Classes/Configuration/ExtensionConfiguration.php index 6fec1985fc8fe11e490271c3863a88df1849f635..3353c8f34d0b52d7fb5146a06519f43e7df7b26e 100644 --- a/Classes/Configuration/ExtensionConfiguration.php +++ b/Classes/Configuration/ExtensionConfiguration.php @@ -26,7 +26,6 @@ namespace ITZBund\GsbMetadataCleaner\Configuration; use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; -use RuntimeException; use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationExtensionNotConfiguredException; use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationPathDoesNotExistException; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration as CoreExtensionConfiguration; @@ -55,7 +54,7 @@ final class ExtensionConfiguration $exifToolPath = trim($this->extensionConfiguration->get('gsb_metadata_cleaner', 'exifToolPath')); if (!$this->utilityExistsAndIsSafe($exifToolPath, self::EXIFTOOL_BINARY)) { - throw new RuntimeException('exitfool path not properly configured', 1710517552); + throw new \RuntimeException('exitfool path not properly configured', 1710517552); } return $exifToolPath . self::EXIFTOOL_BINARY; @@ -71,7 +70,7 @@ final class ExtensionConfiguration $qpdfToolPath = trim($this->extensionConfiguration->get('gsb_metadata_cleaner', 'qpdfToolPath')); if (!$this->utilityExistsAndIsSafe($qpdfToolPath, self::QPDF_BINARY)) { - throw new RuntimeException('qpdf path not properly configured', 1710517551); + throw new \RuntimeException('qpdf path not properly configured', 1710517551); } return $qpdfToolPath . self::QPDF_BINARY; diff --git a/Classes/EventListener/BeforeFileAddedEventListener.php b/Classes/EventListener/BeforeFileAddedEventListener.php index 13b2e330efac3a2bb57f7ca3a9535a2592552b5c..ddb2d32de902c0fbb435ac6f1f8d4887ddf7806c 100644 --- a/Classes/EventListener/BeforeFileAddedEventListener.php +++ b/Classes/EventListener/BeforeFileAddedEventListener.php @@ -24,7 +24,6 @@ declare(strict_types=1); namespace ITZBund\GsbMetadataCleaner\EventListener; -use Exception; use ITZBund\GsbMetadataCleaner\Service\ExifToolService; use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; @@ -46,7 +45,7 @@ class BeforeFileAddedEventListener if ($this->exifToolService->canProcessFile($file)) { try { $this->exifToolService->removeMetadata($file); - } catch (Exception $re) { + } catch (\Exception $re) { $this->logger->log(LogLevel::ERROR, $re->getMessage()); } } diff --git a/Classes/Service/ExifToolService.php b/Classes/Service/ExifToolService.php index b53298bd55f6445aa291212a47660aff05b45392..5112402b34fff726618f885bb5156ebf76025a25 100644 --- a/Classes/Service/ExifToolService.php +++ b/Classes/Service/ExifToolService.php @@ -25,7 +25,6 @@ declare(strict_types=1); namespace ITZBund\GsbMetadataCleaner\Service; use Doctrine\DBAL\Exception; -use InvalidArgumentException; use ITZBund\GsbMetadataCleaner\Configuration\ExtensionConfiguration as GsbMetadataCleanerExtensionConfiguration; use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; @@ -34,7 +33,6 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Resource\FileInterface; use TYPO3\CMS\Core\Utility\CommandUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; -use UnexpectedValueException; class ExifToolService { @@ -82,13 +80,13 @@ class ExifToolService * * @param FileInterface $file the file to be processesed * - * @throws InvalidArgumentException + * @throws \InvalidArgumentException */ public function removeMetadata(FileInterface $file): void { $filePath = $file->getStorage()->getFileForLocalProcessing($file, false); if (!is_file($filePath) && !is_writable($filePath)) { - throw new InvalidArgumentException('File not writeable', 1701857184); + throw new \InvalidArgumentException('File not writeable', 1701857184); } $command = sprintf( '%s -overwrite_original -all= -tagsFromFile @ %s %s', @@ -128,13 +126,13 @@ class ExifToolService * This results in old tags beeing deleted for good and the pdf getting optimized for the web * * @param FileInterface $file the file to be processed - * @throws InvalidArgumentException + * @throws \InvalidArgumentException */ protected function linearizePdf(FileInterface $file): void { $filePath = $file->getStorage()->getFileForLocalProcessing($file, false); if (!is_file($filePath) && !is_writable($filePath)) { - throw new InvalidArgumentException('File not writeable', 1701857185); + throw new \InvalidArgumentException('File not writeable', 1701857185); } $command = sprintf( '%s --replace-input --linearize %s', @@ -156,8 +154,8 @@ class ExifToolService * * @param FileInterface $file the processed file * @return string - * @throws InvalidArgumentException - * @throws UnexpectedValueException + * @throws \InvalidArgumentException + * @throws \UnexpectedValueException * @throws Exception */ protected function getEscapedTagArguments(FileInterface $file): string @@ -180,8 +178,8 @@ class ExifToolService * Get the exiftool_keep_pd_tags value of the file's storage as an array * * @return array<string> - * @throws InvalidArgumentException - * @throws UnexpectedValueException + * @throws \InvalidArgumentException + * @throws \UnexpectedValueException * @throws Exception */ protected function getKeepTagsForPdfFromStorage(FileInterface $file): array @@ -203,8 +201,8 @@ class ExifToolService * Get the exiftool_keep_image_tags value of the file's storage as an array * * @return array<string> - * @throws InvalidArgumentException - * @throws UnexpectedValueException + * @throws \InvalidArgumentException + * @throws \UnexpectedValueException * @throws Exception */ protected function getKeepTagsForImageFromStorage(FileInterface $file): array diff --git a/composer.json b/composer.json index 5ed6ac193e291d23ab4eaa502603fed44c4034d1..592512657724caa0beb99cf5d00187802bba771e 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,7 @@ "squizlabs/php_codesniffer": "^3.7", "ssch/typo3-rector": "^1.1", "symfony/yaml": "^6.1", - "typo3/coding-standards": "^0.7", + "typo3/coding-standards": "^0.8", "typo3/testing-framework": "^8.1" }, "repositories": [ diff --git a/phpmd.baseline.xml b/phpmd.baseline.xml index e15ba29920a6aa9a5ffe3d9c58f61c57375734c8..850693db555121538798ce21822dfc33cf197f90 100644 --- a/phpmd.baseline.xml +++ b/phpmd.baseline.xml @@ -1,8 +1,10 @@ <?xml version="1.0"?> <phpmd-baseline> <violation rule="PHPMD\Rule\Naming\LongVariable" file="Classes/Configuration/ExtensionConfiguration.php"/> + <violation rule="PHPMD\Rule\CleanCode\MissingImport" file="Classes/Configuration/ExtensionConfiguration.php"/> <violation rule="PHPMD\Rule\CleanCode\StaticAccess" file="Classes/Configuration/ExtensionConfiguration.php"/> <violation rule="PHPMD\Rule\Naming\LongVariable" file="Classes/Service/ExifToolService.php"/> + <violation rule="PHPMD\Rule\CleanCode\MissingImport" file="Classes/Service/ExifToolService.php"/> <violation rule="PHPMD\Rule\CleanCode\StaticAccess" file="Classes/Service/ExifToolService.php"/> <violation rule="PHPMD\Rule\CleanCode\ElseExpression" file="Classes/Service/ExifToolService.php"/> </phpmd-baseline>