yoctore/yocto-utils

View on GitHub

Showing 37 of 37 total issues

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

ObjUtil.prototype.camelizeKeys = function (obj) {
  // Change state
  this.camelize = true;
  this.underscorize = !this.camelize;

Severity: Major
Found in src/modules/obj/objutil/index.js and 1 other location - About 1 hr to fix
src/modules/obj/objutil/index.js on lines 58..65

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

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

YDate.prototype.generateList = function (min, max, prefixMin, prefixMax, reverse) {
  // Default list
  var list = [];

  try {
Severity: Minor
Found in src/modules/date/index.js - About 1 hr to fix

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

    module.exports = function (grunt) {
      // Init config
      grunt.initConfig({
        // Default package
        pkg : grunt.file.readJSON('package.json'),
    Severity: Minor
    Found in Gruntfile.js - About 1 hr to fix

      Function randomizedPassword has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      Crypto.prototype.randomizedPassword = function (n, level) {
        // Choose complexity level of password
        // 1 : easy - 2 middle - 3 huge
        level = !_.isUndefined(level) && _.isNumber(level) && (level >= 1 && level <= 3) ? level : 3;
      
      
      Severity: Minor
      Found in src/modules/crypto/index.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

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

      Obj.prototype.camelizeKeysMongoose = function (o) {
        // Default statement
        return this.objUtil.camelizeKeys(JSON.parse(JSON.stringify(o.toObject())));
      };
      Severity: Major
      Found in src/modules/obj/index.js and 1 other location - About 1 hr to fix
      src/modules/obj/index.js on lines 108..111

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

      Obj.prototype.underscorizeKeysMongoose = function (o) {
        // Default statement
        return this.objUtil.underscoreKeys(JSON.parse(JSON.stringify(o.toObject())));
      };
      Severity: Major
      Found in src/modules/obj/index.js and 1 other location - About 1 hr to fix
      src/modules/obj/index.js on lines 85..88

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

          prefixMax = !_.isUndefined(prefixMax) && !_.isNull(prefixMax) &&
                      _.isString(prefixMax) && !_.isEmpty(prefixMax) ? prefixMax : '';
      Severity: Major
      Found in src/modules/date/index.js and 1 other location - About 1 hr to fix
      src/modules/date/index.js on lines 75..76

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

      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

          prefixMin = !_.isUndefined(prefixMin) && !_.isNull(prefixMin) &&
                      _.isString(prefixMin) && !_.isEmpty(prefixMin) ? prefixMin : '';
      Severity: Major
      Found in src/modules/date/index.js and 1 other location - About 1 hr to fix
      src/modules/date/index.js on lines 77..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 62.

      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

      Consider simplifying this complex logical expression.
      Open

            if (i >= 33 && i <= 47 || i >= 58 && i <= 64 || i >= 91 && i <= 96 || i >= 123 && i <= 126) {
              s += String.fromCharCode(i);
            }
      Severity: Critical
      Found in src/modules/strings/index.js - About 1 hr to fix

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

              if (i >= 33 && i <= 47 || i >= 58 && i <= 64 || i >= 91 && i <= 96 || i >= 123 && i <= 126) {
        Severity: Major
        Found in src/modules/strings/index.js and 1 other location - About 1 hr to fix
        src/modules/strings/index.js on lines 107..108

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

        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

                 value.length === 1 && (zero >= 33 && zero <= 47 || zero >= 58 && zero <= 64 ||
                                        zero >= 91 && zero <= 96 || zero >= 123 && zero <= 126);
        Severity: Major
        Found in src/modules/strings/index.js and 1 other location - About 1 hr to fix
        src/modules/strings/index.js on lines 61..61

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

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

        Crypto.prototype.randomizedPassword = function (n, level) {
          // Choose complexity level of password
          // 1 : easy - 2 middle - 3 huge
          level = !_.isUndefined(level) && _.isNumber(level) && (level >= 1 && level <= 3) ? level : 3;
        
        
        Severity: Minor
        Found in src/modules/crypto/index.js - About 1 hr to fix

          Function walk has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          ObjUtil.prototype.walk = function (obj) {
            // First test
            if (!obj || !_.isObject(obj)) {
              // Default statement
              return obj;
          Severity: Minor
          Found in src/modules/obj/objutil/index.js - About 55 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

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

          YDate.prototype.generateList = function (min, max, prefixMin, prefixMax, reverse) {
          Severity: Minor
          Found in src/modules/date/index.js - About 35 mins to fix

            Function calculDifference has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              function (actualDate, limitDate, difference, firstPassage) {
              // Find a valid day from the actualDate
                var validDate = this.findNextValidDay(actualDate);
            
                // Check if the validDate is not BetweenOpenPlanning & if isBefore the limitDate
            Severity: Minor
            Found in src/modules/date/elapsed/index.js - About 35 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

            Avoid too many return statements within this function.
            Open

              return _.reduce(Object.keys(obj), function (acc, key) {
                // Camelcase
                var state = this.camelize ? this.str.camelCase(key) : this.str.underscore(key);
            
                // Assign
            Severity: Major
            Found in src/modules/obj/objutil/index.js - About 30 mins to fix

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

              Str.prototype.isSpecialChar = function (value) {
                // Char At zero
                var zero = value.charCodeAt(0);
              
                // Default statement
              Severity: Minor
              Found in src/modules/strings/index.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

              Severity
              Category
              Status
              Source
              Language