diff options
author | Joas Schilling <coding@schilljs.com> | 2022-04-11 20:13:49 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-04-11 20:13:49 +0300 |
commit | b9c75c77d9cd448fc38df29a4cbbd0fd9f1246fe (patch) | |
tree | 95b025a02274807657bb41247faa4539ffc21eb6 | |
parent | 51f8753772487c83f102b3ef7d4fb5da8ae99158 (diff) |
Fix linter
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | lib/Analyzer.php | 12 | ||||
-rw-r--r-- | lib/AppInfo/Application.php | 1 | ||||
-rw-r--r-- | lib/CacheWrapper.php | 2 | ||||
-rw-r--r-- | lib/Command/Block.php | 1 | ||||
-rw-r--r-- | lib/Notification/Notifier.php | 1 | ||||
-rw-r--r-- | lib/Settings/Admin.php | 1 | ||||
-rw-r--r-- | lib/Settings/Personal.php | 2 | ||||
-rw-r--r-- | lib/Striker.php | 15 | ||||
-rw-r--r-- | templates/admin.php | 4 | ||||
-rw-r--r-- | templates/personal.php | 8 |
10 files changed, 21 insertions, 26 deletions
diff --git a/lib/Analyzer.php b/lib/Analyzer.php index f8eeb02..7e475ea 100644 --- a/lib/Analyzer.php +++ b/lib/Analyzer.php @@ -21,7 +21,6 @@ namespace OCA\RansomwareProtection; - use OCP\App\IAppManager; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Files\ForbiddenException; @@ -31,10 +30,9 @@ use OCP\ILogger; use OCP\IRequest; class Analyzer { - - const READING = 1; - const WRITING = 2; - const DELETE = 3; + public const READING = 1; + public const WRITING = 2; + public const DELETE = 3; /** @var string[] */ protected $extensionsPlain = []; @@ -249,7 +247,7 @@ class Analyzer { if (isset($plainLengths[$ext]) && substr($name, 0 - $plainLengths[$ext]) === $ext) { $this->striker->handleMatch($mode, 'extension', $path, $ext); } - } else if (strpos($name, $ext) !== false) { + } elseif (strpos($name, $ext) !== false) { $this->striker->handleMatch($mode, 'extension', $path, $ext); } } @@ -332,7 +330,7 @@ class Analyzer { } if ($folder === 'thumbnails') { - list($fileId,) = explode('/', $innerPath, 2); + list($fileId, ) = explode('/', $innerPath, 2); $innerPath = $storage->getCache()->getPathById($fileId); if ($innerPath !== null) { diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 053a603..feaa39d 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -38,7 +38,6 @@ use OCP\Notification\IManager; use OCP\Util; class Application extends App implements IBootstrap { - public function __construct() { parent::__construct('ransomware_protection'); } diff --git a/lib/CacheWrapper.php b/lib/CacheWrapper.php index 8d925c1..783d615 100644 --- a/lib/CacheWrapper.php +++ b/lib/CacheWrapper.php @@ -27,7 +27,7 @@ use OCP\Files\Cache\ICache; use OCP\Files\ForbiddenException; use OCP\Files\Storage\IStorage; -class CacheWrapper extends Wrapper { +class CacheWrapper extends Wrapper { /** @var Analyzer */ protected $analyzer; /** @var StorageWrapper */ diff --git a/lib/Command/Block.php b/lib/Command/Block.php index 19214c8..3aeb91e 100644 --- a/lib/Command/Block.php +++ b/lib/Command/Block.php @@ -82,7 +82,6 @@ class Block extends Command { * @throws \InvalidArgumentException */ protected function execute(InputInterface $input, OutputInterface $output) { - $userId = $input->getArgument('user-id'); if (!$this->userManager->userExists($userId)) { diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index 142ee3d..966e7f1 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -23,7 +23,6 @@ namespace OCA\RansomwareProtection\Notification; - use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index a876351..ee7c3be 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -75,5 +75,4 @@ class Admin implements ISettings { public function getPriority() { return 1; } - } diff --git a/lib/Settings/Personal.php b/lib/Settings/Personal.php index 9514ae2..9ea1b11 100644 --- a/lib/Settings/Personal.php +++ b/lib/Settings/Personal.php @@ -63,7 +63,7 @@ class Personal implements ISettings { $disabledUntil = $disabledUntil === 0 ? '' : $this->l10n->l('datetime', $disabledUntil, ['width' => 'medium*|short']); return new TemplateResponse('ransomware_protection', 'personal', [ - 'disabledUntil' => $disabledUntil, + 'disabledUntil' => $disabledUntil, ], TemplateResponse::RENDER_AS_BLANK); } diff --git a/lib/Striker.php b/lib/Striker.php index cd1f5bd..4f7efb2 100644 --- a/lib/Striker.php +++ b/lib/Striker.php @@ -21,21 +21,17 @@ namespace OCA\RansomwareProtection; - -use OCP\App\IAppManager; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Files\ForbiddenException; -use OCP\Files\Storage\IStorage; use OCP\IConfig; use OCP\ILogger; use OCP\Notification\IManager; class Striker { - - const FIRST_STRIKE = 1; - const ALREADY_STRIKED = 2; - const FIFTH_STRIKE = 3; - const EXTERNAL_STRIKE = 4; + public const FIRST_STRIKE = 1; + public const ALREADY_STRIKED = 2; + public const FIFTH_STRIKE = 3; + public const EXTERNAL_STRIKE = 4; /** @var IConfig */ protected $config; @@ -75,7 +71,6 @@ class Striker { * @throws ForbiddenException */ public function handleMatch($mode, $case, $path, $pattern) { - $lastStrikes = $this->config->getUserValue($this->userId, 'ransomware_protection', 'last_strikes', '[]'); $lastStrikes = json_decode($lastStrikes, true); @@ -137,7 +132,7 @@ class Striker { protected function updateLastStrikes(array $lastStrikes, $newStrike) { $thirtyMinutesAgo = $this->time->getTime() - 30 * 60; - $lastStrikes = array_filter($lastStrikes, function($strike) use ($thirtyMinutesAgo) { + $lastStrikes = array_filter($lastStrikes, function ($strike) use ($thirtyMinutesAgo) { return $strike['time'] > $thirtyMinutesAgo; }); diff --git a/templates/admin.php b/templates/admin.php index 421eb22..5a2045a 100644 --- a/templates/admin.php +++ b/templates/admin.php @@ -35,7 +35,9 @@ script('ransomware_protection', 'ransomware_protection_admin'); <p> <input id="ransomware_protection_notes_include_biased" name="notes_include_biased" type="checkbox" class="checkbox" value="1" - <?php if ($_['notesIncludeBiased']) { print_unescaped('checked="checked"'); } ?> /> + <?php if ($_['notesIncludeBiased']) { + print_unescaped('checked="checked"'); +} ?> /> <label for="ransomware_protection_notes_include_biased"><?php p($l->t('Include note files with non-obvious names, e.g. ReadMe.TxT, info.html')); ?></label><br/> </p> diff --git a/templates/personal.php b/templates/personal.php index 45097c4..44c7d44 100644 --- a/templates/personal.php +++ b/templates/personal.php @@ -30,12 +30,16 @@ script('ransomware_protection', 'ransomware_protection'); <div id="ransomware_protection" class="section"> <h2 class="inlineblock"><?php p($l->t('Ransomware protection')); ?></h2> - <p id="ransomware_protection_protected" class="<?php if ($_['disabledUntil']) { p('hidden'); } ?>"> + <p id="ransomware_protection_protected" class="<?php if ($_['disabledUntil']) { + p('hidden'); +} ?>"> <span class="icon icon-checkmark-color svg"></span> <?php p($l->t('Protection is currently active')); ?> </p> - <p id="ransomware_protection_paused" class="<?php if (!$_['disabledUntil']) { p('hidden'); } ?>"> + <p id="ransomware_protection_paused" class="<?php if (!$_['disabledUntil']) { + p('hidden'); +} ?>"> <span class="icon icon-error-color svg"></span> <span><?php print_unescaped($l->t('Protection is currently paused until: <strong>%s</strong>', $_['disabledUntil'])); ?></span><br> |