michielbdejong/solid-ui

View on GitHub
src/acl/acl.ts

Summary

Maintainability
F
4 days
Test Coverage

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'
Severity: Major
Found in src/acl/acl.ts - About 1 day to fix

    Function getACLorDefault has 85 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function getACLorDefault (
      doc: $rdf.NamedNode,
      callbackFunction: (
        a: boolean,
        b: boolean,
    Severity: Major
    Found in src/acl/acl.ts - About 3 hrs to fix

      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,
      Severity: Minor
      Found in src/acl/acl.ts - About 3 hrs to fix

      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('/')
      Severity: Major
      Found in src/acl/acl.ts - About 2 hrs to fix

        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
        Severity: Minor
        Found in src/acl/acl.ts - About 1 hr to fix

          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,
          Severity: Minor
          Found in src/acl/acl.ts - About 1 hr to fix

            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
            Severity: Minor
            Found in src/acl/acl.ts - About 1 hr to fix

            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,
            Severity: Minor
            Found in src/acl/acl.ts - About 1 hr to fix

            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 {
            Severity: Minor
            Found in src/acl/acl.ts - About 1 hr to fix

              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,
              Severity: Minor
              Found in src/acl/acl.ts - About 1 hr to fix

                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,
                Severity: Minor
                Found in src/acl/acl.ts - About 1 hr to fix

                  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
                  Severity: Minor
                  Found in src/acl/acl.ts - About 1 hr to fix

                    Function makeACLGraphbyCombo has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      kb: $rdf.IndexedFormula,
                      x: $rdf.NamedNode,
                      byCombo: ComboList,
                      aclDoc: $rdf.NamedNode,
                      main?: boolean,
                    Severity: Minor
                    Found in src/acl/acl.ts - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                  if (!b[pred][agent] || !b[pred][agent][mode]) {
                                    return false
                                  }
                      Severity: Major
                      Found in src/acl/acl.ts - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                      if (!b[pred][ag]) b[pred][ag] = []
                        Severity: Major
                        Found in src/acl/acl.ts - About 45 mins to fix

                          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
                          Severity: Minor
                          Found in src/acl/acl.ts - About 35 mins to fix

                            Function putACLObject has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                              kb: $rdf.IndexedFormula,
                              x: $rdf.NamedNode,
                              ac: AgentMapMap,
                              aclDoc: $rdf.NamedNode,
                              callbackFunction
                            Severity: Minor
                            Found in src/acl/acl.ts - About 35 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                        return tryParent(uri) // Keep searching
                              Severity: Major
                              Found in src/acl/acl.ts - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        return callbackFunction(
                                          true,
                                          false,
                                          doc,
                                          aclDoc as $rdf.NamedNode,
                                Severity: Major
                                Found in src/acl/acl.ts - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                        return callbackFunction(true, true, doc, aclDoc as $rdf.NamedNode)
                                  Severity: Major
                                  Found in src/acl/acl.ts - About 30 mins to fix

                                    There are no issues that match your filters.

                                    Category
                                    Status