Skip to content

Conversation

@ChristophWurst
Copy link
Member

@ChristophWurst ChristophWurst commented Sep 15, 2024

  • Resolves: #

Summary

Makes code easier to read.

TODO

  • ...

Checklist

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
$currentValue = $accountProperty->getValue();
$scope = ($accountProperty->getScope() ? $accountProperty->getScope()
: $defaultScopes[$property]);
$scope = ($accountProperty->getScope() ?: $defaultScopes[$property]);

Check notice

Code scanning / Psalm

RedundantConditionGivenDocblockType

Operand of type 'v2-federated'|'v2-local'|'v2-private'|'v2-published' is always truthy
// resolve and store formatted address
$address = $this->resolveLocation($lat, $lon);
$address = $address ? $address : $this->l10n->t('Unknown address');
$address = $address ?: $this->l10n->t('Unknown address');

Check notice

Code scanning / Psalm

RiskyTruthyFalsyComparison

Operand of type null|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead.
Copy link
Member

@st3iny st3iny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹

@miaulalala
Copy link
Contributor

tenor

$method = is_string($request->getMethod()) ? $request->getMethod() : '--';
if ($this->config->getValue('installed', false)) {
$user = \OC_User::getUser() ? \OC_User::getUser() : '--';
$user = \OC_User::getUser() ?: '--';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uid "0" would also evaluate to '--'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, same as with the ternary operator

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed :)

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
@ChristophWurst ChristophWurst changed the title refactor: Use the elvis operator refactor: Use the elvis operator + fix: Handle null checks with the ?? operator Sep 15, 2024
@ChristophWurst ChristophWurst merged commit 0a7b4b5 into master Sep 16, 2024
@ChristophWurst ChristophWurst deleted the refactor/elvis branch September 16, 2024 08:04
@skjnldsv skjnldsv mentioned this pull request Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Development

Successfully merging this pull request may close these issues.

7 participants