Function notepad
has a Cognitive Complexity of 184 (exceeds 5 allowed). Consider refactoring. Open
UI.pad.notepad = function (dom, padDoc, subject, me, options) {
options = options || {}
var exists = options.exists
var table = dom.createElement('table')
var kb = UI.store
- 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 notepad
has 580 lines of code (exceeds 25 allowed). Consider refactoring. Open
UI.pad.notepad = function (dom, padDoc, subject, me, options) {
options = options || {}
var exists = options.exists
var table = dom.createElement('table')
var kb = UI.store
File pad.js
has 742 lines of code (exceeds 250 allowed). Consider refactoring. Open
/** **************
* Notepad Widget
*/
/** @module UI.pad
Function addListeners
has 165 lines of code (exceeds 25 allowed). Consider refactoring. Open
var addListeners = function (part, chunk) {
part.addEventListener('keydown', function (event) {
var queueProperty, queue
// up 38; down 40; left 37; right 39 tab 9; shift 16; escape 27
switch (event.keyCode) {
Function updateStore
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
var updateStore = function (part) {
var chunk = part.subject
setPartStyle(part, undefined, true)
var old = kb.any(chunk, ns.sioc('content')).value
var del = [$rdf.st(chunk, ns.sioc('content'), old, padDoc)]
Function newChunk
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
var newChunk = function (ele, before) {
// element of chunk being split
var kb = UI.store
var indent = 0
var queueProperty = null
Function consistencyCheck
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
var consistencyCheck = function () {
var found = []
var failed = 0
function complain2 (msg) {
complain(msg)
Function sync
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
var sync = function () {
// var first = kb.the(subject, PAD('next'))
if (kb.each(subject, PAD('next')).length !== 1) {
var msg =
'Pad: Inconsistent data - NEXT pointers: ' +
Function removePart
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
var removePart = function (part) {
var chunk = part.subject
if (!chunk) throw new Error('No chunk for line to be deleted!') // just in case
var prev = kb.any(undefined, PAD('next'), chunk)
var next = kb.any(chunk, PAD('next'))
Function renderPartipants
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
UI.pad.renderPartipants = function (dom, table, padDoc, subject, me, options) {
table.setAttribute('style', 'margin: 0.8em;')
var newRowForParticpation = function (parp) {
var person = kb.any(parp, ns.wf('participant'))
Function participationObject
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
UI.pad.participationObject = function (subject, padDoc, me) {
return new Promise(function (resolve, reject) {
if (!me) {
throw new Error('Not user id')
}
Function reloadAndSync
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
var reloadAndSync = function () {
if (reloading) {
console.log(' Already reloading - stop')
return // once only needed
}
Function recordParticipation
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
UI.pad.recordParticipation = function (subject, padDoc, refreshable) {
var me = UI.authn.currentUser()
if (!me) return // Not logged in
var parps = kb.each(subject, ns.wf('participation')).filter(function (pn) {
Function setPartStyle
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
var setPartStyle = function (part, colors, pending) {
var chunk = part.subject
colors = colors || ''
var baseStyle =
'font-size: 100%; font-family: monospace; width: 100%; border: none; white-space: pre-wrap;'
Function tryReload
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
var tryReload = function () {
console.log('try reload - timeout = ' + retryTimeout)
updater.reload(updater.store, padDoc, function (ok, message, xhr) {
reloading = false
if (ok) {
Function manageParticipation
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
dom,
container,
padDoc,
subject,
me,
Function renderPartipants
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
UI.pad.renderPartipants = function (dom, table, padDoc, subject, me, options) {
Function notepad
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
UI.pad.notepad = function (dom, padDoc, subject, me, options) {
Function participationObject
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
UI.pad.participationObject = function (subject, padDoc, me) {
return new Promise(function (resolve, reject) {
if (!me) {
throw new Error('Not user id')
}
- 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
var hash = function (x) {
return x.split('').reduce(function (a, b) {
a = (a << 5) - a + b.charCodeAt(0)
return a & a
}, 0)
- 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 74.
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
var refreshTree = function (root) {
if (root.refresh) {
root.refresh()
return
}
- 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 72.
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
var parps = kb.each(subject, ns.wf('participation')).filter(function (pn) {
return kb.holds(pn, ns.wf('participant'), me)
})
- 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 58.
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
var parps = kb.each(subject, ns.wf('participation')).filter(function (pn) {
return kb.holds(pn, ns.wf('participant'), me)
})
- 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 58.
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
case 38: // Up
if (part.parentNode.previousSibling) {
part.parentNode.previousSibling.firstChild.focus()
event.preventDefault()
}
- 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 54.
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
case 40: // Down
if (part.parentNode.nextSibling) {
part.parentNode.nextSibling.firstChild.focus()
event.preventDefault()
}
- 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 54.
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