discorb-lib/discorb

View on GitHub

Showing 38 of 48 total issues

File gateway_events.rb has 343 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Discorb
  module Gateway
    #
    # Represents an event.
    # @abstract
Severity: Minor
Found in lib/discorb/gateway_events.rb - About 4 hrs to fix

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

        def initialize(name, tone: 0)
          if EmojiTable::DISCORD_TO_UNICODE.key?(name)
            @name = name
            @value = EmojiTable::DISCORD_TO_UNICODE[name]
          elsif EmojiTable::UNICODE_TO_DISCORD.key?(name)
    Severity: Minor
    Found in lib/discorb/emoji.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 setup_commands has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def setup_commands(token = nil, guild_ids: nil)
            Async do
              @token ||= token
              @http = HTTP.new(self)
              global_commands =
    Severity: Major
    Found in lib/discorb/app_command/handler.rb - About 2 hrs to fix

      Method edit has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def edit(
            name: Discorb::Unset,
            event_type: Discorb::Unset,
            actions: Discorb::Unset,
            enabled: Discorb::Unset,
      Severity: Minor
      Found in lib/discorb/automod.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 modify_option_map has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def modify_option_map(option_map, options, guild, members, attachments)
                options ||= []
                options.each do |option|
                  val =
                    case option[:type]
      Severity: Minor
      Found in lib/discorb/interaction/command.rb - About 1 hr to fix

        Method setup_commands has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

              def setup_commands(token = nil, guild_ids: nil)
                Async do
                  @token ||= token
                  @http = HTTP.new(self)
                  global_commands =
        Severity: Minor
        Found in lib/discorb/app_command/handler.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 build_version_sidebar has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def build_version_sidebar(dir, version)
          raw = File.read("template-replace/resources/version_list.html")
          template = raw.match(/<!--template-->(.*)<!--endtemplate-->/m)[1]
          raw.gsub!(template, "")
          res = +""
        Severity: Minor
        Found in template-replace/scripts/version.rb - About 1 hr to fix

          Method modify_option_map has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                  def modify_option_map(option_map, options, guild, members, attachments)
                    options ||= []
                    options.each do |option|
                      val =
                        case option[:type]
          Severity: Minor
          Found in lib/discorb/interaction/command.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 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def initialize(client, data)
                  @client = client
                  @data = data
                  if data.key?(:user_id)
                    @user_id = Snowflake.new(data[:user_id])
          Severity: Minor
          Found in lib/discorb/gateway_events.rb - About 1 hr to fix

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

                  def initialize(client, data)
                    @client = client
                    @data = data
                    if data.key?(:user_id)
                      @user_id = Snowflake.new(data[:user_id])
            Severity: Minor
            Found in lib/discorb/gateway_events.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 post has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def post(
                  content = nil,
                  tts: false,
                  embed: nil,
                  embeds: nil,
            Severity: Minor
            Found in lib/discorb/interaction/root.rb - About 1 hr to fix

              Method _set_data has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def _set_data(data)
                    super
                    Sync do
                      name, options =
                        Discorb::CommandInteraction::ChatInputCommand.get_command_data(data)
              Severity: Minor
              Found in lib/discorb/interaction/autocomplete.rb - About 1 hr to fix

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

                    def initialize_hash(data)
                      @title = data[:title]
                      @description = data[:description]
                      @url = data[:url]
                      @timestamp = data[:timestamp] && Time.iso8601(data[:timestamp])
                Severity: Minor
                Found in lib/discorb/embed.rb - About 1 hr to fix

                  Method initialize has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def initialize(name, tone: 0)
                        if EmojiTable::DISCORD_TO_UNICODE.key?(name)
                          @name = name
                          @value = EmojiTable::DISCORD_TO_UNICODE[name]
                        elsif EmojiTable::UNICODE_TO_DISCORD.key?(name)
                  Severity: Minor
                  Found in lib/discorb/emoji.rb - About 1 hr to fix

                    Method yard_replace has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    def yard_replace(dir, version)
                      sha = `git rev-parse HEAD`.strip
                      tag = `git describe --exact-match #{sha}`
                      tag = tag.empty? ? "(main)" : tag.strip
                      Dir.glob("#{dir}/**/*.html") do |file|
                    Severity: Minor
                    Found in template-replace/scripts/yard_replace.rb - About 1 hr to fix

                      Method _set_data has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def _set_data(data)
                            @data = data
                            @guild_id = data[:guild_id]
                            @channel_id = data[:channel_id]
                            @user_id = data[:user_id]
                      Severity: Minor
                      Found in lib/discorb/voice_state.rb - About 1 hr to fix

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

                        def build_version_sidebar(dir, version)
                          raw = File.read("template-replace/resources/version_list.html")
                          template = raw.match(/<!--template-->(.*)<!--endtemplate-->/m)[1]
                          raw.gsub!(template, "")
                          res = +""
                        Severity: Minor
                        Found in template-replace/scripts/version.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 edit_original_message has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def edit_original_message(
                              content = nil,
                              embed: nil,
                              embeds: nil,
                              attachment: nil,
                        Severity: Minor
                        Found in lib/discorb/interaction/root.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 to_hash has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def to_hash
                              # @type var ret: Hash[untyped, untyped]
                              ret = { type: "rich" }
                              ret[:title] = @title if @title
                              ret[:description] = @description if @description
                        Severity: Minor
                        Found in lib/discorb/embed.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 edit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def edit(
                              name: Discorb::Unset,
                              position: Discorb::Unset,
                              bitrate: Discorb::Unset,
                              user_limit: Discorb::Unset,
                        Severity: Minor
                        Found in lib/discorb/channel/voice.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

                        Severity
                        Category
                        Status
                        Source
                        Language