meedan/check-bot

View on GitHub

Showing 102 of 102 total issues

Function handler has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.handler = function(data, context, callback) {
  let options = {
    url: 'https://www.google.com/searchbyimage',
    qs: { image_url: data.image_url, sbisrc: '4chanx', safe: 'off' },
    headers: { 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36', 'accept-language': 'en-US,en;q=0.5' }
Severity: Minor
Found in google-image-search.js - About 1 hr to fix

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

      const event3 = { channel: uid, bot_id: 'ABCDEFGH', attachments: [{ fields: [{ title: 'App', value: 'Test' }, { title: 'Device Info', value: 'Device: WhatsApp Messenger | Phone Number: \u003ctel:' + identifier + '|' + identifier + '\u003e' }] }] };
    Severity: Major
    Found in index.test.js and 1 other location - About 1 hr to fix
    index.test.js on lines 530..530

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

    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

      const event4 = { channel: uid, bot_id: 'ABCDEFGH', attachments: [{ fields: [{ title: 'App', value: 'Test' }, { title: 'Device Info', value: 'Device: WhatsApp Messenger | Phone Number: <tel:' + identifier + '|' + identifier + '>' }] }] };
    Severity: Major
    Found in index.test.js and 1 other location - About 1 hr to fix
    index.test.js on lines 521..521

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

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

    const process = function(body, token, callback) {
      const setProjectRegexp = new RegExp(/set <(.+)>/, 'g');
      const showProjectRegexp = new RegExp(/^show/, 'g');
      const addUrlRegexp = new RegExp(/<(.+)>/, 'g');
      const activateBotRegexp = new RegExp(/^bot activate/, 'g');
    Severity: Minor
    Found in slash.js - About 1 hr to fix

      Function updateTitleOrDescription has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const updateTitleOrDescription = function(attribute, event, data, token, callback, done) {
        const id = data.last_status_id,
              text = event.text;
      
        const mutationQuery = `($setFields: String!, $id: ID!, $clientMutationId: String!) {
      Severity: Minor
      Found in index.js - About 1 hr to fix

        Function getProjectMedia has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const getProjectMedia = function(teamSlug, projectId, projectMediaId, callback, done) {
          const client = getGraphqlClient(teamSlug, config.checkApi.apiKey, callback);
        
          const projectMediaQuery = `
          query project_media($ids: String!) {
        Severity: Minor
        Found in index.js - About 1 hr 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

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

            test('verify call if team is in config', () => {
              const data = buildData('123456abcdef', 'url_verification');
              const callback = jest.fn();
              buttons.handler(data, null, callback);
              expect(callback).toHaveBeenCalledWith(null, 'challenge');
            Severity: Major
            Found in buttons.test.js and 1 other location - About 1 hr to fix
            index.test.js on lines 31..36

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

            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

            test('verify call if team is in config', () => {
              const data = buildData('123456abcdef', 'url_verification');
              const callback = jest.fn();
              index.handler(data, null, callback);
              expect(callback).toHaveBeenCalledWith(null, 'challenge');
            Severity: Major
            Found in index.test.js and 1 other location - About 1 hr to fix
            buttons.test.js on lines 19..24

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

            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

            test('does not verify call if team is not in config', () => {
              const data = buildData('notinconfig', 'url_verification');
              const callback = jest.fn();
              index.handler(data, null, callback);
              expect(callback).toHaveBeenCalledWith('Verification failed');
            Severity: Major
            Found in index.test.js and 1 other location - About 1 hr to fix
            buttons.test.js on lines 26..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 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('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

            test('does not verify call if team is not in config', () => {
              const data = buildData('notinconfig', 'url_verification');
              const callback = jest.fn();
              buttons.handler(data, null, callback);
              expect(callback).toHaveBeenCalledWith('Verification failed');
            Severity: Major
            Found in buttons.test.js and 1 other location - About 1 hr to fix
            index.test.js on lines 38..43

            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

              const event9 = { channel: uid, bot_id: 'ABCDEFGH', attachments: [{ fields: [{ title: 'App', value: 'Test' }, { title: 'Device Info', value: 'Device: Viber Messenger | Profile Photo: https://media-direct.cdn.viber.com/download_photo?dlid=' + identifier + '&fltp=jpg&imsz=0000' }] }] };
            Severity: Major
            Found in index.test.js and 1 other location - About 1 hr to fix
            index.test.js on lines 548..548

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

            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

              const event6 = { channel: uid, bot_id: 'ABCDEFGH', attachments: [{ fields: [{ title: 'App', value: 'Test' }, { title: 'Device Info', value: 'Device: Twitter DM | Profile Image: https://twitter.com/profile_images/' + identifier + '/image.png' }] }] };
            Severity: Major
            Found in index.test.js and 1 other location - About 1 hr to fix
            index.test.js on lines 569..569

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

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

              const testEditMedia = async (field) => {
                let outputData = '';
                storeLog = inputs => (outputData += inputs);
                console['log'] = jest.fn(storeLog);
              
              
              Severity: Minor
              Found in index.test.js - About 1 hr to fix

                Function fieldCallback has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      const fieldCallback = function(resp) {
                        if (!resp && n < 60) {
                          n++;
                          setTimeout(function() { getField(query, callback, fieldCallback) }, 5000);
                        }
                Severity: Minor
                Found in index.js - About 1 hr to fix

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

                    const event5 = { channel: uid, bot_id: 'ABCDEFGH', attachments: [{ fields: [{ title: 'App', value: 'Test' }, { title: 'Device Info', value: 'Device: Facebook Messenger | Profile Image: https://facebook.com/psid=' + identifier }] }] };
                  Severity: Major
                  Found in index.test.js and 2 other locations - About 1 hr to fix
                  index.test.js on lines 477..477
                  index.test.js on lines 578..578

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

                  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