silentrob/superscript

View on GitHub

Showing 92 of 92 total issues

Function postParse has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const postParse = function postParse(regexp, message, user) {
  if (_.isNull(regexp)) {
    return null;
  }

Severity: Minor
Found in src/bot/postParse.js - About 1 hr to fix

    Function findConversationTopics has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const findConversationTopics = async function findConversationTopics(pendingTopics, user, chatSystem, conversationTimeout) {
      if (user.history.length === 0) {
        return pendingTopics;
      }
    
    
    Severity: Minor
    Found in src/bot/getReply/getPendingTopics.js - About 1 hr to fix

      Function processReplyTags has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const processReplyTags = async function processReplyTags(replyObj, options) {
        debug.verbose('Depth: ', options.depth);
      
        let replyString = replyObj.reply.reply;
        debug.info(`Reply before processing reply tags: "${replyString}"`);
      Severity: Minor
      Found in src/bot/processTags.js - About 1 hr to fix

        Function processStars has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        const processStars = function processStars(match, gambit, topic) {
          debug.verbose(`Match found: ${gambit.input} in topic: ${topic}`);
          const stars = [];
          if (match.length > 1) {
            for (let j = 1; j < match.length; j++) {
        Severity: Minor
        Found in src/bot/getReply/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 findMatches has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const findMatches = async function findMatches(pendingTopics, messageObject, options) {
          debug.verbose(`Found pending topics/conversations: ${JSON.stringify(pendingTopics)}`);
        
          const replies = [];
          let stopSearching = false;
        Severity: Minor
        Found in src/bot/getReply/index.js - About 1 hr to fix

          Function inlineRedirect has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const inlineRedirect = async function inlineRedirect(triggerTarget, options) {
            debug.verbose(`Inline redirection to: '${triggerTarget}'`);
          
            // if we have a special topic, reset it to the previous one
            // in order to preserve the context for inline redirection
          Severity: Minor
          Found in src/bot/reply/inlineRedirect.js - About 1 hr to fix

            Function eachTopicItor has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              const eachTopicItor = function eachTopicItor(topicName, nextTopic) {
                const topic = data.topics[topicName];
                debug.verbose(`Find or create topic with name '${topicName}'`);
                const topicProperties = {
                  name: topic.name,
            Severity: Minor
            Found in src/bot/db/import.js - About 1 hr to fix

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

                const redirectMessage = await new Promise((resolve, reject) => {
                  Message.createMessage(topicTrigger, messageOptions, (err, redirectMessage) => {
                    err ? reject(err) : resolve(redirectMessage);
                  });
                });
              Severity: Major
              Found in src/bot/reply/topicRedirect.js and 1 other location - About 1 hr to fix
              src/bot/reply/inlineRedirect.js on lines 32..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 57.

              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 redirectMessage = await new Promise((resolve, reject) => {
                  Message.createMessage(triggerTarget, messageOptions, (err, redirectMessage) => {
                    err ? reject(err) : resolve(redirectMessage);
                  });
                });
              Severity: Major
              Found in src/bot/reply/inlineRedirect.js and 1 other location - About 1 hr to fix
              src/bot/reply/topicRedirect.js on lines 26..30

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

              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 findConversationTopics has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              const findConversationTopics = async function findConversationTopics(pendingTopics, user, chatSystem, conversationTimeout) {
                if (user.history.length === 0) {
                  return pendingTopics;
                }
              
              
              Severity: Minor
              Found in src/bot/getReply/getPendingTopics.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 matchItorHandle has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              const matchItorHandle = async function matchItorHandle(match, message, options) {
                const system = options.system;
                options.message = message;
              
                debug.verbose('Match itor: ', match.gambit);
              Severity: Minor
              Found in src/bot/getReply/index.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 doesMatch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              export const doesMatch = async function doesMatch(gambit, message, options) {
                if (gambit.conditions && gambit.conditions.length > 0) {
                  const conditionsMatch = processConditions(gambit.conditions, options);
                  if (!conditionsMatch) {
                    debug.verbose('Conditions did not match');
              Severity: Minor
              Found in src/bot/getReply/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 processCustomFunction has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const processCustomFunction = async function processCustomFunction(tag, replyObj, options) {
                if (tag.functionArgs === null) {
                  debug.verbose(`Processing custom function: ^${tag.functionName}()`);
                  return customFunction(tag.functionName, [], replyObj, options);
                }
              Severity: Minor
              Found in src/bot/processTags.js - About 1 hr to fix

                Function createReplyModel has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const createReplyModel = function createReplyModel(db) {
                  const replySchema = new mongoose.Schema({
                    id: { type: String, index: true, default: Utils.genId() },
                    reply: { type: String, required: '{reply} is required.' },
                    keep: { type: Boolean, default: false },
                Severity: Minor
                Found in src/bot/db/models/reply.js - About 1 hr to fix

                  Function doesMatch has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const doesMatch = async function doesMatch(gambit, message, options) {
                    if (gambit.conditions && gambit.conditions.length > 0) {
                      const conditionsMatch = processConditions(gambit.conditions, options);
                      if (!conditionsMatch) {
                        debug.verbose('Conditions did not match');
                  Severity: Minor
                  Found in src/bot/getReply/helpers.js - About 1 hr to fix

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

                    const filterRepliesByFunction = async function filterRepliesByFunction(potentialReplies, options) {
                      const bits = await Promise.all(potentialReplies.map(async (potentialReply) => {
                        const system = options.system;
                    
                        // We support a single filter function in the reply
                    Severity: Minor
                    Found in src/bot/getReply/filterFunction.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 eachGambitHandle has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const eachGambitHandle = async function eachGambitHandle(gambit, message, options) {
                      const plugins = options.system.plugins;
                      const scope = options.system.scope;
                      const topic = options.topic || 'reply';
                      const chatSystem = options.system.chatSystem;
                    Severity: Minor
                    Found in src/bot/getReply/helpers.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 wordLength has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const wordLength = function wordLength(cap, cb) {
                      if (typeof cap === 'string') {
                        const parts = cap.split(' ');
                        if (parts.length === 1) {
                          cb(null, cap.length);
                    Severity: Minor
                    Found in src/plugins/alpha.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

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

                      const redirectReply = await new Promise((resolve, reject) => {
                        getReply(redirectMessage, options, (err, redirectReply) => {
                          err ? reject(err) : resolve(redirectReply);
                        });
                      });
                    Severity: Minor
                    Found in src/bot/reply/topicRedirect.js and 1 other location - About 55 mins to fix
                    src/bot/reply/inlineRedirect.js on lines 40..44

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

                    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

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

                      const redirectReply = await new Promise((resolve, reject) => {
                        getReply(redirectMessage, options, (err, redirectReply) => {
                          err ? reject(err) : resolve(redirectReply);
                        });
                      });
                    Severity: Minor
                    Found in src/bot/reply/inlineRedirect.js and 1 other location - About 55 mins to fix
                    src/bot/reply/topicRedirect.js on lines 34..38

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

                    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