File acl.ts
has 511 lines of code (exceeds 250 allowed). Consider refactoring. Open
// Access control logic
import * as $rdf from 'rdflib'
import ns from '../ns'
import kb from '../store.js'
Function getACLorDefault
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function getACLorDefault (
doc: $rdf.NamedNode,
callbackFunction: (
a: boolean,
b: boolean,
Function sameACL
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
export function sameACL (a: AgentMapMap, b: AgentMapMap): boolean {
const contains = function (a, b) {
for (const pred in {
agent: true,
agentClass: true,
- 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 tryParent
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
const tryParent = function (uri) {
if (uri.slice(-1) === '/') {
uri = uri.slice(0, -1)
}
const right = uri.lastIndexOf('/')
Function adoptACLDefault
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function adoptACLDefault (
doc: $rdf.NamedNode,
aclDoc: $rdf.NamedNode,
defaultResource: $rdf.NamedNode,
defaultACLdoc: $rdf.NamedNode
Function getACL
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function getACL (
doc: $rdf.NamedNode,
callbackFunction: (
ok: boolean,
messageOrStatus: number | string,
Function comboToString
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export function comboToString (byCombo: ComboList): string {
let str = ''
for (const combo in byCombo) {
const modeURIs = combo.split('\n')
const initials = modeURIs
- 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 makeACLGraphbyCombo
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export function makeACLGraphbyCombo (
kb: $rdf.IndexedFormula,
x: $rdf.NamedNode,
byCombo: ComboList,
aclDoc: $rdf.NamedNode,
- 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 setACL
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function setACL (
docURI: $rdf.NamedNode,
aclText: string,
callbackFunction: (ok: boolean, message: string) => void
): void {
Function fixIndividualACL
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function fixIndividualACL (item: $rdf.NamedNode, subjects: Array<$rdf.NamedNode>, log: Function, callbackFunction: Function): void {
log = log || console.log
const doc = item.doc()
getACLorDefault(doc, function (
ok,
Function makeACLGraphbyCombo
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function makeACLGraphbyCombo (
kb: $rdf.IndexedFormula,
x: $rdf.NamedNode,
byCombo: ComboList,
aclDoc: $rdf.NamedNode,
Function readACL
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function readACL (
x: $rdf.NamedNode,
aclDoc: $rdf.NamedNode,
kb2: $rdf.IndexedFormula = kb,
getDefaults?: boolean
Function makeACLGraphbyCombo
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
kb: $rdf.IndexedFormula,
x: $rdf.NamedNode,
byCombo: ComboList,
aclDoc: $rdf.NamedNode,
main?: boolean,
Avoid deeply nested control flow statements. Open
if (!b[pred][agent] || !b[pred][agent][mode]) {
return false
}
Avoid deeply nested control flow statements. Open
if (!b[pred][ag]) b[pred][ag] = []
Function putACLbyCombo
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
kb: $rdf.IndexedFormula,
x: $rdf.NamedNode,
byCombo: ComboList,
aclDoc: $rdf.NamedNode,
callbackFunction: (ok: boolean, message?: string) => void
Function putACLObject
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
kb: $rdf.IndexedFormula,
x: $rdf.NamedNode,
ac: AgentMapMap,
aclDoc: $rdf.NamedNode,
callbackFunction
Avoid too many return
statements within this function. Open
return tryParent(uri) // Keep searching
Avoid too many return
statements within this function. Open
return callbackFunction(
true,
false,
doc,
aclDoc as $rdf.NamedNode,
Avoid too many return
statements within this function. Open
return callbackFunction(true, true, doc, aclDoc as $rdf.NamedNode)