Function renderTableViewPane
has a Cognitive Complexity of 376 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function renderTableViewPane (doc, options) {
var sourceDocument = options.sourceDocument
var tableClass = options.tableClass
var givenQuery = options.query
- 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 renderTableViewPane
has 1064 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function renderTableViewPane (doc, options) {
var sourceDocument = options.sourceDocument
var tableClass = options.tableClass
var givenQuery = options.query
File table.js
has 1075 lines of code (exceeds 250 allowed). Consider refactoring. Open
// Table Widget: Format an array of RDF statements as an HTML table.
//
// This can operate in one of three modes: when the class of object is given
// or when the source document from whuch data is taken is given,
// or if a prepared query object is given.
Function Column
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Column () {
this.useCount = 0
// Have we checked any values for this column yet?
Function runQuery
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
function runQuery (query, rows, columns, table) {
query.running = true
var startTime = Date.now()
var progressMessage = doc.createElement('tr')
Function renderLiteralSelector
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
function renderLiteralSelector (rows, columns, column) {
var result = doc.createElement('div')
var textBox = doc.createElement('input')
textBox.setAttribute('type', 'text')
Function renderEnumSelector
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
function renderEnumSelector (rows, columns, column, list) {
var doMultiple = true
var result = doc.createElement('div')
var dropdown = doc.createElement('select')
Function renderTableRowInto
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function renderTableRowInto (tr, row, columns, _downstream) {
/* Link column, for linking to this subject. */
var linkTd = doc.createElement('td')
Function SubjectType
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function SubjectType (type) {
this.type = type
this.columns = null
this.allColumns = null
this.useCount = 0
Function renderNumberSelector
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function renderNumberSelector (rows, columns, column) {
var result = doc.createElement('div')
var minSelector = doc.createElement('input')
minSelector.setAttribute('type', 'text')
Function renderValue
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function renderValue (obj, column) {
// hint
var hints = getHints(column)
var cellFormat = hints.cellFormat
if (cellFormat) {
Function inferColumnsFromFormula
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function inferColumnsFromFormula (columns, formula) {
UI.log.debug('>> processing formula')
for (let i = 0; i < formula.statements.length; ++i) {
var statement = formula.statements[i]
Function generateColumnAddDropdown
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function generateColumnAddDropdown (type) {
var resultDiv = doc.createElement('div')
var unusedColumns = type.getUnusedColumns()
Function onResult
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
var onResult = function (values) {
if (!query.running) {
return
}
Function applyColumnSort
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function applyColumnSort (rows, column, sortFunction, reverse) {
var columnKey = column.getKey()
// Sort the rows array.
rows.sort(function (row1, row2) {
Avoid deeply nested control flow statements. Open
if (obj.toString() !== orig.toString()) {
different = true
}
Avoid too many return
statements within this function. Open
return span
Avoid too many return
statements within this function. Open
return doc.createTextNode("unknown termtype '" + obj.termType + "'!")
Avoid too many return
statements within this function. Open
return linkToObject(obj, hints)
Avoid too many return
statements within this function. Open
return fallbackRenderTableSelector(rows, columns, column)
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (
statement.predicate.termType === 'NamedNode' &&
statement.subject.termType === 'Variable'
) {
const variable = statement.subject.toString()
- 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 65.
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 (
statement.predicate.termType === 'NamedNode' &&
statement.object.termType === 'Variable'
) {
var variable = statement.object.toString()
- 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 65.
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