michielbdejong/solid-panes

View on GitHub
src/pad/padPane.ts

Summary

Maintainability
F
5 days
Test Coverage

Function render has 366 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render: function (subject, context, paneOptions: any) {
    const dom = context.dom
    const store = context.session.store
    // Utility functions
    var complainIfBad = function (ok: boolean, message: string) {
Severity: Major
Found in src/pad/padPane.ts - About 1 day to fix

    Function render has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
    Open

      render: function (subject, context, paneOptions: any) {
        const dom = context.dom
        const store = context.session.store
        // Utility functions
        var complainIfBad = function (ok: boolean, message: string) {
    Severity: Minor
    Found in src/pad/padPane.ts - About 1 day 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

    File padPane.ts has 423 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { authn, icons, ns, pad, widgets } from 'solid-ui'
    // @@ TODO: serialize is not part rdflib type definitions
    // Might be fixed in https://github.com/linkeddata/rdflib.js/issues/341
    // @ts-ignore
    import { graph, log, NamedNode, Namespace, sym, serialize, UpdateManager, Fetcher } from 'rdflib'
    Severity: Minor
    Found in src/pad/padPane.ts - About 6 hrs to fix

      Function initializeNewInstanceAtBase has 111 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var initializeNewInstanceAtBase = function (
            thisInstance: any,
            newBase: string
          ) {
            var here = sym(thisInstance.uri.split('#')[0])
      Severity: Major
      Found in src/pad/padPane.ts - About 4 hrs to fix

        Function loadPadData has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            var loadPadData = function () {
              // @@ TODO Remove casting of fetcher
              ;(fetcher as any).nowOrWhenFetched(padDoc.uri, undefined, function (
                ok: boolean,
                body: string,
        Severity: Minor
        Found in src/pad/padPane.ts - About 1 hr to fix

          Function setACL has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              var setACL = function setACL (
                docURI: string,
                allWrite: boolean,
                callbackFunction: Function
              ) {
          Severity: Minor
          Found in src/pad/padPane.ts - About 1 hr to fix

            Function copyItem has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    var fun = function copyItem (item: any) {
                      agenda.push(function () {
                        var newURI = newBase + item.local
                        console.log('Copying ' + base + item.local + ' to ' + newURI)
            
            
            Severity: Minor
            Found in src/pad/padPane.ts - About 1 hr to fix

              Function createNewPadDataFile has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    agenda.push(function createNewPadDataFile () {
                      store.add(newInstance, ns.rdf('type'), PAD('Notepad'), newPadDoc)
              
                      // TODO @@ Remove casting of add
                      ;(store.add as any)(
              Severity: Minor
              Found in src/pad/padPane.ts - About 1 hr to fix

                Function mintNew has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  mintNew: function (context, newPaneOptions: any) {
                    const store = context.session.store
                    const updater = store.updater as UpdateManager
                    if (newPaneOptions.me && !newPaneOptions.me.uri) {
                      throw new Error('notepad mintNew:  Invalid userid')
                Severity: Minor
                Found in src/pad/padPane.ts - About 1 hr to fix

                  Function showBootstrap has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      var showBootstrap = function showBootstrap (
                        thisInstance: any,
                        container: HTMLElement,
                        noun: string
                      ) {
                  Severity: Minor
                  Found in src/pad/padPane.ts - About 1 hr to fix

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                                  if (ok) {
                                    clearElement(naviMain)
                                    showResults(false)
                                  } else {
                                    complainIfBad(
                    Severity: Major
                    Found in src/pad/padPane.ts and 1 other location - About 1 hr to fix
                    src/pad/padPane.ts on lines 352..368

                    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 55.

                    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

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                                if (ok) {
                                  agenda.shift()!()
                                } else {
                                  complainIfBad(
                                    ok,
                    Severity: Major
                    Found in src/pad/padPane.ts and 1 other location - About 1 hr to fix
                    src/pad/padPane.ts on lines 452..469

                    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 55.

                    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

                    Further Reading

                    There are no issues that match your filters.

                    Category
                    Status