Skip to content

Commit

Permalink
monk mode: removed some psalm infos
Browse files Browse the repository at this point in the history
Signed-off-by: dartcafe <[email protected]>
  • Loading branch information
dartcafe committed Oct 9, 2024
1 parent cd37ea7 commit c1f6895
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 34 deletions.
2 changes: 1 addition & 1 deletion lib/Db/Poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public function setUserId(string $userId): void {
}

public function getGroupShares(): array {
if (!empty($this->groupShares)) {
if ($this->groupShares !== null && $this->groupShares !== '') {
// explode with separator and remove empty elements
return array_filter(explode(PollMapper::CONCAT_SEPARATOR, PollMapper::CONCAT_SEPARATOR . $this->groupShares));
}
Expand Down
7 changes: 5 additions & 2 deletions lib/Db/Preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
* @method void setUserId(string $value)
* @method string getTimestamp()
* @method void setTimestamp(int $value)
* @method string getPreferences()
* @method void setPreferences(string $value)
*/
class Preferences extends Entity implements JsonSerializable {
Expand Down Expand Up @@ -52,8 +51,12 @@ public function __construct() {
$this->setPreferences(json_encode(self::DEFAULT));
}

public function getPreferences(): string {
return $this->preferences ?? '';
}

public function getPreferences_decoded(): mixed {
return json_decode($this->getPreferences() ?? '');
return json_decode($this->getPreferences());
}

public function getCheckCalendarsHoursBefore(): int {
Expand Down
3 changes: 3 additions & 0 deletions lib/Filter/ActivityFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
use OCP\IL10N;
use OCP\IURLGenerator;

/**
* @psalm-suppress UnusedClass
*/
class ActivityFilter implements \OCP\Activity\IFilter {
private $l10n;
private $urlGenerator;
Expand Down
2 changes: 1 addition & 1 deletion lib/Model/Group/Circle.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use OCA\Polls\Model\UserBase;

/**
* @psam-supress
* @psalm-suppress UnusedClass
*/
class Circle extends UserBase {
public const TYPE = 'circle';
Expand Down
8 changes: 7 additions & 1 deletion lib/Model/Group/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace OCA\Polls\Model\Group;

use OCA\Polls\Exceptions\NotFoundException;
use OCA\Polls\Helper\Container;
use OCA\Polls\Model\User\User;
use OCA\Polls\Model\UserBase;
Expand All @@ -30,7 +31,12 @@ public function __construct(
}

private function setUp(): void {
$this->group = $this->groupManager->get($this->id);
$foundGroup = $this->groupManager->get($this->id);
if ($foundGroup === null) {
throw new NotFoundException('Group not found');
}

$this->group = $foundGroup;
$this->displayName = $this->group->getDisplayName();
}

Expand Down
4 changes: 0 additions & 4 deletions lib/Model/Settings/AppSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ public function getGroupSetting(string $key): array {
return $this->stringToArray($this->appConfig->getValueString(AppConstants::APP_ID, $key));
}

public function getStringSetting(string $key, string $default = ''): string {
return $this->appConfig->getValueString(AppConstants::APP_ID, $key, $default);
}

public function getIntegerSetting(string $key, int $default = 0): int {
if ($this->checkSettingType($key, IAppConfig::VALUE_INT)) {
return $this->appConfig->getValueInt(AppConstants::APP_ID, $key, $default);
Expand Down
2 changes: 1 addition & 1 deletion lib/Model/UserBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public static function search(string $query = ''): array {
$types[] = IShare::TYPE_CIRCLE;
}

[$result, $more] = Container::queryClass(ISearch::class)->search($query, $types, false, 200, 0);
[$result] = Container::queryClass(ISearch::class)->search($query, $types, false, 200, 0);

foreach (($result['users'] ?? []) as $item) {
$items[] = new User($item['value']['shareWith']);
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/MailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static function extractEmailAddressAndName($eMailString): array {
preg_match(self::REGEX_PARSE_MAIL_AND_NAME, $eMailString, $matches);

// Check if the found element is a valid email address
$emailAddress = !empty($matches[1]) ? trim($matches[1]) : null;
$emailAddress = boolval($matches[1]) ? trim($matches[1]) : null;

if ($emailAddress !== null && filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) {
// Extract the name based on the input string
Expand Down
6 changes: 3 additions & 3 deletions lib/Service/ShareService.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,14 @@ private function convertPersonalPublicShareToExternalShare(
$this->share->setDisplayName($displayName ?? $this->share->getDisplayName());
$this->share->setTimeZoneName($timeZone ?? $this->share->getTimeZoneName());
$this->share->setLanguage($language ?? $this->share->getLanguage());
if ($emailAddress && $emailAddress !== $this->share->getEmailAddress()) {

if ($emailAddress !== null && $emailAddress !== '' && $emailAddress !== $this->share->getEmailAddress()) {
// reset invitation sent, if email address is changed
$this->share->setInvitationSent(0);
}

$this->share->setEmailAddress($emailAddress ?? $this->share->getEmailAddress());


// convert to type external
$this->share->setType(Share::TYPE_EXTERNAL);

Expand Down
3 changes: 3 additions & 0 deletions lib/Settings/ActivityVote.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

namespace OCA\Polls\Settings;

/**
* @psalm-suppress UnusedClass
*/
class ActivityVote extends ActivitySettings {
public function getIdentifier() : string {
return 'vote_set';
Expand Down
21 changes: 1 addition & 20 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,33 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- SPDX-FileCopyrightText: 2021 Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<files psalm-version="5.23.0@005e3184fb6de4350a873b9b8c4dc3cede9db762">
<file src="lib/Filter/ActivityFilter.php">
<UnusedClass>
<code><![CDATA[ActivityFilter]]></code>
</UnusedClass>
</file>
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
<file src="lib/Model/Group/Circle.php">
<UndefinedClass>
<code><![CDATA[$this->circle]]></code>
<code><![CDATA[CirclesCircle]]></code>
</UndefinedClass>
</file>
<file src="lib/Model/UserBase.php">
<UnusedVariable>
<code><![CDATA[$more]]></code>
</UnusedVariable>
</file>
<file src="lib/Service/MailService.php">
<PossiblyUnusedMethod>
<code><![CDATA[parseEmailStrings]]></code>
</PossiblyUnusedMethod>
</file>
<file src="lib/Settings/ActivityVote.php">
<UnusedClass>
<code><![CDATA[ActivityVote]]></code>
</UnusedClass>
</file>
</files>

0 comments on commit c1f6895

Please sign in to comment.