brussell98/Mirai

View on GitHub

Showing 9 of 9 total issues

Function constructor has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    constructor(bot, options = { }) {
        this.bot = bot;

        this.allowSelf = !!options.allowSelf;
        this.allowBots = !!options.allowBots;
Severity: Minor
Found in lib/ChatHandler.js - About 2 hrs 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 constructor has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    constructor(options = { }) {
        this.timestamps = !!options.timestamps;
        this.levels = {
            'log':     options.levels && options.levels.log !== undefined     ? options.levels.log     : true,
            'info':    options.levels && options.levels.info !== undefined    ? options.levels.info    : true,
Severity: Minor
Found in lib/Logger.js - About 2 hrs 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 getHelp has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    getHelp(message) {
        const help = Object.values(this.bot.commandPlugins).map(plugin => plugin.help).filter(help => help);
        switch (this.help.style) {
            case 'basic':
                return message.channel.createMessage(
Severity: Minor
Found in lib/ChatHandler.js - About 2 hrs 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 constructor has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    constructor(options = { }, rLogger, rChatHandler) {
        super(options.token, options.eris);

        this.carbonBotsKey = options.carbonBotsKey;
        this.discordBotsKey = options.discordBotsKey;
Severity: Minor
Found in lib/Bot.js - About 1 hr to fix

    Function constructor has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        constructor(bot, options = { }) {
            this.bot = bot;
    
            this.allowSelf = !!options.allowSelf;
            this.allowBots = !!options.allowBots;
    Severity: Minor
    Found in lib/ChatHandler.js - About 1 hr to fix

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

          sendMessage(message, content, options) {
              if (!message || (!content && !options))
                  return Promise.resolve();
      
              options = options || { };
      Severity: Minor
      Found in lib/Base/AbstractCommand.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

      Consider simplifying this complex logical expression.
      Open

                  if ((message.author.id === this.bot.user.id && this.allowSelf === false) ||
                      (message.author.bot && this.allowBots === false) ||
                      (message.channel.guild && this.bot.blacklistedGuilds.includes(message.channel.guild.id)) ||
                      this.bot.blacklistedUsers.includes(message.author.id))
                      return;
      Severity: Major
      Found in lib/ChatHandler.js - About 1 hr to fix

        Function findMember has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            findMember(query, members) {
                query = query.toLowerCase().trim();
        
                if (/^[0-9]{16,19}$/.test(query)) { // If query looks like an ID try to get by ID
                    const member = members.get(query);
        Severity: Minor
        Found in lib/Bot.js - About 25 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 constructor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            constructor(options = { }, rLogger, rChatHandler) {
                super(options.token, options.eris);
        
                this.carbonBotsKey = options.carbonBotsKey;
                this.discordBotsKey = options.discordBotsKey;
        Severity: Minor
        Found in lib/Bot.js - About 25 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