michaelowens/AutoModerator

View on GitHub

Showing 24 of 24 total issues

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

    it('returns false if actions does not contain remove', () => {
      let cond1 = new Condition(myServerMock, {
        action: 'reply'
      })
      let cond2 = new Condition(myServerMock, {
Severity: Major
Found in __tests__/condition-test.js and 1 other location - About 4 hrs to fix
__tests__/condition-test.js on lines 181..195

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

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

    it('returns true if remove action is given', () => {
      let cond1 = new Condition(myServerMock, {
        action: 'remove'
      })
      let cond2 = new Condition(myServerMock, {
Severity: Major
Found in __tests__/condition-test.js and 1 other location - About 4 hrs to fix
__tests__/condition-test.js on lines 165..179

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

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

  matchesAgainstMessage(message: DiscordJS.Message) {
    // Check against user conditions first
    if ('user' in this.data) {
      if (!this.matchesAgainstUserConditions(message)) {
        console.log('user does not match')
Severity: Minor
Found in src/condition.js - About 3 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

File condition.js has 294 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* @flow */

import DiscordJS from 'discord.js'
import Discord from './bot/discord'
import Config from './config'
Severity: Minor
Found in src/condition.js - About 3 hrs to fix

    File condition-test.js has 264 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const ConditionImport = require('../src/condition')
    const Condition = ConditionImport.default
    const MatchModifiers = ConditionImport.MatchModifiers
    
    describe('Condition', () => {
    Severity: Minor
    Found in __tests__/condition-test.js - About 2 hrs to fix

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

            it('returns true if message matches message condition, with inverse', () => {
              let cond = new Condition(myServerMock, {
                '~message': 'not found message'
              })
              let message = {
      Severity: Major
      Found in __tests__/condition-test.js and 2 other locations - About 2 hrs to fix
      __tests__/condition-test.js on lines 294..305
      __tests__/condition-test.js on lines 307..318

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

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

            it('returns false if message does not match message condition, with inverse', () => {
              let cond = new Condition(myServerMock, {
                '~message': 'test message'
              })
              let message = {
      Severity: Major
      Found in __tests__/condition-test.js and 2 other locations - About 2 hrs to fix
      __tests__/condition-test.js on lines 281..292
      __tests__/condition-test.js on lines 294..305

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

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

            it('returns false if message does not match message condition', () => {
              let cond = new Condition(myServerMock, {
                'message': 'not found message'
              })
              let message = {
      Severity: Major
      Found in __tests__/condition-test.js and 2 other locations - About 2 hrs to fix
      __tests__/condition-test.js on lines 281..292
      __tests__/condition-test.js on lines 307..318

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

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

        matchesAgainstUserConditions(message: DiscordJS.Message) {
          if (!('user' in this.data)) {
            return true
          }
      
      
      Severity: Minor
      Found in src/condition.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 matchesAgainstMessage has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        matchesAgainstMessage(message: DiscordJS.Message) {
          // Check against user conditions first
          if ('user' in this.data) {
            if (!this.matchesAgainstUserConditions(message)) {
              console.log('user does not match')
      Severity: Minor
      Found in src/condition.js - About 1 hr to fix

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

          constructor(server: DiscordJS.Guild, values: ConditionValues) {
            this.data = values
            this.server = server
            this.modifiers = values.modifiers || []
            this.matchSuccess = true
        Severity: Minor
        Found in src/condition.js - About 1 hr to fix

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

            constructor(server: DiscordJS.Guild, values: ConditionValues) {
              this.data = values
              this.server = server
              this.modifiers = values.modifiers || []
              this.matchSuccess = true
          Severity: Minor
          Found in src/condition.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 matchesAgainstUserConditions has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            matchesAgainstUserConditions(message: DiscordJS.Message) {
              if (!('user' in this.data)) {
                return true
              }
          
          
          Severity: Minor
          Found in src/condition.js - About 1 hr to fix

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

              isValid() {
                try {
                  this.validateKeys()
            
                  // this.validateType(this.data, 'message', 'array') // could be string or array?
            Severity: Minor
            Found in src/condition.js - About 1 hr to fix

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

                  it('replaces parameter with multiple regex as plain text values', () => {
                    let formatted = cond.formatMatchPattern('{0}', ['te?st', 'another', '[a|b]'])
                    let expected = '(te\\?st|another|\\[a\\|b\\])'
                    expect(formatted).toBe(expected)
                  })
              Severity: Major
              Found in __tests__/condition-test.js and 1 other location - About 1 hr to fix
              __tests__/condition-test.js on lines 231..235

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

                  it('replaces parameter with multiple plain text values', () => {
                    let formatted = cond.formatMatchPattern('{0}', ['plain', 'text', 'values'])
                    let expected = '(plain|text|values)'
                    expect(formatted).toBe(expected)
                  })
              Severity: Major
              Found in __tests__/condition-test.js and 1 other location - About 1 hr to fix
              __tests__/condition-test.js on lines 243..247

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

                getFormattedMessage(condition: Condition, message: DiscordJS.Message) {
                  return condition.data.reply
                    .replace('{user}', message.author.username)
                }
              Severity: Minor
              Found in src/actions/reply.js and 1 other location - About 55 mins to fix
              src/actions/dm.js on lines 20..23

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

              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

                getFormattedMessage(condition: Condition, message: DiscordJS.Message) {
                  return condition.data.dm
                    .replace('{user}', message.author.username)
                }
              Severity: Minor
              Found in src/actions/dm.js and 1 other location - About 55 mins to fix
              src/actions/reply.js on lines 20..23

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

              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

                  it('replaces parameter with plain text', () => {
                    let formatted = cond.formatMatchPattern('{0}', 'plain text value')
                    let expected = '(plain text value)'
                    expect(formatted).toBe(expected)
                  })
              Severity: Minor
              Found in __tests__/condition-test.js and 1 other location - About 50 mins to fix
              __tests__/condition-test.js on lines 237..241

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

              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

                  it('replaces parameter with regex as plain text', () => {
                    let formatted = cond.formatMatchPattern('{0}', 'te?st')
                    let expected = '(te\\?st)'
                    expect(formatted).toBe(expected)
                  })
              Severity: Minor
              Found in __tests__/condition-test.js and 1 other location - About 50 mins to fix
              __tests__/condition-test.js on lines 225..229

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

              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