File buttons.js
has 853 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* UI Widgets such as buttons
*/
/* global alert */
const $rdf = require('rdflib')
Function attachmentList
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
buttons.attachmentList = function (dom, subject, div, options) {
options = options || {}
var doc = options.doc || subject.doc()
if (options.modify === undefined) options.modify = true
var modify = options.modify
Function selectorPanelRefresh
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
buttons.selectorPanelRefresh = function (
list,
dom,
kb,
type,
Function refreshItem
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
var refreshItem = function (box, x) {
// Scope to hold item and x
var item, image
var setStyle = function () {
Function deleteButtonWithCheck
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
buttons.deleteButtonWithCheck = function (
dom,
container,
noun,
deleteFunction
Function selectorPanelRefresh
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
buttons.selectorPanelRefresh = function (
list,
dom,
kb,
type,
- 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 askName
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
buttons.askName = function (dom, kb, container, predicate, klass, noun) {
// eslint-disable-next-line promise/param-names
return new Promise(function (resolve, _reject) {
var form = dom.createElement('div') // form is broken as HTML behaviour can resurface on js error
// classLabel = utils.label(ns.vcard('Individual'))
Function selectorPanelRefresh
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
list,
dom,
kb,
type,
predicate,
Function findImageFromURI
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
buttons.findImageFromURI = function findImageFromURI (x) {
const iconDir = UI.icons.iconBase
// Special cases from URI scheme:
if (x.uri) {
- 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 shortDate
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
buttons.shortDate = function (str, noTime) {
if (!str) return '???'
var month = [
'Jan',
'Feb',
Function fileUploadButtonDiv
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
buttons.fileUploadButtonDiv = function fileUploadButtonDiv (
dom,
droppedFileHandler
) {
const div = dom.createElement('div')
Function propertyTriage
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
buttons.propertyTriage = function (kb) {
var possibleProperties = {}
// if (possibleProperties === undefined) possibleProperties = {}
// var kb = UI.store
var dp = {}
Function selectorPanel
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
dom,
kb,
type,
predicate,
inverse,
Function personTR
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
buttons.personTR = function (dom, pred, obj, options) {
var tr = dom.createElement('tr')
options = options || {}
// tr.predObj = [pred.uri, obj.uri] moved to acl-control
var td1 = tr.appendChild(dom.createElement('td'))
Function _trySetImage
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
buttons._trySetImage = function _trySetImage (element, thing, iconForClassMap) {
const kb = UI.store
const explitImage = buttons.findImage(thing)
if (explitImage) {
Function askName
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
buttons.askName = function (dom, kb, container, predicate, klass, noun) {
Function attachmentList
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
buttons.attachmentList = function (dom, subject, div, options) {
options = options || {}
var doc = options.doc || subject.doc()
if (options.modify === undefined) options.modify = true
var modify = options.modify
- 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 faviconOrDefault
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
var faviconOrDefault = function (dom, x) {
var image = dom.createElement('img')
image.style = UI.style.iconStyle
var isOrigin = function (x) {
if (!x.uri) return false
- 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 propertyTriage
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
buttons.propertyTriage = function (kb) {
var possibleProperties = {}
// if (possibleProperties === undefined) possibleProperties = {}
// var kb = UI.store
var dp = {}
- 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 null
Avoid too many return
statements within this function. Open
return false // we can do better
Avoid too many return
statements within this function. Open
return iconDir + 'noun_10636_grey.svg' // Grey Circle - some thing
Avoid too many return
statements within this function. Open
return 'shortdate:' + e
Function _trySetImage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
buttons._trySetImage = function _trySetImage (element, thing, iconForClassMap) {
const kb = UI.store
const explitImage = buttons.findImage(thing)
if (explitImage) {
- 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 personTR
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
buttons.personTR = function (dom, pred, obj, options) {
var tr = dom.createElement('tr')
options = options || {}
// tr.predObj = [pred.uri, obj.uri] moved to acl-control
var td1 = tr.appendChild(dom.createElement('td'))
- 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 defaultAnnotationStore
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
buttons.defaultAnnotationStore = function (subject) {
if (subject.uri === undefined) return undefined
var s = subject.uri
if (s.slice(0, 7) !== 'http://') return undefined
s = s.slice(7) // Remove
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
buttons.refreshTree = function refreshTree (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
Similar blocks of code found in 2 locations. Consider refactoring. Open
kb.any(x, ns.vcard('fn')) ||
kb.any(x, ns.foaf('name')) ||
kb.any(x, ns.vcard('organization-name'))
- 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 60.
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
kb.any(thing, ns.sioc('avatar')) ||
kb.any(thing, ns.foaf('img')) ||
kb.any(thing, ns.vcard('logo')) ||
- 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 60.
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