Showing 610 of 610 total issues
Function stop
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
async stop(force /*: ?bool */ = false) {
log.debug('Stopping watcher...')
if (!this.watcher) 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 apply
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
async apply(change /*: Change */) /*: Promise<void> */ {
let stopMeasure = () => {}
try {
this.events.emit('sync-current', change.seq)
- 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 isIgnored
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
isIgnored(
{ relativePath, isFolder } /*: {relativePath: string, isFolder: boolean} */
) /*: boolean */ {
let result = false
for (let pattern of Array.from(this.patterns)) {
- 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 retry
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const retry = async (
cause /*: {| err: RemoteError |} | {| err: SyncError, change: Change |} */,
sync /*: Sync */
) => {
log.debug(cause, 'retrying after blocking 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 match
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function match(
path /*: string */,
isFolder /*: boolean */,
pattern /*: IgnorePattern */
) /*: boolean */ {
- 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 setupInitialState
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const setupInitialState = (scenario /*: Scenario */) => {
if (scenario.init == null) return
debug('[init]')
return Promise.each(scenario.init, opts => {
let { ino, path: relpath, content } = opts
Function getSession
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const getSession = (
session /*: Session */,
userAgent /*: string */
) /*: Session */ => {
const syncSession = session.fromPartition(SESSION_PARTITION_NAME, {
Function placeWithTray
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
placeWithTray(
wantedWidth /*: number */,
wantedHeight /*: number */,
trayposition /*: Bounds */
) {
Function fromRemoteFile
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fromRemoteFile(remoteFile /*: MetadataRemoteFile */) /*: Metadata */ {
const doc /*: Object */ = {
docType: localDocType(remoteFile.type),
path: pathUtils.remoteToLocal(remoteFile.path),
size: parseInt(remoteFile.size, 10),
Function includeAddEventInFileMove
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function includeAddEventInFileMove(
sameInodeChange /*: ?LocalChange */,
e /*: LocalFileAdded */
) {
const moveChange /*: ?LocalFileMove */ = maybeMoveFile(sameInodeChange)
Function trashAsync
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async trashAsync(doc /*: SavedMetadata */) /*: Promise<void> */ {
log.info({ path: doc.path }, 'Moving to the OS trash...')
const fullpath = path.join(this.syncPath, doc.path)
try {
await this.sendToTrash(fullpath)
Function buildPattern
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function buildPattern(line /*: string */) /*: IgnorePattern */ {
let folder = false
let negate = false
let noslash = line.indexOf('/') === -1
if (line.indexOf('**') !== -1) {
Function moveFileAsync
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
async moveFileAsync(
side /*: SideName */,
doc /*: Metadata */,
was /*: SavedMetadata */
) {
Function init
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const init = (app, listener) => {
tray = new Tray(nativeImage.createEmpty())
// XXX: updating the status should always come after the initialization of the
// `tray` as we use it.
Function debounce
has 26 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) {
continue
Function rebuildIncompleteEvent
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function rebuildIncompleteEvent(
previousEvent /*: ChannelEvent */,
nextEvent /*: ChannelEvent */,
opts /*: { config: Config , checksumer: Checksumer, pouch: Pouch } */
) /*: Promise<Completion> */ {
Function uploadFileToSupport
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
async uploadFileToSupport(
incident /*: string */,
name /*: string */,
data /*: string|stream.Readable */
) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (type === 'folder') {
const dirNameMaxBytes = detectDirNameLengthIncompatibility(
name,
restrictions
)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 55.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (order < 0) {
// node should come first
newNode.dependentOn.push(node)
if (createsCycle(newNode)) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 55.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (e.type === 'unlinkDir' && e.old && e.old.docType === metadata.FILE) {
log.warn(
{ event: e, old: e.old, path: e.path },
'chokidar miscategorized event (was file, event unlinkDir)'
)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 55.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76