Shimogawa/rubirai

View on GitHub

Showing 9 of 9 total issues

Method start_listen has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def start_listen(interval, is_blocking: false, ignore_error: false)
      raise RubiraiError, 'listener is already running' if @listener&.running?
      @listener_stop_event = Concurrent::Event.new if is_blocking
      bot = self
      @listener = Concurrent::TimerTask.new(execution_interval: interval) do
Severity: Minor
Found in lib/rubirai/listener.rb - About 4 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

Method _interpolate_with_objects has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def _interpolate_with_objects(str)
      sb = +''
      result = MessageChain.new(bot)
      i = 0
      while i < str.length
Severity: Minor
Found in lib/rubirai/messages/interpolation.rb - About 2 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

Method set_message has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.set_message(type, *attr_keys, &initialize_block)
      attr_reader(*attr_keys)

      metaclass.instance_eval do
        define_method(:keys) do
Severity: Minor
Found in lib/rubirai/messages/message.rb - About 1 hr to fix

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

        def _interpolate_with_objects(str)
          sb = +''
          result = MessageChain.new(bot)
          i = 0
          while i < str.length
    Severity: Minor
    Found in lib/rubirai/messages/interpolation.rb - About 1 hr to fix

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

          def respond_to_new_friend_request(event_id, from_id, operation, group_id = 0, message = '')
      Severity: Minor
      Found in lib/rubirai/event_resp.rb - About 35 mins to fix

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

            def respond_to_group_invite(event_id, from_id, group_id, operation, message = '')
        Severity: Minor
        Found in lib/rubirai/event_resp.rb - About 35 mins to fix

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

              def respond_to_member_join(event_id, from_id, group_id, operation, message = '')
          Severity: Minor
          Found in lib/rubirai/event_resp.rb - About 35 mins to fix

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

                def call(method, path, **kwargs)
                  return unless %i[get post].include?(method) && HTTP.respond_to?(method)
            
                  resp = HTTP.send method, gen_uri(path), kwargs
                  raise(HttpResponseError, resp.code) unless resp.status.success?
            Severity: Minor
            Found in lib/rubirai.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def initialize(bot = nil, source = nil)
                  @bot = bot
                  @messages = []
                  @has_interpolation = false
                  @interpolated_str = nil
            Severity: Minor
            Found in lib/rubirai/messages/message_chain.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

            Severity
            Category
            Status
            Source
            Language