meedan/check-bot

View on GitHub

Showing 35 of 102 total issues

Function formatMessageFromData has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const formatMessageFromData = function(data) {

  // Build a list of verification statuses (core or custom) to be selected
  // Get the current status (label and color)

Severity: Minor
Found in helpers.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 executeMutation has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

const executeMutation = function(mutationQuery, vars, fail, done, token, callback, event, data) {
Severity: Major
Found in helpers.js - About 1 hr to fix

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

    const process = function(data, callback, context) {
      if (data.token === VERIFICATION_TOKEN) {
    
        getCheckSlackUser(data.user.id,
          function(err) {
    Severity: Minor
    Found in buttons.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

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

    const updateTitleOrDescription = function(attribute, event, data, token, callback, done) {
    Severity: Minor
    Found in index.js - About 45 mins 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 saveAndReply has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            const saveAndReply = function(data, token, callback, mode, newMessage, attachments) {
            Severity: Minor
            Found in helpers.js - About 45 mins to fix

              Function getIdentifier has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              const getIdentifier = function(text) {
                let identifier = null;
                // The identifier is different depending on the platform
                if (/WhatsApp Messenger/.test(text)) {
                  identifier = text.match(/Phone Number:\s(.*)/)[1];
              Severity: Minor
              Found in helpers.js - About 45 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

              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

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

                const setSmoochUserSlackChannelUrl = function(event, data, token, callback, done) {
                Severity: Minor
                Found in index.js - About 35 mins to fix

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

                  const getProjectMedia = function(teamSlug, projectId, projectMediaId, callback, done) {
                  Severity: Minor
                  Found in index.js - About 35 mins to fix

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

                    const createComment = function(event, data, token, callback, done) {
                    Severity: Minor
                    Found in index.js - About 35 mins to fix

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

                      const saveToRedisAndReplyToSlack = function(redisKey, value, message, done, callback) {
                      Severity: Minor
                      Found in helpers.js - About 35 mins to fix

                        Function handler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        exports.handler = function(event, context, callback) {
                          const body = config.awsRegion === 'local' ? event.body : qs.parse(decodeURIComponent(event.body));
                          const teamConfig = getTeamConfig(body.team_id);
                          if (body.token === teamConfig.verificationToken) {
                            if (/^bot /.test(body.text) || body.text === '') {
                        Severity: Minor
                        Found in slash.js - About 35 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

                        Severity
                        Category
                        Status
                        Source
                        Language