Skip to content
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

style: add operator_linebreak #40

Merged
merged 1 commit into from
Nov 6, 2024
Merged

Conversation

blizzz
Copy link
Member

@blizzz blizzz commented Nov 6, 2024

Ensure that conditional statements are split into multiple lines and that the operator is placed at the beginning. This actually implements the style described in https://docs.nextcloud.com/server/latest/developer_manual/getting_started/codingguidelines.html#control-structures

...
diff --git a/apps/dav/lib/CalDAV/BirthdayService.php b/apps/dav/lib/CalDAV/BirthdayService.php
index e1e46316d74..680b228766f 100644
--- a/apps/dav/lib/CalDAV/BirthdayService.php
+++ b/apps/dav/lib/CalDAV/BirthdayService.php
@@ -295,8 +295,8 @@ class BirthdayService {
                }
 
                return (
-                       $newCalendarData->VEVENT->DTSTART->getValue() !== $existingBirthday->VEVENT->DTSTART->getValue() ||
-                       $newCalendarData->VEVENT->SUMMARY->getValue() !== $existingBirthday->VEVENT->SUMMARY->getValue()
+                       $newCalendarData->VEVENT->DTSTART->getValue() !== $existingBirthday->VEVENT->DTSTART->getValue()
+                       || $newCalendarData->VEVENT->SUMMARY->getValue() !== $existingBirthday->VEVENT->SUMMARY->getValue()
                );
        }
 
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php
index c9d323d27df..b1e31733b7a 100644
--- a/apps/dav/lib/CalDAV/CalDavBackend.php
+++ b/apps/dav/lib/CalDAV/CalDavBackend.php
@@ -394,8 +394,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
                                                // New share can not have more permissions than the old one.
                                                continue;
                                        }
-                                       if (isset($calendars[$row['id']][$readOnlyPropertyName]) &&
-                                               $calendars[$row['id']][$readOnlyPropertyName] === 0) {
+                                       if (isset($calendars[$row['id']][$readOnlyPropertyName])
+                                               && $calendars[$row['id']][$readOnlyPropertyName] === 0) {
                                                // Old share is already read-write, no more permissions can be gained
                                                continue;
                                        }
@@ -1929,8 +1929,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
 
                if ($pattern !== '') {
                        $innerQuery->andWhere($innerQuery->expr()->iLike('op.value',
-                               $outerQuery->createNamedParameter('%' .
-                                       $this->db->escapeLikeParameter($pattern) . '%')));
+                               $outerQuery->createNamedParameter('%'
+                                       . $this->db->escapeLikeParameter($pattern) . '%')));
                }
 
                $start = null;
...

Downside: a lot if fixes in server:

 223 files changed, 1864 insertions(+), 1875 deletions(-)

@blizzz blizzz added the enhancement New feature or request label Nov 6, 2024
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@blizzz blizzz force-pushed the enh/operator_linebreak branch from 1652d37 to abad0dc Compare November 6, 2024 11:45
Copy link

@susnux susnux left a comment

Choose a reason for hiding this comment

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

Agree! I find this much better readable, as the operator is in the same line as the condition and you do not need to look for it on the previous condition.

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

👍 smooth operators

@nickvergessen nickvergessen merged commit 7b16bcf into master Nov 6, 2024
2 checks passed
@nickvergessen nickvergessen deleted the enh/operator_linebreak branch November 6, 2024 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants