notduncansmith/summit

View on GitHub

Showing 96 of 96 total issues

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

    fields: {
      title: 'string',
      body: 'text',
      get slug() {
        return slugify(this.title);
Severity: Major
Found in cms/page.js and 1 other location - About 1 hr to fix
cms/post.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 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

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

    return this.get(name)
    .then(function (results) {
      if (results.length === 0) {
        return self.put(name, doc);
      }
Severity: Major
Found in lib/drivers/database/nano.js and 1 other location - About 1 hr to fix
lib/drivers/database/pouch.js on lines 64..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 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

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

    return this.get(name)
    .then(function (results) {
      if (results.length === 0) {
        return self.put(name, doc);
      }
Severity: Major
Found in lib/drivers/database/pouch.js and 1 other location - About 1 hr to fix
lib/drivers/database/nano.js on lines 40..57

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

    fields: {
      title: 'string',
      body: 'text',
      get slug() {
        return slugify(this.title);
Severity: Major
Found in cms/post.js and 1 other location - About 1 hr to fix
cms/page.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 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 save has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Item.prototype.save = function () {
  var self = this
    , fields = this._collection.fields
    , uploadFields
    , attachmentPaths;
Severity: Minor
Found in lib/collection/item.js - About 1 hr to fix

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

    function authenticatePassword (data) {
      if (!data.username) {
        throw new Error('`username` is required for password authenticate');
      }
    
    
    Severity: Minor
    Found in lib/collection/user.js - About 1 hr to fix

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

          if (opts.page) {
            esQuery.size = esQuery.size || 10;
            esQuery.from = esQuery.size * (opts.page - 1);
          }
      Severity: Major
      Found in lib/drivers/search/elasticsearch.js and 1 other location - About 1 hr to fix
      lib/collection.js on lines 376..379

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

        if (opts.page) {
          args.size = args.size || 10;
          args.from = args.size * (opts.page - 1);
        }
      Severity: Major
      Found in lib/collection.js and 1 other location - About 1 hr to fix
      lib/drivers/search/elasticsearch.js on lines 78..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 (app) {
        var User = app.collection({
          name: 'User',
          isUserType: true,
          fields: {
      Severity: Minor
      Found in lib/services/user.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 defaultConfig has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = function defaultConfig (userConfig) {
        var userConfig = userConfig || {};
      
        var hostname = process.env.HOSTNAME || 'localhost'
          , port = process.env.PORT || 1337
      Severity: Minor
      Found in lib/configure.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 put has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Database.prototype.put = function (name, doc, force) {
        var args = []
          , self = this;
      
        if (force && force === true) {
      Severity: Minor
      Found in lib/drivers/database/pouch.js - About 1 hr to fix

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

        Collection.prototype.follow = function (opts, handler) {
          var opts = opts || {}
            , args = {}
            , handler = handler || function(){}
            , feed;
        Severity: Minor
        Found in lib/collection.js - About 1 hr to fix

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

          Database.prototype.use = function (name) {
            var config = _.extend({}, this.config, {name: name});
            return new Database(config);
          };
          Severity: Major
          Found in lib/drivers/database/nano.js and 1 other location - About 1 hr to fix
          lib/drivers/database/pouch.js on lines 92..95

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

          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

          Database.prototype.use = function (name) {
            var config = _.extend({}, this.config, {name: name});
            return new Database(config);
          };
          Severity: Major
          Found in lib/drivers/database/pouch.js and 1 other location - About 1 hr to fix
          lib/drivers/database/nano.js on lines 73..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 56.

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

                withToken: function (token) {
                  return coll.get(token)
                  .then(function (fpRecord) {
                    var timestamp = moment(fpRecord.createdAt, moment.ISO_8601)
                      , weekAgo = moment().add(1, 'weeks');
          Severity: Minor
          Found in lib/services/forgot_password.js - About 1 hr to fix

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

            function sendMail (opts) {
              var toEmail = opts.toEmail
                , body = opts.body
                , fromEmail = opts.fromEmail
                , fromName = opts.fromName
            Severity: Minor
            Found in lib/services/mailer.js - About 1 hr to fix

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

              Database.prototype.attach = function (name, filePaths) {
                var self = this
                  , doc = (typeof name === 'string' ? this.get(name) : Promise.resolve([name]));
              
                if (filePaths.length === 0) {
              Severity: Minor
              Found in lib/drivers/database/nano.js - About 1 hr to fix

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

                UserCollection.prototype.validate = function (user) {
                  var services = ['password', 'facebook', 'twitter']
                    , identifiers = ['email', 'facebookId', 'twitterId', 'username']
                    , userIdentifiers = [];
                
                
                Severity: Minor
                Found in lib/collection/user.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

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

                  byTwitterId: {
                    map: function (doc) {
                      if (doc.type === '{{name}}' && doc.twitterId) {
                        emit(doc.twitterId, doc);
                      }
                Severity: Major
                Found in lib/collection/user.js and 9 other locations - About 50 mins to fix
                cms/page.js on lines 23..29
                cms/page.js on lines 30..36
                cms/post.js on lines 22..28
                cms/post.js on lines 29..35
                cms/post.js on lines 36..42
                lib/collection/group.js on lines 96..102
                lib/collection/user.js on lines 247..253
                lib/collection/user.js on lines 255..261
                lib/services/mailer.js on lines 16..22

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

                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

                UserCollection.fields = {
                  service: 'hidden',
                  email: 'email',
                  username: 'string',
                  firstName: 'string',
                Severity: Minor
                Found in lib/collection/user.js and 1 other location - About 50 mins to fix
                lib/services/user.js on lines 5..16

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

                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