asdqwex/discobot

View on GitHub

Showing 112 of 112 total issues

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

      customsearch.cse.list({ cx: CX, q: SEARCH, auth: API_KEY, searchType: 'image', num: 10 }, function (err, resp) {
        if (err) {
          LOG.error('An error occured', err)
          return
        }
Severity: Major
Found in src/modules/image.js and 1 other location - About 7 hrs to fix
src/modules/cat.js on lines 18..32

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

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

    customsearch.cse.list({ cx: CX, q: SEARCH, auth: API_KEY, searchType: 'image', num: 10 }, function (err, resp) {
      if (err) {
        LOG.error('An error occured', err)
        return
      }
Severity: Major
Found in src/modules/cat.js and 1 other location - About 7 hrs to fix
src/modules/image.js on lines 21..35

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

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

  if (message.indexOf('(╯°□°)╯︵ ┻━┻') > -1) {
    const count = (message.match(/\(\╯\°\□\°\)\╯\︵ \┻\━\┻/g) || []).length
    const tableArray = []
    for (let i = 0; i < count; i++) {
      tableArray.push('┬─┬ ノ( ゜-゜ノ)')
Severity: Major
Found in src/index.js and 1 other location - About 3 hrs to fix
src/modules/table_flip.js on lines 9..19

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

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

    if (message.indexOf('(╯°□°)╯︵ ┻━┻') > -1 && message.indexOf('will flip all table back upright') === -1) {
      const count = (message.match(/\(\╯\°\□\°\)\╯\︵ \┻\━\┻/g) || []).length
      const tableArray = []
      for (let i = 0; i < count; i++) {
        tableArray.push('┬─┬ ノ( ゜-゜ノ)')
Severity: Major
Found in src/modules/table_flip.js and 1 other location - About 3 hrs to fix
src/index.js on lines 164..174

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

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 onMessage has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    onMessage: function (bot, user, userID, channelID, message, rawEvent) {
      const imgParts = message.split('"')
      const memeType = imgParts[0].split(' ')[1]
      const memeList = {
        '10guy': 101440,
Severity: Major
Found in src/modules/meme.js - About 2 hrs to fix

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

    module.exports = {
      names: ['yomama'],
      onMessage: function (bot, user, userID, channelID, message, rawEvent) {
        request('http://api.yomomma.info/', function (msg, response, body) {
          var joke = JSON.parse(body).joke
    Severity: Major
    Found in src/modules/yomama.js and 1 other location - About 2 hrs to fix
    src/modules/xkcd.js on lines 5..16

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

    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

    module.exports = {
      names: ['xkcd'],
      onMessage: function (bot, user, userID, channelID, message, rawEvent) {
        request('http://xkcd.com/info.0.json', function (msg, response, body) {
          var img = JSON.parse(body).img
    Severity: Major
    Found in src/modules/xkcd.js and 1 other location - About 2 hrs to fix
    src/modules/yomama.js on lines 5..16

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

    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

      gulp.src(MODULES_GLOB)
        .pipe(eslint()).pipe(eslint.format())
        .pipe(sourcemaps.init())
        .pipe(babel({ presets: [ 'es2015' ] }))
        .pipe(sourcemaps.write('.'))
    Severity: Major
    Found in gulpfile.babel.js and 1 other location - About 2 hrs to fix
    gulpfile.babel.js on lines 25..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 91.

    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

      gulp.src(MAIN_GLOB)
        .pipe(eslint()).pipe(eslint.format())
        .pipe(sourcemaps.init())
        .pipe(babel({ presets: [ 'es2015' ] }))
        .pipe(sourcemaps.write('.'))
    Severity: Major
    Found in gulpfile.babel.js and 1 other location - About 2 hrs to fix
    gulpfile.babel.js on lines 34..39

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

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

    const setupBot = function () {
      bot.on('ready', function (data) {
        // First wins if none is defined
        if (!bot.DISCORD_GUILD) bot.DISCORD_GUILD = data.d.guilds[0].id
        // Allow usage of text name or id
    Severity: Minor
    Found in src/index.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 onMessage has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      onMessage: function (bot, user, userID, channelID, message, rawEvent) {
        var parts = message.split(' ')
        parts.splice(0, 2)
        var verb = parts.splice(0, 1).join()
        if (verb === 'at') {
    Severity: Minor
    Found in src/modules/reminder.js - About 1 hr to fix

      Function initialize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      const initialize = function () {
        glob('_build/modules/*.js', function (err, files) {
          // Bail out if the modules directory doesn't exist. Your install is fucked?
          if (err) throw new Error(err)
          for (let i = 0; i < files.length; i++) {
      Severity: Minor
      Found in src/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 onMessage has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        onMessage: function (bot, user, userID, channelID, message, rawEvent) {
          var parts = message.split(' ')
          parts.splice(0, 2)
          var verb = parts.splice(0, 1).join()
          if (verb === 'at') {
      Severity: Minor
      Found in src/modules/reminder.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 onMessage has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        onMessage: function (bot, user, userID, channelID, message, rawEvent, {random}) {
          const rollMatches = search => {
            return regex`
            (
              (?<numDice> \d{0,4})
      Severity: Minor
      Found in src/modules/dice.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 onMessage has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const onMessage = function (user, userID, channelID, message, rawEvent) {
        if (message.indexOf('!bots?') > -1 && message.indexOf('Force all bots to identify themselves') === -1) {
          return bot.sendMessage({
            to: channelID,
            message: 'Hello I am a robot and my name is ' + bot.BOT_NAME
      Severity: Minor
      Found in src/index.js - About 1 hr to fix

        Function setupBot has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const setupBot = function () {
          bot.on('ready', function (data) {
            // First wins if none is defined
            if (!bot.DISCORD_GUILD) bot.DISCORD_GUILD = data.d.guilds[0].id
            // Allow usage of text name or id
        Severity: Minor
        Found in src/index.js - About 1 hr to fix

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

          const onMessage = function (user, userID, channelID, message, rawEvent) {
            if (message.indexOf('!bots?') > -1 && message.indexOf('Force all bots to identify themselves') === -1) {
              return bot.sendMessage({
                to: channelID,
                message: 'Hello I am a robot and my name is ' + bot.BOT_NAME
          Severity: Minor
          Found in src/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 onReady has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const onReady = function () {
          // Cron Jobby bit
            schedule.scheduleJob('announceGuard', '*/5 * * * *', function () {
              announceGuard = 0
            })
          Severity: Minor
          Found in src/index.js - About 1 hr to fix

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

              it(`rolls a number of sided dice.`, () => {
                const {message: actual} = roller('kingles', '2d10')
                const expected = 'Kingles rolled 2d10! ( 4 + 1 ) = 5'
            
                assert.equal(actual, expected)
            Severity: Major
            Found in test/modules/dice.spec.js and 3 other locations - About 1 hr to fix
            test/modules/dice.spec.js on lines 59..64
            test/modules/dice.spec.js on lines 66..71
            test/modules/dice.spec.js on lines 73..78

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

            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 4 locations. Consider refactoring.
            Open

              it(`ridicules the user when syntax is invalid`, () => {
                const {message: actual} = roller('kingles', 'ads')
                const expected = 'Kingles doesn\'t understand how rolling dice works.. ads is not a valid dice roll!'
            
                assert.equal(actual, expected)
            Severity: Major
            Found in test/modules/dice.spec.js and 3 other locations - About 1 hr to fix
            test/modules/dice.spec.js on lines 35..40
            test/modules/dice.spec.js on lines 66..71
            test/modules/dice.spec.js on lines 73..78

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

            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