rootslab/hoar

View on GitHub

Showing 35 of 35 total issues

Function Hoar has a Cognitive Complexity of 177 (exceeds 5 allowed). Consider refactoring.
Open

exports.Hoar = ( function () {
    var log = console.log
        , isArray = Array.isArray
        , alpha = /[^a-z0-9]/gi
        , abs = Math.abs
Severity: Minor
Found in lib/hoar.js - About 3 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 Hoar has 313 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.Hoar = ( function () {
    var log = console.log
        , isArray = Array.isArray
        , alpha = /[^a-z0-9]/gi
        , abs = Math.abs
Severity: Major
Found in lib/hoar.js - About 1 day to fix

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

                    case '<':
                        if ( v1[ 0 ] < v2[ 0 ] ) {
                            return true;
                        }
                        if ( v1[ 0 ] > v2[ 0 ] ) {
    Severity: Major
    Found in lib/hoar.js and 3 other locations - About 4 hrs to fix
    lib/hoar.js on lines 112..128
    lib/hoar.js on lines 129..145
    lib/hoar.js on lines 146..162

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

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

                    case '<=':
                        if ( v1[ 0 ] > v2[ 0 ] ) {
                            return false;
                        }
                        if ( v1[ 0 ] < v2[ 0 ] ) {
    Severity: Major
    Found in lib/hoar.js and 3 other locations - About 4 hrs to fix
    lib/hoar.js on lines 129..145
    lib/hoar.js on lines 146..162
    lib/hoar.js on lines 163..179

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

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

                    case '>':
                        if ( v1[ 0 ] > v2[ 0 ] ) {
                            return true;
                        }
                        if ( v1[ 0 ] < v2[ 0 ] ) {
    Severity: Major
    Found in lib/hoar.js and 3 other locations - About 4 hrs to fix
    lib/hoar.js on lines 112..128
    lib/hoar.js on lines 129..145
    lib/hoar.js on lines 163..179

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

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

                    case '>=':
                        if ( v1[ 0 ] < v2[ 0 ] ) {
                            return false;
                        }
                        if ( v1[ 0 ] > v2[ 0 ] ) {
    Severity: Major
    Found in lib/hoar.js and 3 other locations - About 4 hrs to fix
    lib/hoar.js on lines 112..128
    lib/hoar.js on lines 146..162
    lib/hoar.js on lines 163..179

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

    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 hoar.js has 315 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * Hoar, a fast and light semantic versioning parser/comparator.
     *
     * Copyright(c) 2013-present Guglielmo Ferri <44gatti@gmail.com>
     * MIT Licensed
    Severity: Minor
    Found in lib/hoar.js - About 3 hrs to fix

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

      for ( ; i < vlen; j = ++i ) {
          for ( ; j < vlen; ++j ) {
              for ( c = 0; c < clen; ++c ) {
                  log( '#%d (%d,%d):', ++k, i, j,
                      ver[ i ], cond[ c ], ver[ j ],
      Severity: Major
      Found in example/compare-simple-example.js and 1 other location - About 3 hrs to fix
      example/compare-arrays-simple-example.js on lines 28..37

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

      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

      for ( ; i < vlen; j = ++i ) {
          for ( ; j < vlen; ++j ) {
              for ( c = 0; c < clen; ++c ) {
                  log( '#%d (%d,%d):', ++k, i, j,
                      ver[ i ], cond[ c ], ver[ j ],
      Severity: Major
      Found in example/compare-arrays-simple-example.js and 1 other location - About 3 hrs to fix
      example/compare-simple-example.js on lines 28..37

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

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

              , check = function ( version1, version2, condition ) {
                  var v1 = version1 || [ NaN, NaN, NaN ]
                      , v2 = version2 || [ NaN, NaN, NaN ]
                      , cond = condition || '='
                      ;
      Severity: Major
      Found in lib/hoar.js - About 3 hrs to fix

        Function checkPre has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                , checkPre = function ( pv, pw, cond ) {
                    var c = cond
                        , pvlen = pv.length
                        , pwlen = pw.length
                        , lmin = min( pvlen, pwlen )
        Severity: Minor
        Found in lib/hoar.js - About 1 hr to fix

          Function range has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  , range : function ( values, vrange, nostrict, verbose ) {
                      var v = isArray( values ) ? values : [ values ]
                          , vlen = v.length
                          , vr = isArray( vrange ) ? vrange : []
                          , r1 = vr[ 0 ] || - Infinity
          Severity: Minor
          Found in lib/hoar.js - About 1 hr to fix

            Function print has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    , print = function ( arr ) {
                        var v = arr[ 0 ]
                            , p = arr[ 1 ]
                            , search = function ( arr, pre ) {
                                var list = isArray( arr ) ? arr : []
            Severity: Minor
            Found in lib/hoar.js - About 1 hr to fix

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

                              case '<>':
                                  return ( v1[ 0 ] !== v2[ 0 ] ) ||
                                      ( v1[ 1 ] !== v2[ 1 ] ) ||
                                      ( v1[ 2 ] !== v2[ 2 ] )
                                      ;
              Severity: Minor
              Found in lib/hoar.js and 1 other location - About 50 mins to fix
              lib/hoar.js on lines 180..184

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

              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

                              case '=':
                                  return ( v1[ 0 ] === v2[ 0 ] ) &&
                                      ( v1[ 1 ] === v2[ 1 ] ) &&
                                      ( v1[ 2 ] === v2[ 2 ] )
                                      ;
              Severity: Minor
              Found in lib/hoar.js and 1 other location - About 50 mins to fix
              lib/hoar.js on lines 185..189

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

              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 false;
              Severity: Major
              Found in lib/hoar.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                        return true;
                Severity: Major
                Found in lib/hoar.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                          return true;
                  Severity: Major
                  Found in lib/hoar.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                            return false;
                    Severity: Major
                    Found in lib/hoar.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                          return true;
                      Severity: Major
                      Found in lib/hoar.js - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language