tulul/lycantulul_bot

View on GitHub

Showing 1,243 of 1,243 total issues

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

    def check_custom_role(role_string)
      self.with_lock(wait: true) do
        custom = nil
        return nil unless role_string
        role_string = role_string.gsub(/[^A-Za-z]/, '').downcase

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 valid_action? is too high. [23.85/15]
Open

    def valid_action?(actor_id, actee_name, role)
      self.with_lock(wait: true) do
        return false if role == 'super_necromancer' && self.super_necromancer_done[actor_id.to_s]

        actor = self.send("living_#{role.pluralize}").with_id(actor_id)

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

    def kill_victim
      self.with_lock(wait: true) do
        vc = self.sort(victim)
        hhost = self.homeless_host
        LycantululBot.log(vc.to_s)
Severity: Major
Found in lib/lycantulul_bot/lycantulul/game.rb - About 2 hrs to fix

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

        def add_votee(voter_id, votee)
          self.with_lock(wait: true) do
            return RESPONSE_DOUBLE if self.votee.any?{ |vo| vo[:voter_id] == voter_id }
            return RESPONSE_INVALID unless valid_action?(voter_id, votee, 'player')
    
    

    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. [17/10]
    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 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 send_faux_seer is too high. [21.59/15]
    Open

        def send_faux_seer(game, seer)
          log("sending seer instruction to #{seer.full_name}")
          chosen = seer
          while chosen.user_id == seer.user_id
            chosen = game.living_players.sample

    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 send is too high. [13/7]
    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 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

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

        def add_victim(killer_id, victim)
          self.with_lock(wait: true) do
            return RESPONSE_DOUBLE if self.victim.any?{ |vi| vi[:killer_id] == killer_id }
            return RESPONSE_INVALID unless valid_action?(killer_id, victim, 'werewolf') || valid_action?(killer_id, victim, 'super_werewolf')
    
    

    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 roles_statistics is too high. [21.28/15]
    Open

        def roles_statistics
          sum = self.game
          tot = {}
          Lycantulul::Game::ROLES.each do |role|
            tot[role] ||= 0

    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

    Cyclomatic complexity for send is too high. [11/6]
    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 that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

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

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

    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. [15/10]
    Open

        def list_voting
          res = ''
          self.sort(votee).each do |votee|
            res += "#{votee[0]} - <b>#{votee[1]} suara</b>\n"
          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 add_votee is too high. [20.05/15]
    Open

        def add_votee(voter_id, votee)
          self.with_lock(wait: true) do
            return RESPONSE_DOUBLE if self.votee.any?{ |vo| vo[:voter_id] == voter_id }
            return RESPONSE_INVALID unless valid_action?(voter_id, votee, 'player')
    
    

    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

    Cyclomatic complexity for check_voting_finished is too high. [10/6]
    Open

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

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

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

        def send_welcome_message(game)
          game.reload
          welcomed = game.clear_unwelcomed
          if !welcomed.empty? && game.waiting?
            additional_text =

    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.

    Perceived complexity for check_voting_finished is too high. [11/7]
    Open

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

    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_setting_keyboard is too high. [19.92/15]
    Open

        def role_setting_keyboard
          keyboard = []
          max = IMPORTANT_ROLES.count
          sorted_roles = IMPORTANT_ROLES.sort_by{ |role| self.get_role(self.class.const_get(role.upcase)) }
          count = -1

    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. [14/10]
    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 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. [14/10]
    Open

        def valid_action?(actor_id, actee_name, role)
          self.with_lock(wait: true) do
            return false if role == 'super_necromancer' && self.super_necromancer_done[actor_id.to_s]
    
            actor = self.send("living_#{role.pluralize}").with_id(actor_id)

    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.

    Cyclomatic complexity for valid_action? is too high. [10/6]
    Open

        def valid_action?(actor_id, actee_name, role)
          self.with_lock(wait: true) do
            return false if role == 'super_necromancer' && self.super_necromancer_done[actor_id.to_s]
    
            actor = self.send("living_#{role.pluralize}").with_id(actor_id)

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Severity
    Category
    Status
    Source
    Language