mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-06 12:45:30 +00:00
Expand action and clean up code.
This commit is contained in:
@@ -27,7 +27,7 @@ $paths = [
|
|||||||
$current . '/../../database',
|
$current . '/../../database',
|
||||||
$current . '/../../routes',
|
$current . '/../../routes',
|
||||||
$current . '/../../tests',
|
$current . '/../../tests',
|
||||||
$current . '/../../resources/lang',
|
$current . '/../../resources/lang/en_US',
|
||||||
];
|
];
|
||||||
|
|
||||||
$finder = PhpCsFixer\Finder::create()
|
$finder = PhpCsFixer\Finder::create()
|
||||||
@@ -36,9 +36,11 @@ $finder = PhpCsFixer\Finder::create()
|
|||||||
|
|
||||||
$config = new PhpCsFixer\Config();
|
$config = new PhpCsFixer\Config();
|
||||||
return $config->setRules([
|
return $config->setRules([
|
||||||
'@PSR12' => true,
|
'@PhpCsFixer:risky' => true,
|
||||||
|
// '@PSR12:risky' => true,
|
||||||
'declare_strict_types' => true,
|
'declare_strict_types' => true,
|
||||||
'strict_param' => true,
|
'strict_param' => true,
|
||||||
'array_syntax' => ['syntax' => 'short'],
|
'array_syntax' => ['syntax' => 'short'],
|
||||||
|
'native_function_invocation' => false,
|
||||||
])
|
])
|
||||||
->setFinder($finder);
|
->setFinder($finder);
|
||||||
|
12
.ci/php-cs-fixer/composer.lock
generated
12
.ci/php-cs-fixer/composer.lock
generated
@@ -226,16 +226,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "friendsofphp/php-cs-fixer",
|
"name": "friendsofphp/php-cs-fixer",
|
||||||
"version": "v3.37.0",
|
"version": "v3.37.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
|
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
|
||||||
"reference": "d5ccc3807fd496ac2b448e8e5e57aa0772f0d18b"
|
"reference": "c3fe76976081ab871aa654e872da588077e19679"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/d5ccc3807fd496ac2b448e8e5e57aa0772f0d18b",
|
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/c3fe76976081ab871aa654e872da588077e19679",
|
||||||
"reference": "d5ccc3807fd496ac2b448e8e5e57aa0772f0d18b",
|
"reference": "c3fe76976081ab871aa654e872da588077e19679",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -307,7 +307,7 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
|
"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": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -315,7 +315,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-10-28T14:49:50+00:00"
|
"time": "2023-10-29T20:51:23+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/container",
|
"name": "psr/container",
|
||||||
|
23
.ci/phpcs.sh
23
.ci/phpcs.sh
@@ -28,11 +28,30 @@ SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|||||||
# enable test .env file.
|
# enable test .env file.
|
||||||
# cp .ci/.env.ci .env
|
# 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
|
# clean up php code
|
||||||
cd $SCRIPT_DIR/php-cs-fixer
|
cd $SCRIPT_DIR/php-cs-fixer
|
||||||
composer update --quiet
|
composer update --quiet
|
||||||
rm -f .php-cs-fixer.cache
|
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/..
|
cd $SCRIPT_DIR/..
|
||||||
|
|
||||||
exit 0
|
exit $EXIT_CODE
|
||||||
|
@@ -66,6 +66,8 @@ phpmd database,app,tests html /gdrive-all/development/phpmd/phpmd.xml > public/r
|
|||||||
<!-- include clean code manually -->
|
<!-- include clean code manually -->
|
||||||
<rule ref="rulesets/cleancode.xml/BooleanArgumentFlag" />
|
<rule ref="rulesets/cleancode.xml/BooleanArgumentFlag" />
|
||||||
<rule ref="rulesets/cleancode.xml/ElseExpression" />
|
<rule ref="rulesets/cleancode.xml/ElseExpression" />
|
||||||
|
<rule ref="rulesets/cleancode.xml/MissingImport" />
|
||||||
|
<rule ref="rulesets/cleancode.xml/UndefinedVariable" />
|
||||||
|
|
||||||
<!-- no this one -->
|
<!-- no this one -->
|
||||||
<!--<rule ref="rulesets/cleancode.xml/StaticAccess" />-->
|
<!--<rule ref="rulesets/cleancode.xml/StaticAccess" />-->
|
||||||
|
3
.github/workflows/sonarcloud.yml
vendored
3
.github/workflows/sonarcloud.yml
vendored
@@ -54,6 +54,9 @@ jobs:
|
|||||||
- name: PHPMD
|
- name: PHPMD
|
||||||
run: .ci/phpmd.sh
|
run: .ci/phpmd.sh
|
||||||
|
|
||||||
|
- name: PHP CS Fixer
|
||||||
|
run: .ci/phpcs.sh
|
||||||
|
|
||||||
- name: "Create database file"
|
- name: "Create database file"
|
||||||
run: touch storage/database/database.sqlite
|
run: touch storage/database/database.sqlite
|
||||||
|
|
||||||
|
@@ -96,15 +96,17 @@ class AccountController extends Controller
|
|||||||
// user's preferences
|
// user's preferences
|
||||||
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT])->pluck('id')->toArray();
|
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT])->pluck('id')->toArray();
|
||||||
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
|
$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)) {
|
if (!(is_array($frontPage->data) && count($frontPage->data) > 0)) {
|
||||||
$frontPage->data = $defaultSet;
|
$frontPage->data = $defaultSet;
|
||||||
$frontPage->save();
|
$frontPage->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var TransactionCurrency $default */
|
||||||
|
$default = app('amount')->getDefaultCurrency();
|
||||||
|
$accounts = $this->repository->getAccountsById($frontPage->data);
|
||||||
|
$chartData = [];
|
||||||
|
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
$currency = $this->repository->getAccountCurrency($account);
|
$currency = $this->repository->getAccountCurrency($account);
|
||||||
|
@@ -34,7 +34,6 @@ use Throwable;
|
|||||||
*/
|
*/
|
||||||
final class IntervalException extends Exception
|
final class IntervalException extends Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
public array $availableIntervals;
|
public array $availableIntervals;
|
||||||
public Periodicity $periodicity;
|
public Periodicity $periodicity;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
@@ -60,8 +59,7 @@ final class IntervalException extends Exception
|
|||||||
array $intervals,
|
array $intervals,
|
||||||
int $code = 0,
|
int $code = 0,
|
||||||
?Throwable $previous = null
|
?Throwable $previous = null
|
||||||
): IntervalException
|
): IntervalException {
|
||||||
{
|
|
||||||
$message = sprintf(
|
$message = sprintf(
|
||||||
'The periodicity %s is unknown. Choose one of available periodicity: %s',
|
'The periodicity %s is unknown. Choose one of available periodicity: %s',
|
||||||
$periodicity->name,
|
$periodicity->name,
|
||||||
|
@@ -48,8 +48,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
|||||||
protected array $allowedMimes = [];
|
protected array $allowedMimes = [];
|
||||||
protected int $maxUploadSize = 0;
|
protected int $maxUploadSize = 0;
|
||||||
|
|
||||||
/** @var Filesystem The disk where attachments are stored. */
|
protected Filesystem $uploadDisk;
|
||||||
protected $uploadDisk;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AttachmentHelper constructor.
|
* AttachmentHelper constructor.
|
||||||
|
@@ -32,7 +32,6 @@ use Illuminate\Contracts\Validation\ValidationRule;
|
|||||||
*/
|
*/
|
||||||
class IsBoolean implements ValidationRule
|
class IsBoolean implements ValidationRule
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $attribute
|
* @param string $attribute
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
|
@@ -35,7 +35,6 @@ use Illuminate\Contracts\Validation\ValidationRule;
|
|||||||
*/
|
*/
|
||||||
class IsDateOrTime implements ValidationRule
|
class IsDateOrTime implements ValidationRule
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $attribute
|
* @param string $attribute
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
@@ -47,7 +46,8 @@ class IsDateOrTime implements ValidationRule
|
|||||||
{
|
{
|
||||||
$value = (string)$value;
|
$value = (string)$value;
|
||||||
if ('' === $value) {
|
if ('' === $value) {
|
||||||
$fail('validation.date_or_time')->translate();;
|
$fail('validation.date_or_time')->translate();
|
||||||
|
;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (10 === strlen($value)) {
|
if (10 === strlen($value)) {
|
||||||
@@ -57,12 +57,14 @@ class IsDateOrTime implements ValidationRule
|
|||||||
} catch (InvalidDateException $e) { // @phpstan-ignore-line
|
} catch (InvalidDateException $e) { // @phpstan-ignore-line
|
||||||
app('log')->error(sprintf('"%s" is not a valid date: %s', $value, $e->getMessage()));
|
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;
|
return;
|
||||||
} catch (InvalidFormatException $e) { // @phpstan-ignore-line
|
} catch (InvalidFormatException $e) { // @phpstan-ignore-line
|
||||||
app('log')->error(sprintf('"%s" is of an invalid format: %s', $value, $e->getMessage()));
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,12 +76,14 @@ class IsDateOrTime implements ValidationRule
|
|||||||
} catch (InvalidDateException $e) { // @phpstan-ignore-line
|
} catch (InvalidDateException $e) { // @phpstan-ignore-line
|
||||||
app('log')->error(sprintf('"%s" is not a valid date or time: %s', $value, $e->getMessage()));
|
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;
|
return;
|
||||||
} catch (InvalidFormatException $e) {
|
} catch (InvalidFormatException $e) {
|
||||||
app('log')->error(sprintf('"%s" is of an invalid format: %s', $value, $e->getMessage()));
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,6 @@ use Illuminate\Contracts\Validation\ValidationRule;
|
|||||||
*/
|
*/
|
||||||
class IsTransferAccount implements ValidationRule
|
class IsTransferAccount implements ValidationRule
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $attribute
|
* @param string $attribute
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
|
@@ -35,7 +35,6 @@ use Illuminate\Contracts\Validation\ValidationRule;
|
|||||||
*/
|
*/
|
||||||
class ValidJournals implements ValidationRule
|
class ValidJournals implements ValidationRule
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $attribute
|
* @param string $attribute
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
|
@@ -293,7 +293,8 @@ class RecurrenceUpdateService
|
|||||||
if (array_key_exists('currency_id', $submitted) || array_key_exists('currency_code', $submitted)) {
|
if (array_key_exists('currency_id', $submitted) || array_key_exists('currency_code', $submitted)) {
|
||||||
$currency = $currencyFactory->find(
|
$currency = $currencyFactory->find(
|
||||||
array_key_exists('currency_id', $submitted) ? (int)$submitted['currency_id'] : null,
|
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) {
|
if (null === $currency) {
|
||||||
unset($submitted['currency_id'], $submitted['currency_code']);
|
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)) {
|
if (array_key_exists('foreign_currency_id', $submitted) || array_key_exists('foreign_currency_code', $submitted)) {
|
||||||
$foreignCurrency = $currencyFactory->find(
|
$foreignCurrency = $currencyFactory->find(
|
||||||
array_key_exists('foreign_currency_id', $submitted) ? (int)$submitted['foreign_currency_id'] : null,
|
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) {
|
if (null === $foreignCurrency) {
|
||||||
unset($submitted['foreign_currency_id'], $currency['foreign_currency_code']);
|
unset($submitted['foreign_currency_id'], $currency['foreign_currency_code']);
|
||||||
|
@@ -43,7 +43,6 @@ use stdClass;
|
|||||||
*/
|
*/
|
||||||
class TransactionGroupTransformer extends AbstractTransformer
|
class TransactionGroupTransformer extends AbstractTransformer
|
||||||
{
|
{
|
||||||
|
|
||||||
private ExchangeRateConverter $converter;
|
private ExchangeRateConverter $converter;
|
||||||
private array $currencies = [];
|
private array $currencies = [];
|
||||||
private TransactionCurrency $default;
|
private TransactionCurrency $default;
|
||||||
|
@@ -47,7 +47,6 @@ use PragmaRX\Google2FA\Exceptions\InvalidCharactersException;
|
|||||||
use PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException;
|
use PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException;
|
||||||
use ValueError;
|
use ValueError;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class FireflyValidator.
|
* Class FireflyValidator.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user