Skip to content

Commit

Permalink
fix code smells and set baseline
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
  • Loading branch information
blizzz committed Feb 28, 2023
1 parent 5610895 commit 850b8de
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
use OCP\WorkflowEngine\IRuleMatcher;
use OCP\WorkflowEngine\ISpecificOperation;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\GenericEvent as LegacyGenericEvent;
use UnexpectedValueException;

class Operation implements ISpecificOperation {
Expand Down Expand Up @@ -120,7 +119,6 @@ public function isAvailableForScope(int $scope): bool {

public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatcher): void {
if (!$event instanceof GenericEvent
&& !$event instanceof LegacyGenericEvent
&& !$event instanceof MapperEvent) {
return;
}
Expand Down Expand Up @@ -218,7 +216,7 @@ protected function buildCommand(string $template, Node $node, string $event, arr
$nodeID = $node->getId();
} catch (InvalidPathException | NotFoundException $e) {
}
$command = str_replace('%i', escapeshellarg($nodeID), $command);
$command = str_replace('%s', escapeshellarg((string)$nodeID), $command);
}

if (strpos($command, '%a')) {
Expand Down
30 changes: 30 additions & 0 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.30.0@d0bc6e25d89f649e4f36a534f330f8bb4643dd69">
<file src="lib/BackgroundJobs/Launcher.php">
<ForbiddenCode occurrences="1">
<code>shell_exec($wrapper)</code>
</ForbiddenCode>
<UndefinedClass occurrences="1">
<code>View</code>
</UndefinedClass>
</file>
<file src="lib/Operation.php">
<ForbiddenCode occurrences="1">
<code>shell_exec('command -v ' . escapeshellarg($scriptName))</code>
</ForbiddenCode>
<MissingDependency occurrences="5">
<code>$this-&gt;rootFolder</code>
<code>$this-&gt;rootFolder</code>
<code>$this-&gt;rootFolder</code>
<code>IRootFolder</code>
<code>IRootFolder</code>
</MissingDependency>
<UndefinedClass occurrences="5">
<code>File</code>
<code>GroupFolderStorage</code>
<code>NoUserException</code>
<code>SharedStorage</code>
<code>View</code>
</UndefinedClass>
</file>
</files>

0 comments on commit 850b8de

Please sign in to comment.