tulul/lycantulul_bot

View on GitHub

Showing 1,243 of 1,243 total issues

Method perform has a Cognitive Complexity of 611 (exceeds 5 allowed). Consider refactoring.
Open

    def perform(message, bot)
      @bot = bot
      log("incoming message from #{message.from.first_name}: #{message.text}")

      if MAINTENANCE.call
Severity: Minor
Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 1 wk 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

json Gem for Ruby Unsafe Object Creation Vulnerability (additional fix)
Open

    json (1.8.3)
Severity: Critical
Found in Gemfile.lock by bundler-audit

Advisory: CVE-2020-10663

Criticality: High

URL: https://www.ruby-lang.org/en/news/2020/03/19/json-dos-cve-2020-10663/

Solution: upgrade to >= 2.3.0

Potentially unintended unmarshalling of user-provided objects in MemCacheStore and RedisCacheStore
Open

    activesupport (4.2.5.1)
Severity: Minor
Found in Gemfile.lock by bundler-audit

Advisory: CVE-2020-8165

Criticality: Critical

URL: https://groups.google.com/forum/#!topic/rubyonrails-security/bv6fW4S0Y1c

Solution: upgrade to >= 5.2.4.3, ~> 5.2.4, >= 6.0.3.1

OS Command Injection in Rake
Open

    rake (11.1.2)
Severity: Critical
Found in Gemfile.lock by bundler-audit

Advisory: CVE-2020-8130

Criticality: High

URL: https://github.com/advisories/GHSA-jppv-gw3r-w3q8

Solution: upgrade to >= 12.3.3

ReDoS based DoS vulnerability in Active Support’s underscore
Open

    activesupport (4.2.5.1)
Severity: Minor
Found in Gemfile.lock by bundler-audit

Advisory: CVE-2023-22796

URL: https://github.com/rails/rails/releases/tag/v7.0.4.1

Solution: upgrade to >= 5.2.8.15, ~> 5.2.8, >= 6.1.7.1, ~> 6.1.7, >= 7.0.4.1

Class has too many lines. [1029/100]
Open

  class InputProcessorJob
    include SuckerPunch::Job

    attr_accessor :bot

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

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

    def perform(message, bot)
      @bot = bot
      log("incoming message from #{message.from.first_name}: #{message.text}")

      if MAINTENANCE.call

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

    def perform(message, bot)
      @bot = bot
      log("incoming message from #{message.from.first_name}: #{message.text}")

      if MAINTENANCE.call

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.

Class has too many lines. [787/100]
Open

  class Game
    include Mongoid::Document
    include Mongoid::Locker
    include Mongoid::Timestamps

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

Assignment Branch Condition size for message_action is too high. [223.1/15]
Open

    def message_action(game, action, aux = nil)
      case action
      when BROADCAST_ROLE
        log('game starts')
        opening = 'MULAI! MWA HA HA HA'

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 perform is too high. [200/7]
Open

    def perform(message, bot)
      @bot = bot
      log("incoming message from #{message.from.first_name}: #{message.text}")

      if MAINTENANCE.call

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

File input_processor_job.rb has 1033 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Lycantulul
  class InputProcessorJob
    include SuckerPunch::Job

    attr_accessor :bot
Severity: Major
Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 2 days to fix

    Assignment Branch Condition size for get_stats is too high. [170.7/15]
    Open

        def self.get_stats(stat)
          stats = ["Statistik #{stat}"]
          case stat
          when '/stats'
            stats << "Current stats:"

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

        def perform(message, bot)
          @bot = bot
          log("incoming message from #{message.from.first_name}: #{message.text}")
    
          if MAINTENANCE.call
    Severity: Major
    Found in lib/lycantulul_bot/lycantulul/input_processor_job.rb - About 2 days to fix

      Cyclomatic complexity for perform is too high. [153/6]
      Open

          def perform(message, bot)
            @bot = bot
            log("incoming message from #{message.from.first_name}: #{message.text}")
      
            if MAINTENANCE.call

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

          def message_action(game, action, aux = nil)
            case action
            when BROADCAST_ROLE
              log('game starts')
              opening = 'MULAI! MWA HA HA HA'

      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.

      File game.rb has 791 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Lycantulul
        class Game
          include Mongoid::Document
          include Mongoid::Locker
          include Mongoid::Timestamps
      Severity: Major
      Found in lib/lycantulul_bot/lycantulul/game.rb - About 1 day to fix

        Assignment Branch Condition size for kill_victim is too high. [121.3/15]
        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 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 a Cognitive Complexity of 70 (exceeds 5 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: Minor
        Found in lib/lycantulul_bot/lycantulul/game.rb - About 1 day 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

        Class Game has 63 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Game
            include Mongoid::Document
            include Mongoid::Locker
            include Mongoid::Timestamps
        
        
        Severity: Major
        Found in lib/lycantulul_bot/lycantulul/game.rb - About 1 day to fix
          Severity
          Category
          Status
          Source
          Language