camman3d/jerboa.js

View on GitHub

Showing 12 of 29 total issues

Function createInfoBox has 103 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function createInfoBox(spot, payload) {
    function changeColor(classList, currentClassName, newClassName) {
        if (classList.contains(currentClassName)) {classList.remove(currentClassName)};
        if (!classList.contains(newClassName)) {classList.add(newClassName)};
    }
Severity: Major
Found in src/html-manip.js - About 4 hrs to fix

    File html-manip.js has 287 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { getGlobalOffset } from './positioning';
    import { emit } from './events';
    import state from './state';
    import { isSafari } from './utils';
    /*
    Severity: Minor
    Found in src/html-manip.js - About 2 hrs to fix

      Function addText has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function addText(container, payload, className) {
          let text = document.createElement('div');
          text.classList.add('feedback-text');
          if (className) {
              text.classList.add(className);
      Severity: Major
      Found in src/html-manip.js - About 2 hrs to fix

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

        function createToggleButton() {
            let bottom = '25px';
            let left = '25px';
        
            let buttonContainer = document.createElement('div');
        Severity: Minor
        Found in src/jerboa.js - About 1 hr to fix

          Function createInfoBox has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          export function createInfoBox(spot, payload) {
              function changeColor(classList, currentClassName, newClassName) {
                  if (classList.contains(currentClassName)) {classList.remove(currentClassName)};
                  if (!classList.contains(newClassName)) {classList.add(newClassName)};
              }
          Severity: Minor
          Found in src/html-manip.js - 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 generatePayload has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function generatePayload(event) {
              const container = resolveContainer(event.target, state.currentStrategy);
              if (!container) {
                  return;
              }
          Severity: Minor
          Found in src/jerboa.js - About 1 hr to fix

            Function clickListener has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function clickListener(event) {
                if (!state.active) {
                    return;
                }
                closeInfoBox();
            Severity: Minor
            Found in src/jerboa.js - About 1 hr to fix

              Function addBox has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function addBox(spot, toggled) {
                  spot.addEventListener('click', event => {
                      if (!state.active) {
                          return;
                      }
              Severity: Minor
              Found in src/html-manip.js - About 1 hr to fix

                Function init has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    init(options) {
                        console.log('options', options);
                        options = options || {};
                        state.active = options.active || false
                        state.currentStrategy = options.strategy || strategies.global;
                Severity: Minor
                Found in src/jerboa.js - About 1 hr to fix

                  Function getSelector has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function getSelector(e, child) {
                      if (e.tagName === 'BODY') {
                          return 'body' + (child ? " > " + child : "");
                      }
                      if (e.id) {
                  Severity: Minor
                  Found in src/positioning.js - 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 addTextField has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function addTextField(boxContainer, label, containerClass) {
                      let container = document.createElement('div');
                      if (containerClass) {
                          container.classList.add(containerClass)
                      };
                  Severity: Minor
                  Found in src/html-manip.js - About 1 hr to fix

                    Function addText has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function addText(container, payload, className) {
                        let text = document.createElement('div');
                        text.classList.add('feedback-text');
                        if (className) {
                            text.classList.add(className);
                    Severity: Minor
                    Found in src/html-manip.js - About 35 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

                    Severity
                    Category
                    Status
                    Source
                    Language