medialize/ally.js

View on GitHub
build/data-tables/utils/aggregated-focusable-data.js

Summary

Maintainability
C
1 day
Test Coverage

Function generateBrowserStructure has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function generateBrowserStructure(ident, browser, browserData) {
  const element = browserData.elements[ident] || {};
  const scriptFocus = element.scriptFocus || {};
  const ally = element.ally || {};
  const jquery = element.jquery || {};
Severity: Minor
Found in build/data-tables/utils/aggregated-focusable-data.js - About 1 hr to fix

    Function readableLabel has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    function readableLabel(focusable, tabbable, onlyTabbable, redirecting, focusHost) {
      return (redirecting && 'redirecting')
        || (focusable && tabbable && 'tabbable')
        || (focusable && !tabbable && 'focusable')
        || (!focusable && tabbable && 'only tabbable')
    Severity: Minor
    Found in build/data-tables/utils/aggregated-focusable-data.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 addReadableLabels has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function addReadableLabels(src) {
      src.browser.label = readableLabel(
        src.browser.focusable,
        src.browser.tabbable,
        null, // onlyTabbable
    Severity: Minor
    Found in build/data-tables/utils/aggregated-focusable-data.js - About 1 hr to fix

      Function readableLabel has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function readableLabel(focusable, tabbable, onlyTabbable, redirecting, focusHost) {
      Severity: Minor
      Found in build/data-tables/utils/aggregated-focusable-data.js - About 35 mins to fix

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

        function addGeneratedNotes(ident, browser, browserData, data) {
          let element = browserData.elements[ident];
          if (!element) {
            element = {
              tabindexProperty: 'null',
        Severity: Minor
        Found in build/data-tables/utils/aggregated-focusable-data.js - 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

        Unnecessary return statement.
        Open

            return;

        Disallow redundant return statements (no-useless-return)

        A return; statement with nothing after it is redundant, and has no effect on the runtime behavior of a function. This can be confusing, so it's better to disallow these redundant statements.

        Rule Details

        This rule aims to report redundant return statements.

        Examples of incorrect code for this rule:

        /* eslint no-useless-return: "error" */
        
        function foo() { return; }
        
        function foo() {
          doSomething();
          return;
        }
        
        function foo() {
          if (condition) {
            bar();
            return;
          } else {
            baz();
          }
        }
        
        function foo() {
          switch (bar) {
            case 1:
              doSomething();
            default:
              doSomethingElse();
              return;
          }
        }

        Examples of correct code for this rule:

        /* eslint no-useless-return: "error" */
        
        function foo() { return 5; }
        
        function foo() {
          return doSomething();
        }
        
        function foo() {
          if (condition) {
            bar();
            return;
          } else {
            baz();
          }
          qux();
        }
        
        function foo() {
          switch (bar) {
            case 1:
              doSomething();
              return;
            default:
              doSomethingElse();
          }
        }
        
        function foo() {
          for (const foo of bar) {
            return;
          }
        }

        When Not To Use It

        If you don't care about disallowing redundant return statements, you can turn off this rule. Source: http://eslint.org/docs/rules/

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

          src.ally.labelQuick = readableLabel(
            src.ally.focusableQuick,
            src.ally.tabbableQuick,
            src.ally.onlyTabbable,
            src.ally.redirecting,
        Severity: Major
        Found in build/data-tables/utils/aggregated-focusable-data.js and 2 other locations - About 1 hr to fix
        build/data-tables/utils/aggregated-focusable-data.js on lines 190..196
        build/data-tables/utils/aggregated-focusable-data.js on lines 204..210

        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 3 locations. Consider refactoring.
        Open

          src.ally.label = readableLabel(
            src.ally.focusable,
            src.ally.tabbable,
            src.ally.onlyTabbable,
            src.ally.redirecting,
        Severity: Major
        Found in build/data-tables/utils/aggregated-focusable-data.js and 2 other locations - About 1 hr to fix
        build/data-tables/utils/aggregated-focusable-data.js on lines 197..203
        build/data-tables/utils/aggregated-focusable-data.js on lines 204..210

        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 3 locations. Consider refactoring.
        Open

          src.ally.labelStrict = readableLabel(
            src.ally.focusableStrict,
            src.ally.tabbableStrict,
            src.ally.onlyTabbable,
            src.ally.redirecting,
        Severity: Major
        Found in build/data-tables/utils/aggregated-focusable-data.js and 2 other locations - About 1 hr to fix
        build/data-tables/utils/aggregated-focusable-data.js on lines 190..196
        build/data-tables/utils/aggregated-focusable-data.js on lines 197..203

        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

        There are no issues that match your filters.

        Category
        Status