Expand action and clean up code.

This commit is contained in:
James Cole 2023-11-04 14:09:51 +01:00
parent 6eabe5fa8c
commit 5a35960434
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
23 changed files with 119 additions and 93 deletions

View File

@ -27,7 +27,7 @@ $paths = [
$current . '/../../database',
$current . '/../../routes',
$current . '/../../tests',
$current . '/../../resources/lang',
$current . '/../../resources/lang/en_US',
];
$finder = PhpCsFixer\Finder::create()
@ -36,9 +36,11 @@ $finder = PhpCsFixer\Finder::create()
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PSR12' => true,
'@PhpCsFixer:risky' => true,
// '@PSR12:risky' => true,
'declare_strict_types' => true,
'strict_param' => true,
'array_syntax' => ['syntax' => 'short'],
'native_function_invocation' => false,
])
->setFinder($finder);

View File

@ -226,16 +226,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v3.37.0",
"version": "v3.37.1",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "d5ccc3807fd496ac2b448e8e5e57aa0772f0d18b"
"reference": "c3fe76976081ab871aa654e872da588077e19679"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/d5ccc3807fd496ac2b448e8e5e57aa0772f0d18b",
"reference": "d5ccc3807fd496ac2b448e8e5e57aa0772f0d18b",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/c3fe76976081ab871aa654e872da588077e19679",
"reference": "c3fe76976081ab871aa654e872da588077e19679",
"shasum": ""
},
"require": {
@ -307,7 +307,7 @@
],
"support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.37.0"
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.37.1"
},
"funding": [
{
@ -315,7 +315,7 @@
"type": "github"
}
],
"time": "2023-10-28T14:49:50+00:00"
"time": "2023-10-29T20:51:23+00:00"
},
{
"name": "psr/container",

View File

@ -28,11 +28,30 @@ SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# enable test .env file.
# cp .ci/.env.ci .env
OUTPUT_FORMAT=txt
EXTRA_PARAMS=""
if [[ $GITHUB_ACTIONS = "true" ]]
then
OUTPUT_FORMAT=github
EXTRA_PARAMS="--diff --dry-run"
fi
# clean up php code
cd $SCRIPT_DIR/php-cs-fixer
composer update --quiet
rm -f .php-cs-fixer.cache
PHP_CS_FIXER_IGNORE_ENV=true ./vendor/bin/php-cs-fixer fix --config $SCRIPT_DIR/php-cs-fixer/.php-cs-fixer.php --allow-risky=yes
PHP_CS_FIXER_IGNORE_ENV=true
./vendor/bin/php-cs-fixer fix \
--config $SCRIPT_DIR/php-cs-fixer/.php-cs-fixer.php \
--format=$OUTPUT_FORMAT \
--allow-risky=yes \
$EXTRA_PARAMS
EXIT_CODE=$?
echo "Exit code for CS fixer is $EXIT_CODE."
cd $SCRIPT_DIR/..
exit 0
exit $EXIT_CODE

View File

@ -66,6 +66,8 @@ phpmd database,app,tests html /gdrive-all/development/phpmd/phpmd.xml > public/r
<!-- include clean code manually -->
<rule ref="rulesets/cleancode.xml/BooleanArgumentFlag" />
<rule ref="rulesets/cleancode.xml/ElseExpression" />
<rule ref="rulesets/cleancode.xml/MissingImport" />
<rule ref="rulesets/cleancode.xml/UndefinedVariable" />
<!-- no this one -->
<!--<rule ref="rulesets/cleancode.xml/StaticAccess" />-->

View File

@ -54,6 +54,9 @@ jobs:
- name: PHPMD
run: .ci/phpmd.sh
- name: PHP CS Fixer
run: .ci/phpcs.sh
- name: "Create database file"
run: touch storage/database/database.sqlite

View File

@ -96,15 +96,17 @@ class AccountController extends Controller
// user's preferences
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT])->pluck('id')->toArray();
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
/** @var TransactionCurrency $default */
$default = app('amount')->getDefaultCurrency();
$accounts = $this->repository->getAccountsById($frontPage->data);
$chartData = [];
if (!(is_array($frontPage->data) && count($frontPage->data) > 0)) {
$frontPage->data = $defaultSet;
$frontPage->save();
}
/** @var TransactionCurrency $default */
$default = app('amount')->getDefaultCurrency();
$accounts = $this->repository->getAccountsById($frontPage->data);
$chartData = [];
/** @var Account $account */
foreach ($accounts as $account) {
$currency = $this->repository->getAccountCurrency($account);

View File

@ -34,7 +34,6 @@ use Throwable;
*/
final class IntervalException extends Exception
{
public array $availableIntervals;
public Periodicity $periodicity;
/** @var string */
@ -60,8 +59,7 @@ final class IntervalException extends Exception
array $intervals,
int $code = 0,
?Throwable $previous = null
): IntervalException
{
): IntervalException {
$message = sprintf(
'The periodicity %s is unknown. Choose one of available periodicity: %s',
$periodicity->name,

View File

@ -48,8 +48,7 @@ class AttachmentHelper implements AttachmentHelperInterface
protected array $allowedMimes = [];
protected int $maxUploadSize = 0;
/** @var Filesystem The disk where attachments are stored. */
protected $uploadDisk;
protected Filesystem $uploadDisk;
/**
* AttachmentHelper constructor.

View File

@ -32,7 +32,6 @@ use Illuminate\Contracts\Validation\ValidationRule;
*/
class IsBoolean implements ValidationRule
{
/**
* @param string $attribute
* @param mixed $value

View File

@ -35,7 +35,6 @@ use Illuminate\Contracts\Validation\ValidationRule;
*/
class IsDateOrTime implements ValidationRule
{
/**
* @param string $attribute
* @param mixed $value
@ -47,7 +46,8 @@ class IsDateOrTime implements ValidationRule
{
$value = (string)$value;
if ('' === $value) {
$fail('validation.date_or_time')->translate();;
$fail('validation.date_or_time')->translate();
;
return;
}
if (10 === strlen($value)) {
@ -57,12 +57,14 @@ class IsDateOrTime implements ValidationRule
} catch (InvalidDateException $e) { // @phpstan-ignore-line
app('log')->error(sprintf('"%s" is not a valid date: %s', $value, $e->getMessage()));
$fail('validation.date_or_time')->translate();;
$fail('validation.date_or_time')->translate();
;
return;
} catch (InvalidFormatException $e) { // @phpstan-ignore-line
app('log')->error(sprintf('"%s" is of an invalid format: %s', $value, $e->getMessage()));
$fail('validation.date_or_time')->translate();;
$fail('validation.date_or_time')->translate();
;
return;
}
@ -74,12 +76,14 @@ class IsDateOrTime implements ValidationRule
} catch (InvalidDateException $e) { // @phpstan-ignore-line
app('log')->error(sprintf('"%s" is not a valid date or time: %s', $value, $e->getMessage()));
$fail('validation.date_or_time')->translate();;
$fail('validation.date_or_time')->translate();
;
return;
} catch (InvalidFormatException $e) {
app('log')->error(sprintf('"%s" is of an invalid format: %s', $value, $e->getMessage()));
$fail('validation.date_or_time')->translate();;
$fail('validation.date_or_time')->translate();
;
return;
}
}

View File

@ -34,7 +34,6 @@ use Illuminate\Contracts\Validation\ValidationRule;
*/
class IsTransferAccount implements ValidationRule
{
/**
* @param string $attribute
* @param mixed $value

View File

@ -35,7 +35,6 @@ use Illuminate\Contracts\Validation\ValidationRule;
*/
class ValidJournals implements ValidationRule
{
/**
* @param string $attribute
* @param mixed $value

View File

@ -293,7 +293,8 @@ class RecurrenceUpdateService
if (array_key_exists('currency_id', $submitted) || array_key_exists('currency_code', $submitted)) {
$currency = $currencyFactory->find(
array_key_exists('currency_id', $submitted) ? (int)$submitted['currency_id'] : null,
array_key_exists('currency_code', $submitted) ? $submitted['currency_code'] : null);
array_key_exists('currency_code', $submitted) ? $submitted['currency_code'] : null
);
}
if (null === $currency) {
unset($submitted['currency_id'], $submitted['currency_code']);
@ -304,7 +305,8 @@ class RecurrenceUpdateService
if (array_key_exists('foreign_currency_id', $submitted) || array_key_exists('foreign_currency_code', $submitted)) {
$foreignCurrency = $currencyFactory->find(
array_key_exists('foreign_currency_id', $submitted) ? (int)$submitted['foreign_currency_id'] : null,
array_key_exists('foreign_currency_code', $submitted) ? $submitted['foreign_currency_code'] : null);
array_key_exists('foreign_currency_code', $submitted) ? $submitted['foreign_currency_code'] : null
);
}
if (null === $foreignCurrency) {
unset($submitted['foreign_currency_id'], $currency['foreign_currency_code']);

View File

@ -43,7 +43,6 @@ use stdClass;
*/
class TransactionGroupTransformer extends AbstractTransformer
{
private ExchangeRateConverter $converter;
private array $currencies = [];
private TransactionCurrency $default;

View File

@ -47,7 +47,6 @@ use PragmaRX\Google2FA\Exceptions\InvalidCharactersException;
use PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException;
use ValueError;
/**
* Class FireflyValidator.
*/