meedan/check-bot

View on GitHub
slash-response.js

Summary

Maintainability
D
2 days
Test Coverage
A
100%

File slash-response.js has 310 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// This function adds a ProjectMedia to Check and sends a message back to Slack

const config = require('./config.js'),
      request = require('request'),
      util = require('util'),
Severity: Minor
Found in slash-response.js - About 3 hrs to fix

    Function sendActionToSmoochBot has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const sendActionToSmoochBot = function(payload, redisKey, callback, action) {
      let message = ''
      const redis = getRedisClient();
      redis.on('connect', function() {
        redis.get(redisKey, function(err, reply) {
    Severity: Major
    Found in slash-response.js - About 2 hrs to fix

      Function sendSmoochImage has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const sendSmoochImage = function(payload, callback) {
        const redis = getRedisClient();
        redis.on('connect', function() {
          const redisKey = 'slack_channel_smooch:' + config.redisPrefix + ':' + payload.body.channel;
          redis.get(redisKey, function(err, reply) {
      Severity: Minor
      Found in slash-response.js - About 1 hr to fix

        Function showTips has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const showTips = function(payload, callback) {
          let message = {
            response_type: 'ephemeral',
            text: ':wave: ' + t('need_some_help_with') + ' `' + payload.body.command + '`?',
            attachments: [
        Severity: Minor
        Found in slash-response.js - About 1 hr to fix

          Function createProjectMedia has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          const createProjectMedia = function(team_id, responseUrl, vars, token, data, callback) {
          Severity: Minor
          Found in slash-response.js - About 45 mins to fix

            Function getProject has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            const getProject = function(teamSlug, projectId, token, done, fail, callback) {
            Severity: Minor
            Found in slash-response.js - About 45 mins to fix

              Function sendErrorMessage has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              const sendErrorMessage = function(e, vars, text, team_id, responseUrl, callback) {
              Severity: Minor
              Found in slash-response.js - About 45 mins to fix

                Function fail has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  const fail = function(callback, thread, channel, link, e) {
                Severity: Minor
                Found in slash-response.js - About 35 mins to fix

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

                        {
                          text: t('show_the_default_project_for_this_channel') + ':\n `' + payload.body.command + ' show`',
                          mrkdwn_in: ['text'],
                          fallback: t('show_the_default_project_for_this_channel') + ':\n `' + payload.body.command + ' show`'
                        },
                  Severity: Major
                  Found in slash-response.js and 2 other locations - About 1 hr to fix
                  slash-response.js on lines 296..300
                  slash-response.js on lines 301..305

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

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

                        {
                          text: t('reactivate_Smooch_bot_for_this_conversation') + ':\n `' + payload.body.command + ' bot activate`',
                          mrkdwn_in: ['text'],
                          fallback: t('reactivate_Smooch_bot_for_this_conversation') + ':\n `' + payload.body.command + ' bot activate`',
                        },
                  Severity: Major
                  Found in slash-response.js and 2 other locations - About 1 hr to fix
                  slash-response.js on lines 286..290
                  slash-response.js on lines 301..305

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

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

                        {
                          text: t('send_message_to_Smooch_bot') + ':\n `' + payload.body.command + ' bot send [message]`',
                          mrkdwn_in: ['text'],
                          fallback: t('send_message_to_Smooch_bot') + ':\n `' + payload.body.command + ' bot send [message]`',
                        },
                  Severity: Major
                  Found in slash-response.js and 2 other locations - About 1 hr to fix
                  slash-response.js on lines 286..290
                  slash-response.js on lines 296..300

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

                  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

                          text: t('send_a_URL_to') + ' ' + humanAppName() + '. ' + t('a_default_project_for_this_channel_must_be_already_defined') + ':\n `' + payload.body.command + ' [URL]`',
                  Severity: Minor
                  Found in slash-response.js and 1 other location - About 50 mins to fix
                  slash-response.js on lines 294..294

                  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

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

                          fallback: t('send_the_URL_to') + ' ' + humanAppName() + '. ' + t('a_default_project_for_this_channel_must_be_already_defined') + ':\n `' + payload.body.command + ' [URL]`'
                  Severity: Minor
                  Found in slash-response.js and 1 other location - About 50 mins to fix
                  slash-response.js on lines 292..292

                  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

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

                          fallback: t('define_the_default_project_for_this_channel') + ':\n `' + payload.body.command + ' set ' + config.checkWeb.url + '/[team slug]/project/[project id]`'
                  Severity: Minor
                  Found in slash-response.js and 1 other location - About 30 mins to fix
                  slash-response.js on lines 282..282

                  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

                          text: t('define_the_default_project_for_this_channel') + ':\n `' + payload.body.command + ' set ' + config.checkWeb.url + '/[team slug]/project/[project id]`',
                  Severity: Minor
                  Found in slash-response.js and 1 other location - About 30 mins to fix
                  slash-response.js on lines 284..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 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

                  There are no issues that match your filters.

                  Category
                  Status