Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
korelstar committed Feb 6, 2020
1 parent 4296e72 commit 2f68f2e
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 25 deletions.
4 changes: 2 additions & 2 deletions lib/Controller/NotesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function get($id) {
$this->userId,
$this->appName,
'notesLastViewedNote',
$id
strval($id)
);

$note = $this->notesService->get($id, $this->userId);
Expand Down Expand Up @@ -180,7 +180,7 @@ public function category($id, $category) {
*/
public function favorite($id, $favorite) {
$result = $this->notesService->favorite($id, $favorite, $this->userId);
return new DataResponse($result);
return new DataResponse($result); // @phan-suppress-current-line PhanTypeMismatchArgument
}


Expand Down
3 changes: 0 additions & 3 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@

use OCP\AppFramework\Controller;

use OCP\IConfig;
use OCP\IRequest;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Files\IRootFolder;
use OCP\AppFramework\Http\JSONResponse;
use OCA\Notes\Service\SettingsService;

Expand Down
9 changes: 5 additions & 4 deletions lib/Db/Note.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class Note extends Entity {
public $error = false;
public $errorMessage='';

private const TAG_FAVORITE = \OC\Tags::TAG_FAVORITE; // @phan-suppress-current-line PhanUndeclaredClassConstant

public function __construct() {
$this->addType('modified', 'integer');
$this->addType('favorite', 'boolean');
Expand All @@ -54,7 +56,6 @@ public static function fromFile(File $file, Folder $notesFolder, $tags = [], $on
$fileContent=$file->getContent();
$note->setContent(self::convertEncoding($fileContent));
}
$note->setModified($file->getMTime());
if (!$onlyMeta) {
$note->updateETag();
}
Expand All @@ -72,7 +73,6 @@ public static function fromException($message, File $file, Folder $notesFolder,
$note->setErrorMessage($message);
$note->setError(true);
$note->setContent($message);
$note->setModified(null);
$note->resetUpdatedFields();
return $note;
}
Expand All @@ -87,11 +87,12 @@ private static function convertEncoding($str) {
private function initCommonBaseFields(File $file, Folder $notesFolder, $tags) {
$this->setId($file->getId());
$this->setTitle(pathinfo($file->getName(), PATHINFO_FILENAME)); // remove extension
$this->setModified($file->getMTime());
$subdir = substr(dirname($file->getPath()), strlen($notesFolder->getPath())+1);
$this->setCategory($subdir ? $subdir : '');
if (is_array($tags) && in_array(\OC\Tags::TAG_FAVORITE, $tags)) {
if (is_array($tags) && in_array(self::TAG_FAVORITE, $tags)) {
$this->setFavorite(true);
//unset($tags[array_search(\OC\Tags::TAG_FAVORITE, $tags)]);
//unset($tags[array_search(self::TAG_FAVORITE, $tags)]);
}
}

Expand Down
1 change: 0 additions & 1 deletion lib/Service/MetaService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace OCA\Notes\Service;

use OCA\Notes\Db\Note;
use OCA\Notes\Db\Meta;
use OCA\Notes\Db\MetaMapper;

Expand Down
19 changes: 12 additions & 7 deletions lib/Service/NoteUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,37 @@

namespace OCA\Notes\Service;

use OCP\IDBConnection;
use OCP\IL10N;
use OCP\ILogger;
use OCP\Encryption\Exceptions\GenericEncryptionException;
use OCP\Files\IRootFolder;
use OCP\Files\FileInfo;
use OCP\Files\File;
use OCP\Files\Folder;

use OCA\Notes\Db\Note;

class NoteUtil {

private $db;
private $l10n;
private $root;
private $logger;
private $appName;

/**
* @param IDBConnection $db
* @param IRootFolder $root
* @param IL10N $l10n
* @param ILogger $logger
* @param String $appName
*/
public function __construct(
IDBConnection $db,
IRootFolder $root,
IL10N $l10n,
ILogger $logger,
$appName
) {
$this->db = $db;
$this->root = $root;
$this->l10n = $l10n;
$this->logger = $logger;
Expand All @@ -44,7 +46,7 @@ public function gatherNoteFiles(Folder $folder) : array {
$notes = [];
$nodes = $folder->getDirectoryListing();
foreach ($nodes as $node) {
if ($node->getType() === FileInfo::TYPE_FOLDER) {
if ($node->getType() === FileInfo::TYPE_FOLDER && $node instanceof Folder) {
$notes = array_merge($notes, $this->gatherNoteFiles($node));
continue;
}
Expand All @@ -59,7 +61,7 @@ public function gatherNoteFiles(Folder $folder) : array {
/**
* test if file is a note
*/
public function isNote(File $file) : bool {
public function isNote(FileInfo $file) : bool {
$allowedExtensions = ['txt', 'org', 'markdown', 'md', 'note'];
$ext = strtolower(pathinfo($file->getName(), PATHINFO_EXTENSION));
return $file->getType() === 'file' && in_array($ext, $allowedExtensions);
Expand Down Expand Up @@ -96,7 +98,10 @@ public function moveNote(Folder $notesFolder, File $file, $category, string $tit
$file->move($newFilePath);
}
if ($currentBasePath !== $basePath) {
$this->deleteEmptyFolder($notesFolder, $this->root->get($currentBasePath));
$fileBasePath = $this->root->get($currentBasePath);
if ($fileBasePath instanceof Folder) {
$this->deleteEmptyFolder($notesFolder, $fileBasePath);
}
}
}

Expand Down Expand Up @@ -171,7 +176,7 @@ public function sanitisePath(string $str) : string {

// if mysql doesn't support 4byte UTF-8, then remove those characters
// see \OC\Files\Storage\Common::verifyPath(...)
if (!\OC::$server->getDatabaseConnection()->supports4ByteText()) {
if (!$this->db->supports4ByteText()) {
$str = preg_replace('%(?:
\xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
Expand Down
1 change: 0 additions & 1 deletion lib/Service/NotesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use OCP\Encryption\Exceptions\GenericEncryptionException;
use OCP\Files\File;
use OCP\Files\FileInfo;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\IConfig;
Expand Down
7 changes: 0 additions & 7 deletions lib/Service/SettingsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@

namespace OCA\Notes\Service;

use OCP\AppFramework\Controller;

use OCP\IConfig;
use OCP\IRequest;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Files\IRootFolder;
use OCP\AppFramework\Http\JSONResponse;

class SettingsService {

Expand Down
1 change: 1 addition & 0 deletions src/components/EditorMarkdownIt.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<template>
<!-- eslint-disable-next-line vue/no-v-html -->
<div class="note-preview" v-html="html" />
</template>
<script>
Expand Down

0 comments on commit 2f68f2e

Please sign in to comment.