-
Notifications
You must be signed in to change notification settings - Fork 87
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
fix(psalm): Fix all @throws annotations and add missing ones #3270
base: master
Are you sure you want to change the base?
Changes from all commits
aeb65d8
88a14b6
92fa99d
111f1de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,11 @@ | |
*/ | ||
namespace OCA\GroupFolders\AppInfo; | ||
|
||
use OCA\Circles\Exceptions\RequestBuilderException; | ||
use OCA\GroupFolders\Folder\FolderManager; | ||
use OCP\App\IAppManager; | ||
use OCP\Capabilities\ICapability; | ||
use OCP\DB\Exception; | ||
use OCP\IUser; | ||
use OCP\IUserSession; | ||
|
||
|
@@ -21,6 +23,10 @@ public function __construct( | |
) { | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
* @throws RequestBuilderException | ||
*/ | ||
Comment on lines
+26
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be caught inside, this method is not documented as throwing in ICapability and should not throw. |
||
public function getCapabilities(): array { | ||
$user = $this->userSession->getUser(); | ||
if (!$user) { | ||
|
@@ -35,6 +41,10 @@ public function getCapabilities(): array { | |
]; | ||
} | ||
|
||
/** | ||
* @throws RequestBuilderException | ||
* @throws Exception | ||
*/ | ||
private function hasFolders(IUser $user): bool { | ||
$folders = $this->folderManager->getFoldersForUser($user); | ||
return count($folders) > 0; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,17 +10,26 @@ | |
|
||
use OC\Core\Command\Base; | ||
use OCA\GroupFolders\Folder\FolderManager; | ||
use OCP\DB\Exception; | ||
use Symfony\Component\Console\Exception\InvalidArgumentException; | ||
use Symfony\Component\Console\Exception\LogicException; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class Create extends Base { | ||
/** | ||
* @throws LogicException | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when? Add a description please |
||
*/ | ||
public function __construct( | ||
private FolderManager $folderManager, | ||
) { | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* @throws InvalidArgumentException | ||
*/ | ||
protected function configure(): void { | ||
$this | ||
->setName('groupfolders:create') | ||
|
@@ -29,6 +38,10 @@ protected function configure(): void { | |
parent::configure(); | ||
} | ||
|
||
/** | ||
* @throws Exception | ||
* @throws InvalidArgumentException | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output): int { | ||
$id = $this->folderManager->createFolder($input->getArgument('name')); | ||
$output->writeln((string)$id); | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -9,17 +9,25 @@ | |||||||||||||
namespace OCA\GroupFolders\Command\ExpireGroup; | ||||||||||||||
|
||||||||||||||
use OC\Core\Command\Base; | ||||||||||||||
use Symfony\Component\Console\Exception\InvalidArgumentException; | ||||||||||||||
use Symfony\Component\Console\Exception\LogicException; | ||||||||||||||
use Symfony\Component\Console\Input\InputInterface; | ||||||||||||||
use Symfony\Component\Console\Output\OutputInterface; | ||||||||||||||
|
||||||||||||||
/** | ||||||||||||||
* Base class for the group folder expiration commands. | ||||||||||||||
*/ | ||||||||||||||
class ExpireGroupBase extends Base { | ||||||||||||||
/** | ||||||||||||||
* @throws LogicException | ||||||||||||||
*/ | ||||||||||||||
public function __construct() { | ||||||||||||||
parent::__construct(); | ||||||||||||||
} | ||||||||||||||
Comment on lines
+21
to
26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
dead code |
||||||||||||||
|
||||||||||||||
/** | ||||||||||||||
* @throws InvalidArgumentException | ||||||||||||||
*/ | ||||||||||||||
protected function configure(): void { | ||||||||||||||
$this | ||||||||||||||
->setName('groupfolders:expire') | ||||||||||||||
|
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.
When does that throw Throwable? For me that should never be documented, Throwable which are not Exception are bugs to be fixed, not documented. Anything can throw a Throwable if you use it wrong.
Would also be good if those
@throws
tag would include a description of when to expect a throw.