emotionLoop/jsCode

View on GitHub

Showing 55 of 55 total issues

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

    if ( convertedSettings[7] && convertedSettings[7].name === 'functions_case_lower' ) {
      // lower_case
      options.functionCase = 0;
    } else {
      // camelCase
Severity: Major
Found in app/models/package.js and 6 other locations - About 1 hr to fix
app/models/package.js on lines 220..226
app/models/package.js on lines 229..235
app/models/package.js on lines 238..244
app/models/package.js on lines 247..253
app/models/package.js on lines 265..271
app/models/package.js on lines 274..280

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

    if ( convertedSettings[9] && convertedSettings[9].name === 'variable_concatenation_leading' ) {
      // Leading
      options.concatenationPlace = 0;
    } else {
      // Trailing
Severity: Major
Found in app/models/package.js and 6 other locations - About 1 hr to fix
app/models/package.js on lines 220..226
app/models/package.js on lines 229..235
app/models/package.js on lines 238..244
app/models/package.js on lines 247..253
app/models/package.js on lines 256..262
app/models/package.js on lines 265..271

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

    if ( convertedSettings[11] && convertedSettings[11].name === 'semicolons_no' ) {
      // No
      options.semicolon = '';
    } else {
      // Yes
Severity: Major
Found in app/models/package.js and 3 other locations - About 1 hr to fix
app/models/package.js on lines 182..188
app/models/package.js on lines 211..217
app/models/package.js on lines 283..289

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

    if ( convertedSettings[0] && convertedSettings[0].name === 'indentation_spaces' ) {
      // Space
      options.space = ' ';
    } else {
      // Tab
Severity: Major
Found in app/models/package.js and 3 other locations - About 1 hr to fix
app/models/package.js on lines 211..217
app/models/package.js on lines 283..289
app/models/package.js on lines 292..298

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

exports = module.exports = function( IoC ) {

  var app = this;
  var router = express.Router();
  var controller = IoC.create( 'controllers/packages' );
Severity: Minor
Found in routes/packages.js - About 1 hr to fix

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

    exports = module.exports = function(IoC, settings) {
    
      var app = this;
    
      // set the default views directory
    Severity: Minor
    Found in etc/init/06-views.js - About 1 hr to fix

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

        function show( req, res, next ) {
          async.waterfall([
            // Find package and increment the number of views
            function findPackageAndIncrementViews( callback ) {
              Package.findOne( { slug: req.params.slug }, function( err, _package ) {
      Severity: Minor
      Found in app/controllers/packages.js - About 1 hr to fix

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

        exports = module.exports = function(IoC, logger, settings) {
        
          var app = this;
        
          // adds X-Response-Time header
        Severity: Minor
        Found in etc/init/02-middleware.js - About 1 hr to fix

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

          exports = module.exports = function( Package ) {
          
            // Get 5 most popular packages
            function popular( req, res, next ) {
              req.query.limit = 5;
          Severity: Minor
          Found in app/controllers/packages.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 exports has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          exports = module.exports = function( Package, settings ) {
          
            function home( req, res, next ) {
              var popularPackages = [];
              var latestPackages = [];
          Severity: Minor
          Found in app/controllers/home.js - About 45 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 listPaginated has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            function listPaginated( req, res, next, findOptions, extraOptions ) {
          Severity: Minor
          Found in app/controllers/packages.js - About 35 mins to fix

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

                } else {
                  // 4 Spaces
                  if ( options.space === ' ' ) {
                    options.indentation = '    ';
                  } else {
            Severity: Minor
            Found in app/models/package.js and 1 other location - About 35 mins to fix
            app/models/package.js on lines 191..198

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

            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 ( convertedSettings[1] && convertedSettings[1].name === 'spacing_2_spaces' ) {
                  // 2 Spaces
                  if ( options.space === ' ' ) {
                    options.indentation = '  ';
                  } else {
            Severity: Minor
            Found in app/models/package.js and 1 other location - About 35 mins to fix
            app/models/package.js on lines 198..205

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

            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

              function latest( req, res, next ) {
                req.query.limit = 5;
            
                listPaginated( req, res, next, {}, { sortBy: { created_at: -1 } });
              }
            Severity: Minor
            Found in app/controllers/packages.js and 1 other location - About 30 mins to fix
            app/controllers/packages.js on lines 14..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 45.

            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

              function popular( req, res, next ) {
                req.query.limit = 5;
            
                listPaginated( req, res, next, {}, { sortBy: { views: -1 } });
              }
            Severity: Minor
            Found in app/controllers/packages.js and 1 other location - About 30 mins to fix
            app/controllers/packages.js on lines 21..25

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

            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