-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
refactor: Use the elvis operator + fix: Handle null checks with the ?? operator #48042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Christoph Wurst <[email protected]>
| $currentValue = $accountProperty->getValue(); | ||
| $scope = ($accountProperty->getScope() ? $accountProperty->getScope() | ||
| : $defaultScopes[$property]); | ||
| $scope = ($accountProperty->getScope() ?: $defaultScopes[$property]); |
Check notice
Code scanning / Psalm
RedundantConditionGivenDocblockType
| // 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
st3iny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹
lib/private/Log/LogDetails.php
Outdated
| $method = is_string($request->getMethod()) ? $request->getMethod() : '--'; | ||
| if ($this->config->getValue('installed', false)) { | ||
| $user = \OC_User::getUser() ? \OC_User::getUser() : '--'; | ||
| $user = \OC_User::getUser() ?: '--'; |
There was a problem hiding this comment.
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 '--'
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 <[email protected]>

Summary
Makes code easier to read.
TODO
Checklist