kwooshung/react-overlay-scrollbars-smooth

View on GitHub

Showing 12 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

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

                        if (event.wheelDeltaY && isDivisible(event.wheelDeltaY, 120)) {
                          deltaY = -120 * (event.wheelDeltaY / Math.abs(event.wheelDeltaY));
                        }
                  Severity: Major
                  Found in src/overlay-scrollbars-smooth/Smooth.js and 1 other location - About 1 hr to fix
                  src/overlay-scrollbars-smooth/Smooth.js on lines 297..299

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

                  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 (event.wheelDeltaX && isDivisible(event.wheelDeltaX, 120)) {
                          deltaX = -120 * (event.wheelDeltaX / Math.abs(event.wheelDeltaX));
                        }
                  Severity: Major
                  Found in src/overlay-scrollbars-smooth/Smooth.js and 1 other location - About 1 hr to fix
                  src/overlay-scrollbars-smooth/Smooth.js on lines 300..302

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

                  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

                  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