anyone-oslo/pages

View on GitHub
app/javascript/lib/Tree.ts

Summary

Maintainability
B
4 hrs
Test Coverage

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

  updateNodesPosition() {
    let top = 1;
    let left = 1;
    const root = this.getIndex(1);

Severity: Minor
Found in app/javascript/lib/Tree.ts - About 1 hr to fix

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

      build(obj: N): Tree.Index<N> {
        const indexes = this.indexes;
        const startId = this.cnt;
    
        const index = { id: startId, node: obj };
    Severity: Minor
    Found in app/javascript/lib/Tree.ts - About 1 hr to fix

      Function walk has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          const walk = (objs: Tree.Node[], parent: Tree.Index<N>) => {
            const children: Tree.Id[] = [];
            objs.forEach((obj: N) => {
              const index: Tree.Index<N> = {
                id: this.cnt,
      Severity: Minor
      Found in app/javascript/lib/Tree.ts - About 1 hr to fix

        Function move has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          move(fromId: Tree.Id, toId: Tree.Id, placement: MovePlacement) {
            if (fromId === toId || toId === 1) {
              return;
            }
        
        
        Severity: Minor
        Found in app/javascript/lib/Tree.ts - About 25 mins 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 getNodeByTop has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          getNodeByTop(top: Tree.Id) {
            const indexes = this.indexes;
            for (const id in indexes) {
              if (Object.prototype.hasOwnProperty.call(indexes, id)) {
                if (indexes[id].top === top) {
        Severity: Minor
        Found in app/javascript/lib/Tree.ts - About 25 mins 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

        There are no issues that match your filters.

        Category
        Status