Strider-CD/strider

View on GitHub
apps/strider/lib/models/upgrade/from0to1.js

Summary

Maintainability
F
2 wks
Test Coverage

File from0to1.js has 418 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const models = require('../');
const Job = models.Job;
const User = models.User;
const Project = models.Project;

Severity: Minor
Found in apps/strider/lib/models/upgrade/from0to1.js - About 6 hrs to fix

    Function upgradeJob has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function upgradeJob(job, done) {
      Job.findById(job._id)
        .lean()
        .exec(function (err, mjob) {
          if (err) return done(err);
    Severity: Major
    Found in apps/strider/lib/models/upgrade/from0to1.js - About 2 hrs to fix

      Function upgradeUser has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function upgradeUser(user, done) {
        User.findById(user._id)
          .lean()
          .exec(function (err, mongUser) {
            const heroku = makeHerokuAccounts(user);
      Severity: Minor
      Found in apps/strider/lib/models/upgrade/from0to1.js - About 1 hr to fix

        Function makeHerokuAccounts has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function makeHerokuAccounts(user) {
          if (!user.heroku || !user.heroku.length) return { accounts: [], apps: {} };
          const keys = {};
          const accounts = [];
          const caches = {};
        Severity: Minor
        Found in apps/strider/lib/models/upgrade/from0to1.js - About 1 hr to fix

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

          function upgradeJob(job, done) {
            Job.findById(job._id)
              .lean()
              .exec(function (err, mjob) {
                if (err) return done(err);
          Severity: Major
          Found in apps/strider/lib/models/upgrade/from0to1.js and 1 other location - About 3 days to fix
          apps/strider/dist-lib/models/upgrade/from0to1.js on lines 32..107

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

          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

          const checkPlugins = {
            sauce: function (repo) {
              if (!repo.sauce_access_key) return;
              return {
                access_key: repo.sauce_access_key,
          Severity: Major
          Found in apps/strider/lib/models/upgrade/from0to1.js and 1 other location - About 2 days to fix
          apps/strider/dist-lib/models/upgrade/from0to1.js on lines 311..380

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

          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 upgradeUser(user, done) {
            User.findById(user._id)
              .lean()
              .exec(function (err, mongUser) {
                const heroku = makeHerokuAccounts(user);
          Severity: Major
          Found in apps/strider/lib/models/upgrade/from0to1.js and 1 other location - About 2 days to fix
          apps/strider/dist-lib/models/upgrade/from0to1.js on lines 219..268

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

          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 makeHerokuAccounts(user) {
            if (!user.heroku || !user.heroku.length) return { accounts: [], apps: {} };
            const keys = {};
            const accounts = [];
            const caches = {};
          Severity: Major
          Found in apps/strider/lib/models/upgrade/from0to1.js and 1 other location - About 2 days to fix
          apps/strider/dist-lib/models/upgrade/from0to1.js on lines 178..218

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

          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 makeGithubRepos(user) {
            if (!user.github) return [];
            const github = user.github_metadata[user.github.id].repos;
            const repos = [];
            for (let i = 0; i < github.length; i++) {
          Severity: Major
          Found in apps/strider/lib/models/upgrade/from0to1.js and 1 other location - About 1 day to fix
          apps/strider/dist-lib/models/upgrade/from0to1.js on lines 148..171

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

          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 upgradeJobs(done) {
            Job.collection.find({}, function (err, cursor) {
              if (err) return done(err);
              cursor.toArray(function (err, jobs) {
                if (err) return done(err);
          Severity: Major
          Found in apps/strider/lib/models/upgrade/from0to1.js and 1 other location - About 5 hrs to fix
          apps/strider/dist-lib/models/upgrade/from0to1.js on lines 14..31

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

          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 upgradeUsers(done) {
            User.collection.find({}, function (err, cursor) {
              if (err) return done(err);
              cursor.toArray(function (err, users) {
                if (err) return done(err);
          Severity: Major
          Found in apps/strider/lib/models/upgrade/from0to1.js and 1 other location - About 5 hrs to fix
          apps/strider/dist-lib/models/upgrade/from0to1.js on lines 130..147

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

          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 makePlugins(repo, user, heroku) {
            const plugins = [
              {
                id: 'node',
                enabled: true,
          Severity: Major
          Found in apps/strider/lib/models/upgrade/from0to1.js and 1 other location - About 4 hrs to fix
          apps/strider/dist-lib/models/upgrade/from0to1.js on lines 381..403

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

          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 makeBranch(repo, user, heroku) {
            return {
              active: repo.active,
              name: 'master',
              mirror_master: false,
          Severity: Major
          Found in apps/strider/lib/models/upgrade/from0to1.js and 1 other location - About 4 hrs to fix
          apps/strider/dist-lib/models/upgrade/from0to1.js on lines 404..422

          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

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

            for (let i = 0; i < repos.length; i++) {
              if (repos[i].html_url === repo.display_url) {
                id = repos[i].id;
                url = `git://${repos[i].git_url.split('//')[1]}`;
                break;
          Severity: Major
          Found in apps/strider/lib/models/upgrade/from0to1.js and 1 other location - About 3 hrs to fix
          apps/strider/dist-lib/models/upgrade/from0to1.js on lines 278..284

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

          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 makeProject(name, repo, user, heroku) {
            return {
              name: name.toLowerCase(),
              secret: repo.secret,
              public: repo.public,
          Severity: Major
          Found in apps/strider/lib/models/upgrade/from0to1.js and 1 other location - About 2 hrs to fix
          apps/strider/dist-lib/models/upgrade/from0to1.js on lines 423..434

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

          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 {
              type: 'commit',
              author: commit.author,
              message: commit.message,
              timestamp: commit.timestamp,
          Severity: Major
          Found in apps/strider/lib/models/upgrade/from0to1.js and 1 other location - About 2 hrs to fix
          apps/strider/dist-lib/models/upgrade/from0to1.js on lines 121..128

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

          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 convertGithub(user) {
            if (!user.github) return {};
            const g = user.github;
            return {
              accessToken: g.accessToken,
          Severity: Major
          Found in apps/strider/lib/models/upgrade/from0to1.js and 1 other location - About 2 hrs to fix
          apps/strider/dist-lib/models/upgrade/from0to1.js on lines 435..446

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

          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 killAttrs(model, attrs) {
            for (let i = 0; i < attrs.length; i++) {
              delete model[attrs[i]];
            }
          }
          Severity: Minor
          Found in apps/strider/lib/models/upgrade/from0to1.js and 1 other location - About 50 mins to fix
          apps/strider/dist-lib/models/upgrade/from0to1.js on lines 173..177

          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

          function makeName(url) {
            return url.split('/').slice(-2).join('/').split('.')[0];
          }
          Severity: Minor
          Found in apps/strider/lib/models/upgrade/from0to1.js and 1 other location - About 45 mins to fix
          apps/strider/dist-lib/models/upgrade/from0to1.js on lines 269..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 50.

          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

          module.exports = function (done) {
            upgradeUsers(function (err) {
              if (err) return done(err);
              upgradeJobs(done);
            });
          Severity: Minor
          Found in apps/strider/lib/models/upgrade/from0to1.js and 1 other location - About 40 mins to fix
          apps/strider/dist-lib/models/upgrade/from0to1.js on lines 7..13

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

          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

          There are no issues that match your filters.

          Category
          Status