Showing 415 of 610 total issues
Function getDirectoryContent
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
async function getDirectoryContent(context) {
const { client } = context
const dir = { _id: ROOT_DIR_ID, path: '/', name: '/' }
const dirContent = { [dir.name]: {} }
let resp /*: { next: boolean, bookmark?: string, data: Object[] } */ = {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function findNote
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
const findNote = async (
filePath /*: string */,
{
config,
pouch,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function defaultSorter
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
const defaultSorter = (a /*: LocalChange */, b /*: LocalChange */) => {
if (a.wip && !b.wip) return aFirst
if (b.wip && !a.wip) return bFirst
// b is deleting something which is a children of what a adds
File initial_diff.js
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
/** This step handle the events of the ChannelWatcher initial scan.
*
* Some files and directories can have been deleted while cozy-desktop was
* stopped. So, at the end of the initial scan, we have to do a diff between
* what was in pouchdb and the events from the local watcher to find what was
Function findParentMoves
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
const findParentMoves = (
change /*: RemoteChange */,
previousChanges /*: RemoteChange[] */,
encounteredMoves /*: Array<RemoteDirMove|RemoteDescendantChange> */
) => {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function create
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
create() {
this.log.debug('create')
const opts = {
...this.windowOptions(),
autoHideMenuBar: true,
Function debounce
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
function debounce(waiting /*: WaitingItem[] */, events /*: ChannelEvent[] */) {
for (let i = 0; i < events.length; i++) {
const event = events[i]
if (event.incomplete) {
Function started
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
const started = new Promise(resolve => {
this.initialScanParams.resolve = resolve
for (let eventType of [
'add',
Function identifyChange
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
identifyChange(
remoteDoc /*: CouchDBDoc|CouchDBDeletion|FullRemoteFile|RemoteDir */,
was /*: ?SavedMetadata */,
previousChanges /*: Array<RemoteChange> */,
originalMoves /*: Array<RemoteDirMove|RemoteDescendantChange> */,
Function step
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
const step = async (
changes /*: LocalChange[] */,
{ pouch, prep } /*: SendToPrepOpts */
) => {
const errors /*: Error[] */ = []
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _withDomainErrors
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
async _withDomainErrors /*:: <T: FullRemoteFile|RemoteDir> */(
data /*: Readable */,
options /*: Object */,
fn /*: () => Promise<T> */
) /*: Promise<T> */ {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function selectIcon
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
const selectIcon = info => {
if (info.path.endsWith('url')) {
return 'link'
} else if (!info.mime) {
return 'file'
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function moveAsync
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
async moveAsync /*::<T: Metadata|SavedMetadata> */(
newMetadata /*: T */,
oldMetadata /*: T */
) /*: Promise<void> */ {
const remoteId = oldMetadata.remote._id
Function p
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
const p = new Promise((resolve, reject) => {
let feedObserver
const done = (data = [], err) => {
this.lifecycle.off('will-stop', done)
Function openOAuthView
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
async openOAuthView(url /*: string */) {
try {
// Open remote OAuth flow in separate view, without Node integration.
// This avoids giving access to Node's API to remote code and allows
// remote code to load and make use of jQuery since it can't be loaded via
Function squashMoves
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
function squashMoves(changes /*: LocalChange[] */) {
log.trace('Squash moves...')
const stopMeasure = measureTime('LocalWatcher#squashMoves')
for (let i = 0; i < changes.length; i++) {
Function doTrash
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
async doTrash(
side /*: SideName */,
was /*: SavedMetadata */,
doc /*: Metadata */
) /*: Promise<void> */ {
Function waitForNewChangeOn
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
async waitForNewChangeOn(seq /*: number */, expectedPath /*: string */) {
log.debug({ path: expectedPath }, 'Waiting for new change to be merged')
return new Promise((resolve, reject) => {
const opts = {
Function setup
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
async setup() {
const clientInfo = this.clientInfo()
log.info(clientInfo, 'user config')
if (!this.config.isValid()) {
Function setupDesktop
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
const setupDesktop = async () => {
try {
// TODO: allow setting desktop up without running migrations (when opening
// a cozy-note)?
await desktop.setup()
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"