kwooshung/react-overlay-scrollbars-smooth

View on GitHub

Showing 10 of 13 total issues

Function smooth has a Cognitive Complexity of 217 (exceeds 5 allowed). Consider refactoring.
Open

const smooth = (function () {
  // Scroll Variables (tweakable)
  var defaultOptions = {
    // Scrolling Core
    frameRate: 150, // [Hz]
Severity: Minor
Found in src/overlay-scrollbars-smooth/Smooth.js - About 4 days 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 smooth has 503 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const smooth = (function () {
  // Scroll Variables (tweakable)
  var defaultOptions = {
    // Scrolling Core
    frameRate: 150, // [Hz]
Severity: Major
Found in src/overlay-scrollbars-smooth/Smooth.js - About 2 days to fix

    File Smooth.js has 506 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-disable getter-return */
    /* eslint-disable no-empty */
    /* eslint-disable @typescript-eslint/no-unused-vars */
    const smooth = (function () {
      // Scroll Variables (tweakable)
    Severity: Major
    Found in src/overlay-scrollbars-smooth/Smooth.js - About 1 day to fix

      Function scrollArray has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function scrollArray(elem, left, top) {
          directionCheck(left, top);
      
          if (options.accelerationMax != 1) {
            var now = Date.now();
      Severity: Major
      Found in src/overlay-scrollbars-smooth/Smooth.js - About 2 hrs to fix

        Function keydown has 73 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function keydown(event) {
            var target = event.target;
            var modifier = event.ctrlKey || event.altKey || event.metaKey || (event.shiftKey && event.keyCode !== key.spacebar);
        
            // our own tracked active element could've been removed from the DOM
        Severity: Major
        Found in src/overlay-scrollbars-smooth/Smooth.js - About 2 hrs to fix

          Function wheel has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function wheel(event) {
              if (!initDone) {
                init();
              }
          
          
          Severity: Minor
          Found in src/overlay-scrollbars-smooth/Smooth.js - About 1 hr to fix

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

              function init() {
                if (initDone || !document.body) return;
            
                initDone = true;
            
            
            Severity: Minor
            Found in src/overlay-scrollbars-smooth/Smooth.js - About 1 hr to fix

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

                  var step = function (time) {
                    var now = Date.now();
                    var scrollX = 0;
                    var scrollY = 0;
              
              
              Severity: Minor
              Found in src/overlay-scrollbars-smooth/Smooth.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                    if (
                      event.defaultPrevented ||
                      inputNodeNames.test(target.nodeName) ||
                      (isNodeName(target, 'input') && !buttonTypes.test(target.type)) ||
                      isNodeName(activeElement, 'video') ||
                Severity: Critical
                Found in src/overlay-scrollbars-smooth/Smooth.js - About 1 hr to fix

                  Avoid too many return statements within this function.
                  Open

                        return true;
                  Severity: Major
                  Found in src/overlay-scrollbars-smooth/Smooth.js - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language