Function UserInput
has a Cognitive Complexity of 444 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function UserInput (outline) {
var kb = UI.store
var myDocument = outline.document // is this ok?
// UI.log.warn("myDocument when it's set is "+myDocument.location);
- 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 UserInput
has 1799 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function UserInput (outline) {
var kb = UI.store
var myDocument = outline.document // is this ok?
// UI.log.warn("myDocument when it's set is "+myDocument.location);
File userInput.js
has 1806 lines of code (exceeds 250 allowed). Consider refactoring. Open
// Original author: kennyluck
//
// Kenny's Notes:
/* places to generate SPARQL update: clearInputAndSave() pasteFromClipboard()->insertTermTo();
undetermined statement generated formUndetStat()
Function showMenu
has 361 lines of code (exceeds 25 allowed). Consider refactoring. Open
showMenu: function showMenu (
e,
menuType,
inputQuery,
extraInformation,
Function clearInputAndSave
has 242 lines of code (exceeds 25 allowed). Consider refactoring. Open
clearInputAndSave: function clearInputAndSave (e) {
if (!this.lastModified) return
if (!this.lastModified.isNew) {
try {
var obj = this.getStatementAbout(this.lastModified).object
Function getAutoCompleteHandler
has 191 lines of code (exceeds 25 allowed). Consider refactoring. Open
getAutoCompleteHandler: function getAutoCompleteHandler (mode) {
qp('\n\n***** In getAutoCompleteHandler ****** mode = ' + mode)
if (mode === 'PredicateAutoComplete') {
mode = 'predicate'
} else if (mode !== 'JournalTAC') {
Function fillInRequest
has 156 lines of code (exceeds 25 allowed). Consider refactoring. Open
fillInRequest: function fillInRequest (type, selectedTd, inputTerm) {
var tr = selectedTd.parentNode
var stat
var isInverse
stat = tr.AJAR_statement
Function Refill
has 111 lines of code (exceeds 25 allowed). Consider refactoring. Open
Refill: function Refill (e, selectedTd) {
UI.log.info('Refill' + selectedTd.textContent)
var isPredicate = selectedTd.nextSibling
var predicateQuery
if (isPredicate) {
Function insertTermTo
has 101 lines of code (exceeds 25 allowed). Consider refactoring. Open
insertTermTo: function insertTermTo (selectedTd, term, isObject) {
switch (selectedTd.className) {
case 'undetermined selected':
var defaultpropview = this.views.defaults[
selectedTd.parentNode.AJAR_statement.predicate.uri
Function deleteTriple
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
deleteTriple: function deleteTriple (selectedTd, isBackOut) {
// ToDo: complete deletion of a node
UI.log.debug('deleteTriple entered')
// allow a pending node to be deleted if it's a backout sent by SPARQL update callback
Function addNewPredicateObject
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
addNewPredicateObject: function addNewPredicateObject (e) {
if (UI.utils.getTarget(e).className !== 'bottom-border-active') return
var This = outline.UserInput
var target = UI.utils.getTarget(e)
Function literalModification
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
literalModification: function literalModification (selectedTd) {
UI.log.debug(
'entering literal Modification with ' +
selectedTd +
selectedTd.textContent
Function pasteFromClipboard
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
pasteFromClipboard: function pasteFromClipboard (address, selectedTd) {
function termFrom (fromCode) {
var term = outline.clipboard[fromCode].shift()
if (term === null) {
UI.log.warn('no more element in clipboard!')
Function appendToPredicate
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
appendToPredicate: function appendToPredicate (predicateTd) {
var isEnd = false
var trIterator
try {
for (
Function generateRequest
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
generateRequest: function generateRequest (
tipText,
trNew,
isPredicate,
notShow
Function addNewObject
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
addNewObject: function addNewObject (e) {
var predicateTd = UI.utils.getTarget(e).parentNode.parentNode
// var predicateTerm = UI.utils.getAbout(kb, predicateTd)
var isInverse = predicateTd.parentNode.AJAR_inverse
// var titleTerm=UI.utils.getAbout(kb,UI.utils.ancestor(predicateTd.parentNode,'TD'));
Avoid deeply nested control flow statements. Open
if (enterEvent.keyCode === 37) {
setHighlightItem(menu.lastHighlight.previousSibling)
} else {
setHighlightItem(menu.lastHighlight.nextSibling)
}
Avoid deeply nested control flow statements. Open
switch (menu.lastHighlight.value) {
case 'New...':
qp('subcase New')
outline.UserInput.createNew()
break
Avoid deeply nested control flow statements. Open
if (mode === 'JournalTAC') {
outline.UserInput.clearMenu()
qp('no lastH')
return 'no lastH'
}
Avoid deeply nested control flow statements. Open
if (mode === 'JournalTAC') {
qp('movedArrow? ' + movedArrow)
// Enter only works if arrows have been moved
if (movedArrow && menu.lastHighlight) {
// Get the title from the DOM
Avoid deeply nested control flow statements. Open
if (!isInverse) {
newStats = kb.statementsMatching(
stat.subject,
stat.predicate,
inputTerm,
Avoid deeply nested control flow statements. Open
if (kb.any(undefined, selectedPredicate, textTerm)) {
if (!e) {
// keyboard
var tdNode = this.lastModified.parentNode
e = {}
Function formUndetStat
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
trNode,
subject,
predicate,
object,
why,
Avoid deeply nested control flow statements. Open
if (!newStats.length) {
UI.log.error("userinput.js 1711: Can't find statememt!")
}
Function showMenu
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
e,
menuType,
inputQuery,
extraInformation,
_order
Avoid too many return
statements within this function. Open
return
Avoid too many return
statements within this function. Open
return
Avoid too many return
statements within this function. Open
return
Avoid too many return
statements within this function. Open
return
Avoid too many return
statements within this function. Open
return 'nothing to return'
Avoid too many return
statements within this function. Open
return
Avoid too many return
statements within this function. Open
return 'asGivenTxt'
Avoid too many return
statements within this function. Open
return
Avoid too many return
statements within this function. Open
return
Avoid too many return
statements within this function. Open
return "I'm a little Down Arrow"
Avoid too many return
statements within this function. Open
return
Avoid too many return
statements within this function. Open
return
Avoid too many return
statements within this function. Open
return
Avoid too many return
statements within this function. Open
return
Avoid too many return
statements within this function. Open
return // The new Td is already generated by fillInRequest, so it's done.
Avoid too many return
statements within this function. Open
return
Avoid too many return
statements within this function. Open
return "I'm a little Arrow Up"
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (UI.utils.getTarget(e).className === 'bottom-border') {
border.style.borderColor = 'rgb(100%,65%,0%)'
border.style.cursor = 'copy'
}
- 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 57.
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 (UI.utils.getTarget(e).className === 'bottom-border') {
border.style.borderColor = 'transparent'
border.style.cursor = 'auto'
}
- 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 57.
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
s = kb.add(
s.subject,
s.predicate,
kb.literal(this.lastModified.value),
s.why
- 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 46.
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
s2 = $rdf.st(
s.subject,
s.predicate,
kb.literal(this.lastModified.value),
s.why
- 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 46.
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