File index.js
has 883 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* @module core/sync
* @flow
*/
Function syncBatch
has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring. Open
async syncBatch() /*: Promise<void> */ {
let change /*: Change */ = {}
while (!this.lifecycle.willStop()) {
await this.lifecycle.ready()
- 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 applyDoc
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
async applyDoc(
doc /*: SavedMetadata */,
side /*: Writer */
) /*: Promise<*> */ {
if (doc.incompatibilities && side.name === 'local') {
- 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 syncBatch
has 136 lines of code (exceeds 25 allowed). Consider refactoring. Open
async syncBatch() /*: Promise<void> */ {
let change /*: Change */ = {}
while (!this.lifecycle.willStop()) {
await this.lifecycle.ready()
Function compareChanges
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
const compareChanges = (
{ operation: opA, doc: docA } /*: Change */,
{ operation: opB, doc: docB } /*: Change */
) => {
// Operations on different sides don't have dependencies for now. This will
- 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 applyDoc
has 88 lines of code (exceeds 25 allowed). Consider refactoring. Open
async applyDoc(
doc /*: SavedMetadata */,
side /*: Writer */
) /*: Promise<*> */ {
if (doc.incompatibilities && side.name === 'local') {
Function blockSyncFor
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
blockSyncFor(
cause
/*: {| err: RemoteError |} | {| err: SyncError, change: Change |} */
) {
log.debug(cause, 'blocking sync for error')
Sync
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class Sync {
/*::
changes: any
events: EventEmitter
ignore: Ignore
Function detectOperation
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
const detectOperation = async (
change /*: PouchDBFeedData */,
sync /*: Sync */
) /*: Promise<SyncOperation> */ => {
const outdatedSide = sync.selectSide(change)
- 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 getNextChanges
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getNextChanges(seq /*: number */) /*: Promise<Change[]> */ {
const stopMeasure = measureTime('Sync#getNextChanges')
const opts = {
...this.baseChangeOptions(seq),
include_docs: true,
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 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 trashWithParentOrByItself
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
async trashWithParentOrByItself(
doc /*: SavedMetadata */,
side /*: Writer */
) /*: Promise<void> */ {
const parentPath = dirname(doc.path)
- 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 detectOperation
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
const detectOperation = async (
change /*: PouchDBFeedData */,
sync /*: Sync */
) /*: Promise<SyncOperation> */ => {
const outdatedSide = sync.selectSide(change)
Function apply
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
async apply(change /*: Change */) /*: Promise<void> */ {
let stopMeasure = () => {}
try {
this.events.emit('sync-current', change.seq)
Function trashWithParentOrByItself
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
async trashWithParentOrByItself(
doc /*: SavedMetadata */,
side /*: Writer */
) /*: Promise<void> */ {
const parentPath = dirname(doc.path)
Function blockSyncFor
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
blockSyncFor(
cause
/*: {| err: RemoteError |} | {| err: SyncError, change: Change |} */
) {
log.debug(cause, 'blocking sync for 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 start
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
async start() /*: Promise<void> */ {
if (this.lifecycle.willStop()) {
await this.lifecycle.stopped()
} else {
return
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
Avoid deeply nested control flow statements. Open
if (
(side.name === 'local' && metadata.equivalentLocal(outdated, doc)) ||
(side.name === 'remote' && metadata.equivalentRemote(outdated, doc))
) {
log.debug({ path: doc.path }, 'Ignoring timestamp-only change')
Avoid deeply nested control flow statements. Open
if (change.doc.docType === metadata.FILE) {
this.events.emit('delete-file', change.doc)
}
Function getNextChanges
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
async getNextChanges(seq /*: number */) /*: Promise<Change[]> */ {
const stopMeasure = measureTime('Sync#getNextChanges')
const opts = {
...this.baseChangeOptions(seq),
include_docs: 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"
Further reading
Avoid too many return
statements within this function. Open
return { type: 'MOVE', side: outdatedSide.name } // XXX: can be move with update but we don't care for now
Avoid too many return
statements within this function. Open
return { type: 'NULL' }
Avoid too many return
statements within this function. Open
return { type: 'EDIT', side: outdatedSide.name }
Avoid too many return
statements within this function. Open
return { type: 'ADD', side: outdatedSide.name }
Avoid too many return
statements within this function. Open
if (docA.path.startsWith(docB.path + sep)) return 1
Avoid too many return
statements within this function. Open
if (docA.path.startsWith(docB.path + sep)) return 1
Avoid too many return
statements within this function. Open
if (docB.path.startsWith(docA.path + sep)) return -1
Avoid too many return
statements within this function. Open
return { type: 'DEL', side: outdatedSide.name }
Avoid too many return
statements within this function. Open
return 0
Avoid too many return
statements within this function. Open
return { type: 'EDIT', side: outdatedSide.name }
Avoid too many return
statements within this function. Open
return { type: 'ADD', side: outdatedSide.name }
Avoid too many return
statements within this function. Open
if (docB.path.startsWith(docA.path + sep)) return -1
Avoid too many return
statements within this function. Open
return { type: 'NULL' }
Function start
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
async start() /*: Promise<void> */ {
if (this.lifecycle.willStop()) {
await this.lifecycle.stopped()
} else {
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (metadata.isFile(doc)) {
this.events.emit('transfer-started', doc)
try {
await side.addFileAsync(doc, ({ transferred }) => {
// XXX: progress will never be emitted when we copy the content from
- 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 118.
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
) /*: Promise<void> */ {
this.events.emit('transfer-started', doc)
try {
await side.overwriteFileAsync(doc, ({ transferred }) => {
// XXX: progress will never be emitted when we copy the content from
- 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 118.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
const done = (data = [], err) => {
this.lifecycle.off('will-stop', done)
if (feedObserver) {
feedObserver.cancel()
- 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 66.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
const done = (data, err) => {
this.lifecycle.off('will-stop', done)
if (feedObserver) {
feedObserver.cancel()
- 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 66.
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
} else if (!metadata.wasSynced(doc)) {
log.debug({ path: doc.path }, `Applying ${doc.docType} addition`)
await this.doAdd(side, doc)
} else {
log.debug({ path: doc.path }, `Applying else for ${doc.docType} change`)
- 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 53.
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
} else if (isMarkedForDeletion(doc)) {
log.debug({ path: doc.path }, `Applying ${doc.docType} deletion`)
await this.trashWithParentOrByItself(doc, side)
} else if (!metadata.wasSynced(doc)) {
log.debug({ path: doc.path }, `Applying ${doc.docType} addition`)
- 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 53.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (doc.docType === metadata.FILE) {
this.events.emit('transfer-move', _.clone(doc), _.clone(from))
}
- 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 52.
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 (
docB.moveFrom.path.startsWith(docA.path + sep) &&
!docB.path.startsWith(docA.path + sep)
) {
return 1
- 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 52.
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 (
docA.moveFrom.path.startsWith(docB.path + sep) &&
!docA.path.startsWith(docB.path + sep)
)
return -1
- 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 52.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (doc.docType === metadata.FILE) {
this.events.emit('transfer-move', _.clone(doc), _.clone(from))
}
- 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 52.
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