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

chore(deps): update dependency nextcloud/coding-standard to ^v1.3.2 (main) #1581

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require-dev": {
"nextcloud/coding-standard": "^v1.0.0",
"nextcloud/coding-standard": "^v1.3.2",
"nextcloud/ocp": "dev-master",
"staabm/annotate-pull-request-from-checkstyle": "^1.8.5",
"phpunit/phpunit": "^9",
Expand Down
73 changes: 60 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions lib/Analytics/AnalyticsDatasource.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down Expand Up @@ -30,13 +31,13 @@ class AnalyticsDatasource implements IDatasource {
protected ?string $userId;

public function __construct(
IL10N $l10n,
IL10N $l10n,
LoggerInterface $logger,
TableService $tableService,
ViewService $viewService,
ColumnService $columnService,
RowService $rowService,
?string $userId
TableService $tableService,
ViewService $viewService,
ColumnService $columnService,
RowService $rowService,
?string $userId,
) {
$this->l10n = $l10n;
$this->logger = $logger;
Expand Down
1 change: 1 addition & 0 deletions lib/Api/V1Api.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
1 change: 1 addition & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
1 change: 1 addition & 0 deletions lib/Capabilities.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
4 changes: 2 additions & 2 deletions lib/Command/AddTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
unset($arr['ownerDisplayName']);
$output->writeln(json_encode($arr, JSON_PRETTY_PRINT));
} catch (InternalError|PermissionError|Exception $e) {
$output->writeln('Error occurred: '.$e->getMessage());
$this->logger->warning('Following error occurred during executing occ command "'.self::class.'"', ['exception' => $e]);
$output->writeln('Error occurred: ' . $e->getMessage());
$this->logger->warning('Following error occurred during executing occ command "' . self::class . '"', ['exception' => $e]);
return 1;
}
return 0;
Expand Down
12 changes: 6 additions & 6 deletions lib/Command/ChangeOwnershipTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$table = $this->tableService->setOwner($id, $newOwnerUserId, '');
$output->writeln(json_encode($table->jsonSerialize(), JSON_PRETTY_PRINT));
} catch (InternalError $e) {
$output->writeln('Error occurred: '.$e->getMessage());
$this->logger->warning('Following error occurred during executing occ command "'.self::class.'"', ['exception' => $e]);
$output->writeln('Error occurred: ' . $e->getMessage());
$this->logger->warning('Following error occurred during executing occ command "' . self::class . '"', ['exception' => $e]);
return 1;
} catch (NotFoundError $e) {
$output->writeln('Not found error occurred: '.$e->getMessage());
$this->logger->warning('Following error occurred during executing occ command "'.self::class.'"', ['exception' => $e]);
$output->writeln('Not found error occurred: ' . $e->getMessage());
$this->logger->warning('Following error occurred during executing occ command "' . self::class . '"', ['exception' => $e]);
return 1;
} catch (PermissionError $e) {
$output->writeln('Permission error occurred: '.$e->getMessage());
$this->logger->warning('Following error occurred during executing occ command "'.self::class.'"', ['exception' => $e]);
$output->writeln('Permission error occurred: ' . $e->getMessage());
$this->logger->warning('Following error occurred during executing occ command "' . self::class . '"', ['exception' => $e]);
return 1;
}
return 0;
Expand Down
70 changes: 35 additions & 35 deletions lib/Command/Clean.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ protected function configure(): void {
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
$this->output = $output;
$this->dry = !!$input->getOption('dry');
$this->dry = (bool)$input->getOption('dry');

if ($this->dry) {
$this->print("Dry run activated.");
$this->print('Dry run activated.');
}
if ($output->isVerbose()) {
$this->print("Verbose mode activated.");
$this->print('Verbose mode activated.');
}

// check action, starting point for magic
Expand All @@ -90,9 +90,9 @@ private function getNextRow():void {
try {
$nextRowId = $this->rowMapper->findNextId($this->offset);
if ($nextRowId === null) {
$this->print("");
$this->print("No more rows found.", self::PRINT_LEVEL_INFO);
$this->print("");
$this->print('');
$this->print('No more rows found.', self::PRINT_LEVEL_INFO);
$this->print('');
$this->row = null;
return;
}
Expand All @@ -102,7 +102,7 @@ private function getNextRow():void {
$this->offset = $this->row->getId();
} catch (Exception $e) {
$this->print('Error while fetching row', self::PRINT_LEVEL_ERROR);
$this->logger->error('Following error occurred during executing occ command "'.self::class.'"', ['exception' => $e]);
$this->logger->error('Following error occurred during executing occ command "' . self::class . '"', ['exception' => $e]);
}
}

Expand All @@ -116,10 +116,10 @@ private function checkIfColumnsForRowsExists(): void {

$this->getNextRow();
while ($this->row) {
$this->print("");
$this->print("");
$this->print("Lets check row with id = " . $this->row->getId());
$this->print("==========================================");
$this->print('');
$this->print('');
$this->print('Lets check row with id = ' . $this->row->getId());
$this->print('==========================================');

$this->checkColumns();

Expand All @@ -130,29 +130,29 @@ private function checkIfColumnsForRowsExists(): void {
private function checkColumns(): void {
foreach ($this->row->getData() as $date) {
$valueAsString = is_string($date['value']) ? $date['value'] : json_encode($date['value']);
$suffix = strlen($valueAsString) > $this->truncateLength ? "...": "";
$this->print("");
$this->print("columnId: " . $date['columnId'] . " -> " . substr($valueAsString, 0, $this->truncateLength) . $suffix, self::PRINT_LEVEL_INFO);
$suffix = strlen($valueAsString) > $this->truncateLength ? '...': '';
$this->print('');
$this->print('columnId: ' . $date['columnId'] . ' -> ' . substr($valueAsString, 0, $this->truncateLength) . $suffix, self::PRINT_LEVEL_INFO);

try {
$this->columnService->find($date['columnId'], '');
if($this->output->isVerbose()) {
$this->print("column found", self::PRINT_LEVEL_SUCCESS);
if ($this->output->isVerbose()) {
$this->print('column found', self::PRINT_LEVEL_SUCCESS);
}
} catch (InternalError $e) {
$this->print("😱️ internal error while looking for column", self::PRINT_LEVEL_ERROR);
$this->logger->error('Following error occurred during executing occ command "'.self::class.'"', ['exception' => $e]);
$this->print('😱️ internal error while looking for column', self::PRINT_LEVEL_ERROR);
$this->logger->error('Following error occurred during executing occ command "' . self::class . '"', ['exception' => $e]);
} catch (NotFoundError $e) {
if($this->output->isVerbose()) {
$this->print("corresponding column not found.", self::PRINT_LEVEL_ERROR);
if ($this->output->isVerbose()) {
$this->print('corresponding column not found.', self::PRINT_LEVEL_ERROR);
} else {
$this->print("columnId: " . $date['columnId'] . " not found, but needed by row ".$this->row->getId(), self::PRINT_LEVEL_WARNING);
$this->print('columnId: ' . $date['columnId'] . ' not found, but needed by row ' . $this->row->getId(), self::PRINT_LEVEL_WARNING);
}
// if the corresponding column is not found, lets delete the data from the row.
$this->deleteDataFromRow($date['columnId']);
} catch (PermissionError $e) {
$this->print("😱️ permission error while looking for column", self::PRINT_LEVEL_ERROR);
$this->logger->error('Following error occurred during executing occ command "'.self::class.'"', ['exception' => $e]);
$this->print('😱️ permission error while looking for column', self::PRINT_LEVEL_ERROR);
$this->logger->error('Following error occurred during executing occ command "' . self::class . '"', ['exception' => $e]);
}
}
}
Expand All @@ -164,40 +164,40 @@ private function checkColumns(): void {
*/
private function deleteDataFromRow(int $columnId): void {
if ($this->dry) {
$this->print("Is dry run, will not remove the column data from row dataset.", self::PRINT_LEVEL_INFO);
$this->print('Is dry run, will not remove the column data from row dataset.', self::PRINT_LEVEL_INFO);
return;
}

$this->print("DANGER, start deleting", self::PRINT_LEVEL_WARNING);
$this->print('DANGER, start deleting', self::PRINT_LEVEL_WARNING);
$data = $this->row->getData();

$this->print("Data before: \t".json_encode(array_values($data)), self::PRINT_LEVEL_INFO);
$this->print("Data before: \t" . json_encode(array_values($data)), self::PRINT_LEVEL_INFO);
$key = array_search($columnId, array_column($data, 'columnId'));
unset($data[$key]);
$this->print("Data after: \t".json_encode(array_values($data)), self::PRINT_LEVEL_INFO);
$this->print("Data after: \t" . json_encode(array_values($data)), self::PRINT_LEVEL_INFO);
$this->row->setData(array_values($data));

try {
$this->rowMapper->update($this->row, $this->columnService->findAllByTable($this->row->getTableId()));
$this->print("Row successfully updated", self::PRINT_LEVEL_SUCCESS);
$this->print('Row successfully updated', self::PRINT_LEVEL_SUCCESS);
} catch (InternalError|PermissionError $e) {
$this->print("Error while updating row to db.", self::PRINT_LEVEL_ERROR);
$this->logger->error('Following error occurred during executing occ command "'.self::class.'"', ['exception' => $e]);
$this->print('Error while updating row to db.', self::PRINT_LEVEL_ERROR);
$this->logger->error('Following error occurred during executing occ command "' . self::class . '"', ['exception' => $e]);
}
}

private function print(string $message, ?int $level = null): void {
if($level === self::PRINT_LEVEL_SUCCESS) {
echo "✅ ".$message;
if ($level === self::PRINT_LEVEL_SUCCESS) {
echo '✅ ' . $message;
echo "\n";
} elseif ($level === self::PRINT_LEVEL_INFO && $this->output->isVerbose()) {
echo "ℹ️ ".$message;
echo 'ℹ️ ' . $message;
echo "\n";
} elseif ($level === self::PRINT_LEVEL_WARNING) {
echo "⚠️ ".$message;
echo '⚠️ ' . $message;
echo "\n";
} elseif ($level === self::PRINT_LEVEL_ERROR) {
echo "❌ ".$message;
echo '❌ ' . $message;
echo "\n";
} elseif ($this->output->isVerbose()) {
echo $message;
Expand Down
Loading
Loading