silentrob/superscript

View on GitHub

Showing 92 of 92 total issues

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

  if (this.message.lemWords.indexOf('before') !== -1) {
    if (alpha[pos - 1]) {
      reply = alpha[pos - 1].toUpperCase();
    } else {
      reply = "Don't be silly, there is nothing before A";
Severity: Minor
Found in src/plugins/alpha.js and 1 other location - About 50 mins to fix
src/plugins/alpha.js on lines 55..81

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

  } else if (this.message.lemWords.indexOf('after') !== -1) {
    if (alpha[pos + 1]) {
      reply = alpha[pos + 1].toUpperCase();
    } else {
      reply = 'haha, funny.';
Severity: Minor
Found in src/plugins/alpha.js and 1 other location - About 50 mins to fix
src/plugins/alpha.js on lines 49..81

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

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].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 (!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 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

        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

          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

          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 processNewTopic(tag, replyObj, options);
            Severity: Major
            Found in src/bot/processTags.js - About 30 mins to fix

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

                try {
                  cleanArgs = safeEval(tag.functionArgs);
                } catch (e) {
                  throw new Error(`Error processing custom function arguments: ${e}`);
                }
              Severity: Minor
              Found in src/bot/processTags.js and 2 other locations - About 30 mins to fix
              src/bot/processTags.js on lines 215..219
              src/bot/processTags.js on lines 232..236

              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

              Avoid too many return statements within this function.
              Open

                    return processEndSearching(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

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

                    try {
                      cleanedArgs = safeEval(tag.functionArgs);
                    } catch (err) {
                      throw new Error(`Error processing topicRedirect args: ${err}`);
                    }
                  Severity: Minor
                  Found in src/bot/processTags.js and 2 other locations - About 30 mins to fix
                  src/bot/processTags.js on lines 232..236
                  src/bot/processTags.js on lines 260..264

                  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

                  Avoid too many return statements within this function.
                  Open

                        return processContinueSearching(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 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
                          Severity
                          Category
                          Status
                          Source
                          Language