silentrob/superscript

View on GitHub

Showing 67 of 92 total issues

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

const createUserModel = function createUserModel(db, factSystem, logger) {
  const userSchema = mongoose.Schema({
    id: String,
    currentTopic: { type: String, default: 'random' },
    pendingTopic: String,
Severity: Minor
Found in src/bot/db/models/user.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 topicRedirect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const topicRedirect = async function topicRedirect(topicName, topicTrigger, options) {
  debug.verbose(`Topic redirection to topic: ${topicName}, trigger: ${topicTrigger}`);

  // Here we are looking for gambits in the NEW topic.
  // TODO: Deprecate this behaviour: a failed topic lookup should fail the whole reply
Severity: Minor
Found in src/bot/reply/topicRedirect.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

Avoid deeply nested control flow statements.
Open

        if (!track[inherits].atomic[cnt]) {
          track[inherits].atomic[cnt] = [];
        }
Severity: Major
Found in src/bot/db/sort.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

            if (num > 0 && num <= 26) {
              reply = `It is ${alpha[num - 1].toUpperCase()}`;
            } else {
              reply = 'seriously...';
            }
    Severity: Major
    Found in src/plugins/alpha.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                if (!track[inherits].wild[cnt]) {
                  track[inherits].wild[cnt] = [];
                }
      Severity: Major
      Found in src/bot/db/sort.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                if (!track[inherits].option[cnt]) {
                  track[inherits].option[cnt] = [];
                }
        Severity: Major
        Found in src/bot/db/sort.js - About 45 mins to fix

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

          const receiveData = function receiveData(slack, bot, data) {
            // Fetch the user who sent the message;
            const user = data._client.users[data.user];
            let channel;
            const messageData = data.toJSON();
          Severity: Minor
          Found in clients/slack.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 importData has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          const importData = function importData(chatSystem, data, callback) {
            if (!data.version || data.version < MIN_SUPPORTED_SCRIPT_VERSION) {
              return callback(`Error: Your script has version ${data.version} but the minimum supported version is ${MIN_SUPPORTED_SCRIPT_VERSION}.\nPlease either re-parse your file with a supported parser version, or update SuperScript.`);
            }
          
          
          Severity: Minor
          Found in src/bot/db/import.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

          Avoid too many return statements within this function.
          Open

                return processCustomFunction(tag, replyObj, options);
          Severity: Major
          Found in src/bot/processTags.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return processAlternates(tag, replyObj, options);
            Severity: Major
            Found in src/bot/processTags.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return callback(null, bot);
              Severity: Major
              Found in src/bot/index.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return processNewTopic(tag, replyObj, options);
                Severity: Major
                Found in src/bot/processTags.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                    return false;
                  Severity: Major
                  Found in src/bot/getReply/index.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return false;
                    Severity: Major
                    Found in src/bot/getReply/index.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            return processSetState(tag, replyObj, options);
                      Severity: Major
                      Found in src/bot/processTags.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return helpers.findMatchingGambitsForMessage('reply', reply, messageObject, options);
                        Severity: Major
                        Found in src/bot/getReply/index.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                            return processStars(match, gambit, topic);
                          Severity: Major
                          Found in src/bot/getReply/helpers.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                return pendingTopics;
                            Severity: Major
                            Found in src/bot/getReply/getPendingTopics.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                    return processWordnetLookup(tag, replyObj, options);
                              Severity: Major
                              Found in src/bot/processTags.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                      return processRedirect(tag, replyObj, options);
                                Severity: Major
                                Found in src/bot/processTags.js - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language