tulul/lycantulul_bot

View on GitHub

Showing 1,243 of 1,243 total issues

Method has too many lines. [32/10]
Open

    def get_role(role)
      case role
      when VILLAGER
        'Warga Kampung'
      when GREEDY_VILLAGER

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for protect_players is too high. [37.87/15]
Open

    def protect_players
      self.with_lock(wait: true) do
        ss = self.protectee
        LycantululBot.log(ss.to_s)
        self.update_attribute(:protectee, [])

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [32/10]
Open

    def get_task(role)
      case role
      when VILLAGER
        "Diam menunggu kematian. Seriously. Tapi bisa bantu-bantu yang lain lah sumbang suara buat bunuh para serigala, sekalian berdoa biar dilindungi sama #{self.get_role(PROTECTOR)} kalo ada"
      when GREEDY_VILLAGER

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [31/10]
Open

    def send(message, text, reply: nil, html: nil, keyboard: nil, async: true)
      options = {
        chat_id: message.chat.id,
        text: text[0...4000],
      }

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [29/10]
Open

    def summon(game, who)
      if (Time.now - game.last_summon_query rescue 11).ceil > 10
        to_call =
          case who
          when :all

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [29/10]
Open

    def finish(stats: true)
      self.with_lock(wait: true) do
        self.update_attribute(:finished, true)
        if stats
          self.players.each do |pl|

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for start is too high. [33.27/15]
Open

  def self.start
    Telegram::Bot::Client.run($token) do |bot|
      bot.listen do |message|
        Lycantulul::InputProcessorJob.perform_async(message, bot)
      end

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [28/10]
Open

    def list_players
      liv_count = self.living_players.count
      ded_count = self.dead_players.count

      res = "Masi idup: <b>#{liv_count} makhluk</b>\n"

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for finish is too high. [32.2/15]
Open

    def finish(stats: true)
      self.with_lock(wait: true) do
        self.update_attribute(:finished, true)
        if stats
          self.players.each do |pl|

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for check_round_finished is too high. [31.56/15]
Open

    def check_round_finished(game, round, force = false)
      log("checking round finished #{round}")
      game.reload
      return unless round == game.round && game.night? && !game.waiting? && !game.discussion? && !game.finished?
      log('continuing')

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for perform is too high. [31.97/15]
Open

    def perform(bot, options)
      retry_count = 0
      begin
        bot.api.send_message(options)
      rescue Faraday::TimeoutError => e

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for perform is too high. [31.97/15]
Open

    def perform(bot, options)
      retry_count = 0
      begin
        bot.api.send_message(options)
      rescue Faraday::TimeoutError => e

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [25/10]
Open

    def raise_the_dead
      self.with_lock(wait: true) do
        ss = self.necromancee
        LycantululBot.log(ss.to_s)
        self.update_attribute(:necromancee, [])

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Block has too many lines. [61/25]
Open

      self.with_lock(wait: true) do
        vc = self.sort(victim)
        hhost = self.homeless_host
        LycantululBot.log(vc.to_s)
        self.update_attribute(:victim, [])

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Method has too many lines. [24/10]
Open

    def statistics
      res = "Statistik <b>#{self.full_name}</b>\n"
      res += "\n"
      res += "Main <b>#{self.game}</b>\n"
      res += "Bertahan hidup <b>#{self.percentage(self.survived)}</b>\n"

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [23/10]
Open

  def self.start
    Telegram::Bot::Client.run($token) do |bot|
      bot.listen do |message|
        Lycantulul::InputProcessorJob.perform_async(message, bot)
      end

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for enlighten_seer is too high. [28.88/15]
Open

    def enlighten_seer
      self.with_lock(wait: true) do
        ss = self.seen
        LycantululBot.log(ss.to_s)
        self.update_attribute(:seen, [])

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Perceived complexity for kill_victim is too high. [20/7]
Open

    def kill_victim
      self.with_lock(wait: true) do
        vc = self.sort(victim)
        hhost = self.homeless_host
        LycantululBot.log(vc.to_s)

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Assignment Branch Condition size for role_valid? is too high. [27.82/15]
Open

    def role_valid?
      ww_count_valid =
        if self.custom_roles && ((ww = self.custom_roles[WEREWOLF]) || (sww = self.custom_roles[SUPER_WEREWOLF]))
          val = true
          wwc = ww > 0 rescue true

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

  class MessageQueueJob
    include SuckerPunch::Job

    def perform(bot, options)
      retry_count = 0
Severity: Major
Found in lib/lycantulul_bot/lycantulul/message_queue_job.rb and 1 other location - About 2 hrs to fix
lib/lycantulul_bot/lycantulul/message_sending_job.rb on lines 2..26

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

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