File utils.js
has 512 lines of code (exceeds 250 allowed). Consider refactoring. Open
// Solid-UI general Utilities
// ==========================
//
// This must load AFTER the rdflib.js and log-ext.js (or log.js).
//
Function label
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
function label (x, initialCap) {
// x is an object
function doCap (s) {
// s = s.toString()
if (initialCap) return s.slice(0, 1).toUpperCase() + s.slice(1)
- 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 shortName
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
function shortName (uri) {
let p = uri
if ('#/'.indexOf(p[p.length - 1]) >= 0) p = p.slice(0, -1)
const namespaces = []
for (const ns in this.prefixes) {
- 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 label
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
function label (x, initialCap) {
// x is an object
function doCap (s) {
// s = s.toString()
if (initialCap) return s.slice(0, 1).toUpperCase() + s.slice(1)
Function syncTableToArray
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function syncTableToArray (table, things, createNewRow) {
let foundOne
let row
let i
- 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 syncTableToArrayReOrdered
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function syncTableToArrayReOrdered (table, things, createNewRow) {
const elementMap = {}
for (let i = 0; i < table.children.length; i++) {
const row = table.children[i]
- 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 ontologyLabel
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function ontologyLabel (term) {
if (term.uri === undefined) return '??'
var s = term.uri
var namespaces = []
var i = s.lastIndexOf('#')
- 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 syncTableToArray
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function syncTableToArray (table, things, createNewRow) {
let foundOne
let row
let i
Function ontologyLabel
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function ontologyLabel (term) {
if (term.uri === undefined) return '??'
var s = term.uri
var namespaces = []
var i = s.lastIndexOf('#')
Function shortName
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function shortName (uri) {
let p = uri
if ('#/'.indexOf(p[p.length - 1]) >= 0) p = p.slice(0, -1)
const namespaces = []
for (const ns in this.prefixes) {
Function getTerm
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function getTerm (target) {
var statementTr = target.parentNode
var st = statementTr ? statementTr.AJAR_statement : undefined
var className = st ? target.className : '' // if no st then it's necessary to use getAbout
- 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 syncTableToArrayReOrdered
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function syncTableToArrayReOrdered (table, things, createNewRow) {
const elementMap = {}
for (let i = 0; i < table.children.length; i++) {
const row = table.children[i]
Function predicateLabelForXML
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function predicateLabelForXML (p, inverse) {
var lab
if (inverse) {
// If we know an inverse predicate, use its label
var ip = UI.store.any(p, UI.ns.owl('inverseOf'))
- 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 stackString
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function stackString (e) {
let str = '' + e + '\n'
let i
if (!e.stack) {
return str + 'No stack available.\n'
- 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 term.uri + '!?' // strange should have a nice part
Avoid too many return
statements within this function. Open
if (hash >= 0) return cleanUp(s.slice(hash + 1))
Avoid too many return
statements within this function. Open
if (slash >= 0 && slash < x.uri.length) return cleanUp(s.slice(slash + 1))
Avoid too many return
statements within this function. Open
return doCap(decodeURIComponent(x.uri))
Avoid too many return
statements within this function. Open
for (i = 0; ; i++) if (canUse(p.slice(0, 3) + i)) return pok
Avoid too many return
statements within this function. Open
if (canUse(p.slice(0, 1))) return pok
Avoid too many return
statements within this function. Open
if (canUse(p.slice(0, 5))) return pok
Function getEyeFocus
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function getEyeFocus (element, instantly, isBottom, myWindow) {
if (!myWindow) myWindow = window
var elementPosY = findPos(element)[1]
var totalScroll = elementPosY - 52 - myWindow.scrollY // magic number 52 for web-based version
if (instantly) {
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
function RDFComparePredicateSubject (self, other) {
var x = self.predicate.compareTerm(other.predicate)
if (x !== 0) return x
return self.subject.compareTerm(other.subject)
}
- 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
function RDFComparePredicateObject (self, other) {
var x = self.predicate.compareTerm(other.predicate)
if (x !== 0) return x
return self.object.compareTerm(other.object)
}
- 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