Skip to content

Adjust 'if' conditionals that were reported by phpstan - #462

Merged
phil-davis merged 1 commit into
masterfrom
issue-460
Mar 17, 2022
Merged

phil-davis merged 1 commit into
masterfrom
issue-460

Conversation

@phil-davis

@phil-davis phil-davis commented Mar 17, 2022 •

Copy link
Copy Markdown
Contributor

Fixes issue #460 and gets CI green again.

@phil-davis phil-davis self-assigned this Mar 17, 2022
*/
private function getFileHandle($fileId, $owner, $editor) {
if ($editor && $editor != '') {
if ($editor) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If $editor is the empty string, then $editor will evaluate to false in the first condition, so the 2nd condition adds no value.

Comment thread lib/Storage.php
/** @var \OCP\Files\Node|null $document */
$document = $node;
} elseif ($node->getType() == FileInfo::TYPE_FOLDER && $fileId !== null) {
} elseif ($fileId !== null) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

At this point we know that the resource type is not TYPE_FILE. getType can only return 2 values, so we know that $node must be of type TYPE_FOLDER. Therefore that check is removed.

@phil-davis phil-davis changed the title Adjust if conditionals that were reported by phpstan Adjust 'if' conditionals that were reported by phpstan Mar 17, 2022
@phil-davis phil-davis mentioned this pull request Mar 17, 2022
@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@phil-davis
phil-davis merged commit 74069c8 into master Mar 17, 2022
@delete-merged-branch
delete-merged-branch Bot deleted the issue-460 branch March 17, 2022 11:46
@phil-davis phil-davis mentioned this pull request Jun 24, 2022
8 of 42 tasks
@jnweiger jnweiger mentioned this pull request Jul 7, 2023
31 of 42 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants