Nephos/botpop

View on GitHub

Showing 15 of 15 total issues

Method initialize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize argv
    @argv = argv
    i = 0
    debugvars = []
    argv = @argv.dup
Severity: Minor
Found in arguments.rb - 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

Method forget has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def forget m, arguments, nb, what
    return if not cmd_allowed? m
    if arguments.nil?
      last = Entry.where(channel: m.channel.to_s, user: "self").last
      m.reply last ? "\"#{last.message}\" Forgotten" : "Nop"
Severity: Minor
Found in plugins/iamalive.rb - 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

Method exec_new has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def exec_new m, _, s
    s.downcase!
    f = I18n.transliterate(s)[0]
    x = "Après je vous propose "
    x += (%w(a e i o u y).include?(f) ? "d'" : "de ") if not s.match(/^(d'|de ).+/)
Severity: Minor
Found in plugins/anecdote.rb - About 1 hr to fix

Method initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize arg
    if arg.is_a? String
      v = arg.match(/^(?<nb>\d+)d(?<faces>\d+)$/i)
      if v
        set_rolldice v
Severity: Minor
Found in plugins/dice/Dice.rb - 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

Method initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def initialize(str, dex, con, int, wiz, cha, opt={})
Severity: Major
Found in plugins/dice/Character.rb - About 50 mins to fix

Method let has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def let m, _, _, to, msg
Severity: Minor
Found in plugins/puppet.rb - About 35 mins to fix

Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def initialize from, degats, opt, bonus, attack_opt={}
Severity: Minor
Found in plugins/dice/Weapon.rb - About 35 mins to fix

Method channels has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def channels
    i = @argv.index('--channels') || @argv.index('-c')
    return ['#equilibre'] if i.nil?
    chans = @argv[(i+1)..-1]
    i = chans.index{|c| c[0] == '-'}
Severity: Minor
Found in arguments.rb - 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

Method get_one_argument has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def get_one_argument(name, default_value)
    if name.is_a? String
      i = @argv.index(name)
    elsif name.is_a? Array
      i = nil
Severity: Minor
Found in arguments.rb - 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

Method exec_new has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def exec_new m, _, s
    s.downcase!
    f = I18n.transliterate(s)[0]
    x = "Après je vous propose "
    x += (%w(a e i o u y).include?(f) ? "d'" : "de ") if not s.match(/^(d'|de ).+/)
Severity: Minor
Found in plugins/anecdote.rb - 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

Method exec_fok has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def exec_fok m
    dos_execution m, lambda {|m|
      nick = Botpop::Builtins.get_ip_from_nick(m)[:nick]
      ip = Botpop::Builtins.get_ip_from_nick(m)[:ip]
      return m.reply "User '#{nick}' doesn't exists" if ip.nil?
Severity: Minor
Found in plugins/network.rb - 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

Method load_plugins has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.load_plugins
    Module.constants.select{ |m|
          (m = Module.const_get(m) rescue false) and
            (m.is_a?(Class)) and
            (m.ancestors.include?(Plugin)) and
Severity: Minor
Found in botpop.rb - 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

Method port has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def port
    if ssl and not @argv.index('--port') and not @argv.index('-p')
      return 7000
    else
      i = @argv.index('--port') || @argv.index('-p')
Severity: Minor
Found in arguments.rb - 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

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

  def user_group_rm m, name, group
    cmd_allowed? m
    find_and_exec(m, name) do |u|
      u.update(groups: (u.groups - [group]))
      m.reply "group #{group} removed from #{u.name}"
Severity: Minor
Found in plugins/base/user.rb and 1 other location - About 20 mins to fix
plugins/base/user.rb on lines 54..58

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

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

  def user_group_add m, name, group
    cmd_allowed? m
    find_and_exec(m, name) do |u|
      u.update(groups: (u.groups + [group]))
      m.reply "group #{group} added to #{u.name}"
Severity: Minor
Found in plugins/base/user.rb and 1 other location - About 20 mins to fix
plugins/base/user.rb on lines 62..66

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

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