arianrhodsandlot/DevDocs-Web-Ext

View on GitHub

Showing 45 of 45 total issues

Function Searcher has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

app.Searcher = (function() {
  var CHUNK_SIZE, DEFAULTS, DOT_REGEXP, ELLIPSIS, EMPTY_PARANTHESES_REGEXP, EMPTY_STRING, EOS_SEPARATORS_REGEXP, EVENT_REGEXP, INFO_PARANTHESES_REGEXP, SEPARATORS_REGEXP, STRING, WHITESPACE_REGEXP;

  $.extend(Searcher.prototype, Events);

Severity: Minor
Found in src/lib/vendors/devdocs/app/searcher.js - 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 util.js has 504 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @file This file is ported from the original source in devdocs, which was written in CoffeeScript. See https://github.com/freeCodeCamp/devdocs/blob/main/assets/javascripts/lib/util.coffee
 */

var ESCAPE_HTML_MAP, ESCAPE_HTML_REGEXP, ESCAPE_REGEXP, HIGHLIGHT_DEFAULTS, buildFragment, isAndroid, isChromeForAndroid, isIE, isIOS, isMac, smoothDistance, smoothDuration, smoothEnd, smoothScroll, smoothStart,
Severity: Major
Found in src/lib/vendors/devdocs/lib/util.js - About 1 day to fix

    Function Searcher has 179 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    app.Searcher = (function() {
      var CHUNK_SIZE, DEFAULTS, DOT_REGEXP, ELLIPSIS, EMPTY_PARANTHESES_REGEXP, EMPTY_STRING, EOS_SEPARATORS_REGEXP, EVENT_REGEXP, INFO_PARANTHESES_REGEXP, SEPARATORS_REGEXP, STRING, WHITESPACE_REGEXP;
    
      $.extend(Searcher.prototype, Events);
    
    
    Severity: Major
    Found in src/lib/vendors/devdocs/app/searcher.js - About 7 hrs to fix

      Function Content has 161 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function Content() {
        const [loading, setLoading] = useState(false)
        const [contentUrl, setContentUrl] = useState('')
        const [content, setContent] = useState('')
        const [doc, setDoc] = useState<Doc>()
      Severity: Major
      Found in src/pages/popup/components/content.tsx - About 6 hrs to fix

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

        $.on = function(el, event, callback, useCapture) {
          var j, len, name, ref;
          if (useCapture == null) {
            useCapture = false;
          }
        Severity: Major
        Found in src/lib/vendors/devdocs/lib/util.js and 1 other location - About 6 hrs to fix
        src/lib/vendors/devdocs/lib/util.js on lines 80..94

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

        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

        $.off = function(el, event, callback, useCapture) {
          var j, len, name, ref;
          if (useCapture == null) {
            useCapture = false;
          }
        Severity: Major
        Found in src/lib/vendors/devdocs/lib/util.js and 1 other location - About 6 hrs to fix
        src/lib/vendors/devdocs/lib/util.js on lines 64..78

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

        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

        Function Header has 146 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function Header() {
          const [inputPaddingLeft, setInputPaddingLeft] = useState(0)
          const [scope, setScope] = useState(localStorage.lastScope ?? '')
          const [query, setQuery] = useState(localStorage.lastQuery ?? '')
          const [docName, setDocName] = useState('')
        Severity: Major
        Found in src/pages/popup/components/header.tsx - About 5 hrs to fix

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

          async function initializeOptions() {
            const options: Record<string, string | number> = {}
            for (const option in defaultOptions) {
              if (Object.prototype.hasOwnProperty.call(defaultOptions, option)) {
                const { [option]: previousValue } = await storage.get(option)
          Severity: Major
          Found in src/pages/popup/index.tsx and 1 other location - About 5 hrs to fix
          src/pages/background/index.ts on lines 8..19

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

          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

          async function initializeOptions() {
            const options: Record<string, string | number> = {}
            for (const option in defaultOptions) {
              if (Object.prototype.hasOwnProperty.call(defaultOptions, option)) {
                const { [option]: previousValue } = await storage.get(option)
          Severity: Major
          Found in src/pages/background/index.ts and 1 other location - About 5 hrs to fix
          src/pages/popup/index.tsx on lines 13..24

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

          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

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

          var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
          Severity: Major
          Found in src/lib/vendors/devdocs/models/entry.js and 1 other location - About 4 hrs to fix
          src/lib/vendors/devdocs/app/searcher.js on lines 15..15

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

          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

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

            extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
          Severity: Major
          Found in src/lib/vendors/devdocs/app/searcher.js and 1 other location - About 4 hrs to fix
          src/lib/vendors/devdocs/models/entry.js on lines 9..9

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

          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

          Function Content has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function Content() {
            const [loading, setLoading] = useState(false)
            const [contentUrl, setContentUrl] = useState('')
            const [content, setContent] = useState('')
            const [doc, setDoc] = useState<Doc>()
          Severity: Minor
          Found in src/pages/popup/components/content.tsx - About 4 hrs 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 Entry has 94 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          app.models.Entry = (function(superClass) {
            var ALIASES, applyAliases;
          
            extend(Entry, superClass);
          
          
          Severity: Major
          Found in src/lib/vendors/devdocs/models/entry.js - About 3 hrs to fix

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

            $.isIOS = function() {
              var ref, ref1;
              return isIOS != null ? isIOS : isIOS = ((ref = navigator.userAgent) != null ? ref.indexOf('iPhone') : void 0) >= 0 || ((ref1 = navigator.userAgent) != null ? ref1.indexOf('iPad') : void 0) >= 0;
            };
            Severity: Major
            Found in src/lib/vendors/devdocs/lib/util.js and 1 other location - About 3 hrs to fix
            src/lib/vendors/devdocs/lib/util.js on lines 495..498

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

            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

            $.isIE = function() {
              var ref, ref1;
              return isIE != null ? isIE : isIE = ((ref = navigator.userAgent) != null ? ref.indexOf('MSIE') : void 0) >= 0 || ((ref1 = navigator.userAgent) != null ? ref1.indexOf('rv:11.0') : void 0) >= 0;
            };
            Severity: Major
            Found in src/lib/vendors/devdocs/lib/util.js and 1 other location - About 3 hrs to fix
            src/lib/vendors/devdocs/lib/util.js on lines 516..519

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

            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

            File searcher.js has 297 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /**
             * @file This file is ported from the original source in devdocs, which was written in CoffeeScript. See https://github.com/freeCodeCamp/devdocs/blob/main/assets/javascripts/app/searcher.coffee
             */
            
            /* These lines are added to make the transpiled result of the original CoffeeScript works properly */
            Severity: Minor
            Found in src/lib/vendors/devdocs/app/searcher.js - About 3 hrs to fix

              Function Header has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

              function Header() {
                const [inputPaddingLeft, setInputPaddingLeft] = useState(0)
                const [scope, setScope] = useState(localStorage.lastScope ?? '')
                const [query, setQuery] = useState(localStorage.lastQuery ?? '')
                const [docName, setDocName] = useState('')
              Severity: Minor
              Found in src/pages/popup/components/header.tsx - About 2 hrs 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 scoreExactMatch has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

              function scoreExactMatch() {;
              
              score = 100 - (valueLength - queryLength);
              
              if (index > 0) {
              Severity: Minor
              Found in src/lib/vendors/devdocs/app/searcher.js - About 2 hrs 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

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

                  if (event.indexOf(' ') >= 0) {
                    ref = event.split(' ');
                    for (i = 0, len = ref.length; i < len; i++) {
                      name = ref[i];
                      this.off(name, callback);
              Severity: Major
              Found in src/lib/vendors/devdocs/lib/events.js and 1 other location - About 1 hr to fix
              src/lib/vendors/devdocs/lib/events.js on lines 10..18

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

              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.indexOf(' ') >= 0) {
                    ref = event.split(' ');
                    for (i = 0, len = ref.length; i < len; i++) {
                      name = ref[i];
                      this.on(name, callback);
              Severity: Major
              Found in src/lib/vendors/devdocs/lib/events.js and 1 other location - About 1 hr to fix
              src/lib/vendors/devdocs/lib/events.js on lines 23..34

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

              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

              Severity
              Category
              Status
              Source
              Language