Modernizr/Modernizr

View on GitHub

Showing 99 of 99 total issues

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

define(['Modernizr'], function(Modernizr) {
  Modernizr.addTest('focusvisible', function() {
    try {
      document.querySelector(':focus-visible');
    } catch (error) {
Severity: Major
Found in feature-detects/css/focusvisible.js and 1 other location - About 1 hr to fix
feature-detects/css/focuswithin.js on lines 9..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 66.

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

  Modernizr.addTest('sessionstorage', function() {
    var mod = 'modernizr';
    try {
      sessionStorage.setItem(mod, mod);
      sessionStorage.removeItem(mod);
Severity: Major
Found in feature-detects/storage/sessionstorage.js and 1 other location - About 1 hr to fix
feature-detects/storage/localstorage.js on lines 37..46

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

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

  Modernizr.addTest('localstorage', function() {
    var mod = 'modernizr';
    try {
      localStorage.setItem(mod, mod);
      localStorage.removeItem(mod);
Severity: Major
Found in feature-detects/storage/localstorage.js and 1 other location - About 1 hr to fix
feature-detects/storage/sessionstorage.js on lines 15..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 66.

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

define(['Modernizr'], function(Modernizr) {
  Modernizr.addTest('focuswithin', function() {
    try {
      document.querySelector(':focus-within');
    } catch (error) {
Severity: Major
Found in feature-detects/css/focuswithin.js and 1 other location - About 1 hr to fix
feature-detects/css/focusvisible.js on lines 10..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 66.

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 test_hyphens_find has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      function test_hyphens_find(delimiter) {
        try {
          /* create a sample input for resetting selection location, and a div container
           * these have to be appended to document.body, otherwise some browsers can give false negative
           * div container gets the doubled testword, separated by the delimiter
Severity: Minor
Found in feature-detects/css/hyphens.js - About 1 hr to fix

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

    define(['Modernizr'], function(Modernizr) {
      Modernizr.addTest('restparameters', function() {
        try {
          // eslint-disable-next-line
          eval('function f(...rest) {}');
    Severity: Major
    Found in feature-detects/es6/rest-parameters.js and 4 other locations - About 1 hr to fix
    feature-detects/es6/arrow.js on lines 12..22
    feature-detects/es6/class.js on lines 18..28
    feature-detects/es6/spread-array.js on lines 22..32
    feature-detects/es7/spread-object.js on lines 16..26

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

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

    define(['Modernizr'], function(Modernizr) {
      Modernizr.addTest('es6class', function() {
        try {
          // eslint-disable-next-line
          eval('class A{}');
    Severity: Major
    Found in feature-detects/es6/class.js and 4 other locations - About 1 hr to fix
    feature-detects/es6/arrow.js on lines 12..22
    feature-detects/es6/rest-parameters.js on lines 17..27
    feature-detects/es6/spread-array.js on lines 22..32
    feature-detects/es7/spread-object.js on lines 16..26

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

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

    define(['Modernizr'], function(Modernizr) {
      Modernizr.addTest('spreadarray', function() {
        try {
          // eslint-disable-next-line
          eval('(function f(){})(...[1])');
    Severity: Major
    Found in feature-detects/es6/spread-array.js and 4 other locations - About 1 hr to fix
    feature-detects/es6/arrow.js on lines 12..22
    feature-detects/es6/class.js on lines 18..28
    feature-detects/es6/rest-parameters.js on lines 17..27
    feature-detects/es7/spread-object.js on lines 16..26

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

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

    define(['Modernizr'], function(Modernizr) {
      Modernizr.addTest('spreadobject', function() {
        try {
          // eslint-disable-next-line
          eval('var a={...{b:1}}');
    Severity: Major
    Found in feature-detects/es7/spread-object.js and 4 other locations - About 1 hr to fix
    feature-detects/es6/arrow.js on lines 12..22
    feature-detects/es6/class.js on lines 18..28
    feature-detects/es6/rest-parameters.js on lines 17..27
    feature-detects/es6/spread-array.js on lines 22..32

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

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

    define(['Modernizr'], function(Modernizr) {
      Modernizr.addTest('arrow', function() {
        try {
          // eslint-disable-next-line
          eval('()=>{}');
    Severity: Major
    Found in feature-detects/es6/arrow.js and 4 other locations - About 1 hr to fix
    feature-detects/es6/class.js on lines 18..28
    feature-detects/es6/rest-parameters.js on lines 17..27
    feature-detects/es6/spread-array.js on lines 22..32
    feature-detects/es7/spread-object.js on lines 16..26

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

    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 testRunner has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function testRunner() {
        var featureNames;
        var feature;
        var aliasIdx;
        var result;
    Severity: Minor
    Found in src/testRunner.js - About 1 hr to fix

      Function test_hyphens has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            function test_hyphens(delimiter, testWidth) {
              try {
                /* create a div container and a span within that
                 * these have to be appended to document.body, otherwise some browsers can give false negative */
                var div = createElement('div');
      Severity: Minor
      Found in feature-detects/css/hyphens.js - About 1 hr to fix

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

        define(['Modernizr'], function(Modernizr) {
          Modernizr.addTest('es5function', function() {
            return !!(Function.prototype && Function.prototype.bind);
          });
        });
        Severity: Major
        Found in feature-detects/es5/function.js and 1 other location - About 1 hr to fix
        feature-detects/es5/string.js on lines 17..21

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

        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

        define(['Modernizr'], function(Modernizr) {
          Modernizr.addTest('es5string', function() {
            return !!(String.prototype && String.prototype.trim);
          });
        });
        Severity: Major
        Found in feature-detects/es5/string.js and 1 other location - About 1 hr to fix
        feature-detects/es5/function.js on lines 17..21

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

        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 addTest has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function addTest(feature, test) {
        
            if (typeof feature === 'object') {
              for (var key in feature) {
                if (hasOwnProp(feature, key)) {
        Severity: Minor
        Found in src/addTest.js - About 1 hr to fix

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

              function cleanup() {
                if (url) {
                  URL.revokeObjectURL(url);
                }
                if (worker) {
          Severity: Major
          Found in feature-detects/workers/blobworkers.js and 1 other location - About 1 hr to fix
          feature-detects/workers/transferables.js on lines 60..70

          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

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

              function cleanup() {
                if (url) {
                  URL.revokeObjectURL(url);
                }
                if (worker) {
          Severity: Major
          Found in feature-detects/workers/transferables.js and 1 other location - About 1 hr to fix
          feature-detects/workers/blobworkers.js on lines 71..81

          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

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

          module.exports = function(grunt) {
            'use strict';
          
            // load grunt dependencies
            require('load-grunt-tasks')(grunt);
          Severity: Minor
          Found in legacy/Gruntfile.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 generateBuildQuery has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            return function generateBuildQuery(config) {
              // Format:
              // ?-<prop1>-<prop2>-…-<propN>-<option1>-<option2>-…<optionN>[-dontmin][-cssclassprefix:<prefix>]
              // where prop1…N and option1…N are sorted alphabetically (for consistency)
              var dontmin = !config.minify;
          Severity: Minor
          Found in lib/build-query.js - About 1 hr to fix

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

            define(['Modernizr'], function(Modernizr) {
              Modernizr.addTest('filereader', !!(window.File && window.FileList && window.FileReader));
            });
            Severity: Major
            Found in feature-detects/file/api.js and 1 other location - About 1 hr to fix
            feature-detects/es6/object.js on lines 20..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 55.

            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