File main.js
has 571 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict'
require('../core/globals')
// Initialize `remote` module so that renderer processes can use it.
Function updateState
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
const updateState = async ({ newState, data }) => {
const { status, filename, userAlerts, errors } = data || {}
if (newState === 'sync-state') {
if (status === 'uptodate') tray.setStatus('online')
- 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 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"
Further reading
Function showWindow
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
const showWindow = async bounds => {
if (
notificationsState.revokedAlertShown ||
notificationsState.syncDirUnlinkedShown
)
- 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 setupDesktop
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
const setupDesktop = async () => {
try {
// TODO: allow setting desktop up without running migrations (when opening
// a cozy-note)?
await desktop.setup()
Function showRevokedCozyError
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
const showRevokedCozyError = async () => {
// prevent the alert from appearing twice
if (notificationsState.revokedAlertShown) return
notificationsState.revokedAlertShown = true
Function startSync
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
const startSync = async () => {
enqueueStateUpdate('syncing')
desktop.events.on('sync-state', state => {
enqueueStateUpdate('sync-state', state)
})
Function showWindow
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const showWindow = async bounds => {
if (
notificationsState.revokedAlertShown ||
notificationsState.syncDirUnlinkedShown
)
Function sendErrorToMainWindow
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const sendErrorToMainWindow = async ({ msg, code }) => {
if (code === COZY_CLIENT_REVOKED_CODE) {
return showRevokedCozyError()
} else if (msg === SYNC_DIR_UNLINKED_MESSAGE) {
if (notificationsState.syncDirUnlinkedShown) return
- 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 showRevokedCozyError
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const showRevokedCozyError = async () => {
// prevent the alert from appearing twice
if (notificationsState.revokedAlertShown) return
notificationsState.revokedAlertShown = true
- 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"