Strider-CD/strider

View on GitHub
apps/strider/dist-lib/routes/admin/index.js

Summary

Maintainability
F
1 wk
Test Coverage

Function job has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.job = function (req, res) {
    res.statusCode = 200;
    const org = req.params.org;
    const repo = req.params.repo;
    const jobId = req.params.job_id;
Severity: Major
Found in apps/strider/dist-lib/routes/admin/index.js - About 3 hrs to fix

    Function job has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.job = function (req, res) {
        res.statusCode = 200;
        const org = req.params.org;
        const repo = req.params.repo;
        const jobId = req.params.job_id;
    Severity: Minor
    Found in apps/strider/dist-lib/routes/admin/index.js - About 2 hrs 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 processAndRender has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        }, function processAndRender(err, resultsDetail, results) {
            if (err)
                throw err;
            results.forEach(function (job) {
                job.duration = Math.round((job.finished_timestamp - job.created_timestamp) / 1000);
    Severity: Major
    Found in apps/strider/dist-lib/routes/admin/index.js - About 2 hrs to fix

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

      exports.job = function (req, res) {
          res.statusCode = 200;
          const org = req.params.org;
          const repo = req.params.repo;
          const jobId = req.params.job_id;
      Severity: Major
      Found in apps/strider/dist-lib/routes/admin/index.js and 1 other location - About 5 days to fix
      apps/strider/lib/routes/admin/index.js on lines 128..233

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

      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

      exports.removeUser = function (req, res) {
          User.findOne({ email: req.body.email }, function (err, user) {
              if (err || !user) {
                  req.flash('admin', 'Failed to find user');
                  return res.redirect('/admin/users');
      Severity: Major
      Found in apps/strider/dist-lib/routes/admin/index.js and 1 other location - About 1 day to fix
      apps/strider/lib/routes/admin/index.js on lines 80..100

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

      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

      exports.invites = function (req, res) {
          InviteCode.find({})
              .populate('consumed_by_user')
              .sort({ _id: -1 })
              .exec(function (err, results) {
      Severity: Major
      Found in apps/strider/dist-lib/routes/admin/index.js and 1 other location - About 7 hrs to fix
      apps/strider/lib/routes/admin/index.js on lines 28..45

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

      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

      exports.users = function (req, res) {
          User.find({})
              .sort({ _id: -1 })
              .exec(function (err, users) {
              res.render('admin/users.html', {
      Severity: Major
      Found in apps/strider/dist-lib/routes/admin/index.js and 1 other location - About 6 hrs to fix
      apps/strider/lib/routes/admin/index.js on lines 51..65

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 163.

      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

      exports.makeAdmin = function (req, res) {
          if (!req.body.user) {
              return res.redirect('/admin/users');
          }
          users.makeAdmin(req.body.user, function (err) {
      Severity: Major
      Found in apps/strider/dist-lib/routes/admin/index.js and 1 other location - About 3 hrs to fix
      apps/strider/lib/routes/admin/index.js on lines 67..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 109.

      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

      exports.projects = function (req, res) {
          projects.allProjects(function (err, projects) {
              if (err)
                  return res.send(500, 'Error retrieving projects');
              res.render('admin/projects.html', {
      Severity: Major
      Found in apps/strider/dist-lib/routes/admin/index.js and 1 other location - About 2 hrs to fix
      apps/strider/lib/routes/admin/index.js on lines 106..114

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

      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 makeInviteCode() {
          const random = crypto.randomBytes(5).toString('hex');
          return base32.encode(random);
      }
      Severity: Minor
      Found in apps/strider/dist-lib/routes/admin/index.js and 1 other location - About 35 mins to fix
      apps/strider/lib/routes/admin/index.js on lines 20..23

      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

      There are no issues that match your filters.

      Category
      Status