progdisc/AwesomeBot

View on GitHub

Showing 16 of 21 total issues

Function run has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  run: (bot, message, cmdArgs) => {
    if (!cmdArgs) {
      const langList = availableLanguages.reduce((prev, x) => {
        let langEntry = `${prev}${prev ? '\n' : ''}- ${x}`;
        const aliases = Object.keys(langAliases)
Severity: Major
Found in commands/eval/eval.js - About 2 hrs to fix

    Function getWeatherData has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function getWeatherData(location) {
      const requestURL = darkskyEndpoint
        .replace('key', tokens.darksky)
        .replace('lat', location.coordinate.lat)
        .replace('lng', location.coordinate.lng);
    Severity: Minor
    Found in commands/weather/weather.js - About 1 hr to fix

      Function run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        run: (bot, message, cmdArgs) => {
          if (!cmdArgs) {
            const langList = availableLanguages.reduce((prev, x) => {
              let langEntry = `${prev}${prev ? '\n' : ''}- ${x}`;
              const aliases = Object.keys(langAliases)
      Severity: Minor
      Found in commands/eval/eval.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 run has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        run(bot, message, cmdArgs) {
          if (!cmdArgs) {
            return true;
          }
      
      
      Severity: Minor
      Found in commands/pro/pro.js - About 1 hr to fix

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

          run: (bot, message, cmdArgs) => {
            let pbfLink = false;
        
            if (cmdArgs === 'random') {
              pbfLink = 'http://pbfcomics.com/random';
        Severity: Minor
        Found in commands/pbf/pbf.js - About 1 hr to fix

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

            onMessage() {
              return (message) => {
                // don't respond to own messages
                if (this.client.user.username === message.author.username) {
                  return;
          Severity: Minor
          Found in TheAwesomeBot.js - About 1 hr to fix

            Function processVote has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function processVote(type, bot, message, guild, member) {
              let voting = currentVotes[type][member.user.username];
            
              if (!voting) {
                // sets a timeout for this voting
            Severity: Minor
            Found in commands/vote/vote.js - About 1 hr to fix

              Function handleCreateStream has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                create: function handleCreateStream(bot, message, args) {
                  let [, topic, link, user] = args.split(' '); // eslint-disable-line prefer-const
              
                  if (!topic || !link) {
                    return message.channel.sendMessage('err, please provide topic and link!');
              Severity: Minor
              Found in commands/stream/stream.js - About 1 hr to fix

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

                  run(bot, message, cmdArgs) {
                    if (!cmdArgs) {
                      return true;
                    }
                
                
                Severity: Minor
                Found in commands/pro/pro.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 setTopicToLink has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function setTopicToLink(channel, link, bot, topic, user) {
                Severity: Minor
                Found in commands/stream/stream.js - About 35 mins to fix

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

                  function processVote(type, bot, message, guild, member) {
                  Severity: Minor
                  Found in commands/vote/vote.js - About 35 mins to fix

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

                    function createChannel(title, bot, message, topic, user) {
                    Severity: Minor
                    Found in commands/stream/stream.js - About 35 mins to fix

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

                        create: function handleCreateStream(bot, message, args) {
                          let [, topic, link, user] = args.split(' '); // eslint-disable-line prefer-const
                      
                          if (!topic || !link) {
                            return message.channel.sendMessage('err, please provide topic and link!');
                      Severity: Minor
                      Found in commands/stream/stream.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 false;
                      Severity: Major
                      Found in commands/vote/vote.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return false;
                        Severity: Major
                        Found in commands/vote/vote.js - About 30 mins to fix

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

                          function infoRun(bot, message, cmdArgs) {
                            if (cmdArgs) {
                              if (cmdArgs === 'contributors') {
                                const contributorsEmbed = new discord.RichEmbed();
                                contributorsEmbed.setColor('#4286f4')
                          Severity: Minor
                          Found in commands/info/info.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