Function exports
has a Cognitive Complexity of 699 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function (context) {
const dom = context.dom
this.document = context.dom
this.outlineIcons = outlineIcons
- 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 exports
has 1847 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function (context) {
const dom = context.dom
this.document = context.dom
this.outlineIcons = outlineIcons
File manager.js
has 1856 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* -*- coding: utf-8-dos -*-
Outline Mode Manager
*/
var panes = require('pane-registry')
const $rdf = require('rdflib')
Function appendPropertyTRs
has 178 lines of code (exceeds 25 allowed). Consider refactoring. Open
function appendPropertyTRs (parent, plist, inverse, predicateFilter) {
// UI.log.info('@appendPropertyTRs, 'this' is %s, dom is %s, '+ // Gives 'can't access dead object'
// 'thisOutline.document is %s', this, dom.location, thisOutline.document.location);
// UI.log.info('@appendPropertyTRs, dom is now ' + this.document.location);
// UI.log.info('@appendPropertyTRs, dom is now ' + thisOutline.document.location);
Function expandedHeaderTR
has 162 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function expandedHeaderTR (subject, requiredPane, options) {
async function renderPaneIconTray (td, options = {}) {
const paneShownStyle =
'width: 24px; border-radius: 0.5em; border-top: solid #222 1px; border-left: solid #222 0.1em; border-bottom: solid #eee 0.1em; border-right: solid #eee 0.1em; margin-left: 1em; padding: 3px; background-color: #ffd;'
const paneHiddenStyle =
Function outlineExpand
has 158 lines of code (exceeds 25 allowed). Consider refactoring. Open
function outlineExpand (p, subject1, options) {
options = options || {}
var pane = options.pane
var already = !!options.already
var immediate = options.immediate
Function OutlinerKeypressPanel
has 136 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.OutlinerKeypressPanel = function OutlinerKeypressPanel (e) {
UI.log.info('Key ' + e.keyCode + ' pressed')
function showURI (about) {
if (about && dom.getElementById('UserURI')) {
Function renderPaneIconTray
has 115 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function renderPaneIconTray (td, options = {}) {
const paneShownStyle =
'width: 24px; border-radius: 0.5em; border-top: solid #222 1px; border-left: solid #222 0.1em; border-bottom: solid #eee 0.1em; border-right: solid #eee 0.1em; margin-left: 1em; padding: 3px; background-color: #ffd;'
const paneHiddenStyle =
'width: 24px; border-radius: 0.5em; margin-left: 1em; padding: 3px'
Function showNobj
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
tr.showNobj = function (n) {
var predDups = k - dups
var show = 2 * n < predDups ? n : predDups
var showLaterArray = []
if (predDups !== 1) {
Function listen
has 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
var listen = function (ico, pane) {
// Freeze scope for event time
ico.addEventListener(
'click',
function (event) {
Function outlineObjectTD
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.outlineObjectTD = function outlineObjectTD (
obj,
view,
deleteNode,
statement
Function viewAsBoringDefault
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
function viewAsBoringDefault (obj) {
// UI.log.debug('entered viewAsBoringDefault...');
var rep // representation in html
if (obj.termType === 'Literal') {
Function getDashboardItems
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function getDashboardItems () {
const me = UI.authn.currentUser()
const div = dom.createElement('div')
const [books, pods] = await Promise.all([getAddressBooks(), getPods()])
return [
Function walk
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.walk = function walk (directionCode, inputTd) {
var selectedTd = inputTd || selection[0]
var newSelTd
switch (directionCode) {
case 'down':
Function appendAccessIcon
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.appendAccessIcon = function (node, uri) {
if (!uri) return ''
var docuri = UI.rdf.uri.docpart(uri)
if (docuri.slice(0, 5) !== 'http:') return ''
var state = sf.getState(docuri)
Function outlinePredicateTD
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.outlinePredicateTD = function outlinePredicateTD (
predicate,
newTr,
inverse,
internal
Function render
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
function render () {
subject = kb.canon(subject)
if (!p || !p.parentNode || !p.parentNode.parentNode) return false
var newTable
Function setSelected
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setSelected (node, newValue) {
// UI.log.info('selection has ' +selection.map(function(item){return item.textContent;}).join(', '));
// UI.log.debug('@outline setSelected, intended to '+(newValue?'select ':'deselect ')+node+node.textContent);
// if (newValue === selected(node)) return; //we might not need this anymore...
if (node.nodeName !== 'TD') {
Function expand
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
function expand (uri) {
if (arguments[3]) return true // already fetched indicator
var cursubj = kb.canon(subject) // canonical identifier may have changed
UI.log.info(
'@@ expand: relevant subject=' +
Function globalAppTabs
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function globalAppTabs (options = {}) {
console.log('globalAppTabs @@')
const div = dom.createElement('div')
const me = UI.authn.currentUser()
if (!me) {
Function propertyTable
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
var propertyTable = (this.propertyTable = function propertyTable (
subject,
table,
pane,
options
Function GotoSubject
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.GotoSubject = function (subject, expand, pane, solo, referrer, table) {
table = table || dom.getElementById('outline') // if does not exist just add one? nowhere to out it
if (solo) {
UI.utils.emptyNode(table)
table.style.width = '100%'
Function selectableTDClickListener
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function selectableTDClickListener (e) {
// Is we are in editing mode already
if (thisOutline.UserInput._tabulatorMode) {
return thisOutline.UserInput.Click(e)
}
Function showDashboard
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function showDashboard (options = {}) {
const dashboardContainer = getDashboardContainer()
const outlineContainer = getOutlineContainer()
// reuse dashboard if already children already is inserted
if (dashboardContainer.childNodes.length > 0 && options.pane) {
Function setSelectedParent
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setSelectedParent (node, inc) {
var onIcon = outlineIcons.termWidgets.optOn
var offIcon = outlineIcons.termWidgets.optOff
for (var n = node; n.parentNode; n = n.parentNode) {
while (true) {
Function renderPane
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
var renderPane = function (pane) {
var paneDiv
UI.log.info('outline: Rendering pane (2): ' + pane.name)
if (UI.no_catch_pane_errors) {
// for debugging
Function TabulatorMousedown
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function TabulatorMousedown (e) {
UI.log.info('@TabulatorMousedown, dom.location is now ' + dom.location)
var target = thisOutline.targetOf(e)
if (!target) return
var tname = target.tagName
Function outlineCollapse
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function outlineCollapse (p, subject) {
var row = UI.utils.ancestor(p, 'TR')
row = UI.utils.ancestor(row.parentNode, 'TR') // two levels up
if (row) var statement = row.AJAR_statement
var level // find level (the enclosing TD)
Consider simplifying this complex logical expression. Open
if (
obj.termType === 'NamedNode' ||
obj.termType === 'BlankNode' ||
(obj.termType === 'Literal' &&
obj.value.slice &&
Avoid deeply nested control flow statements. Open
if (d.paneButton) {
d.paneButton.setAttribute('class', 'paneHidden')
d.paneButton.style = paneHiddenStyle
}
Avoid deeply nested control flow statements. Open
if (displayed >= show) {
trObj.style.display = 'none'
showLaterArray.push(trObj)
}
Function GotoSubject
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
this.GotoSubject = function (subject, expand, pane, solo, referrer, table) {
Avoid deeply nested control flow statements. Open
if (
d.pane.requireQueryButton &&
t.parentNode.className /* outer table */ &&
numberOfPanesRequiringQueryButton === 1 &&
dom.getElementById('queryButton')
Avoid too many return
statements within this function. Open
if (UI.utils.getTarget(e).tagName === 'INPUT') return
Avoid too many return
statements within this function. Open
if (this.walk('left')) return
Avoid too many return
statements within this function. Open
return false
Avoid too many return
statements within this function. Open
return
Avoid too many return
statements within this function. Open
return
Identical blocks of code found in 2 locations. Consider refactoring. Open
try {
paneDiv = pane.render(subject, context, options)
} catch (e) {
// Easier debugging for pane developers
paneDiv = dom.createElement('div')
- 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 94.
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
try {
UI.log.info('outline: Rendering pane (1): ' + tr1.firstPane.name)
paneDiv = tr1.firstPane.render(subject, context, options)
} catch (e) {
// Easier debugging for pane developers
- 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 94.
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
function showURI (about) {
if (about && dom.getElementById('UserURI')) {
dom.getElementById('UserURI').value =
about.termType === 'NamedNode' ? about.uri : '' // blank if no URI
}
- 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 62.
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
this.showURI = function showURI (about) {
if (about && dom.getElementById('UserURI')) {
dom.getElementById('UserURI').value =
about.termType === 'NamedNode' ? about.uri : '' // blank if no URI
}
- 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 62.
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 (inverse) {
sel = function (x) {
return x.subject
}
plist = plist.sort(UI.utils.RDFComparePredicateSubject)
- 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
} else {
sel = function (x) {
return x.object
}
plist = plist.sort(UI.utils.RDFComparePredicateObject)
- 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