discorb-lib/discorb

View on GitHub

Showing 38 of 47 total issues

Method initialize has 27 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 edit_original_message has 26 lines of code (exceeds 25 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

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

            def initialize(client, data, before, after)
              @client = client
              @data = data
              @before = before
              @after = after
      Severity: Minor
      Found in lib/discorb/gateway_events.rb - About 1 hr to fix

        Method yard_replace has a Cognitive Complexity of 9 (exceeds 5 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 55 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 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(
              title = nil,
              description = nil,
              color: nil,
              url: nil,
        Severity: Minor
        Found in lib/discorb/embed.rb - About 55 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 post has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def post(
              content = nil,
              tts: false,
              embed: nil,
              embeds: nil,
        Severity: Minor
        Found in lib/discorb/interaction/root.rb - About 55 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 edit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def edit(
                name: Discorb::Unset,
                description: Discorb::Unset,
                tag: Discorb::Unset,
                reason: Discorb::Unset
        Severity: Minor
        Found in lib/discorb/sticker.rb - About 55 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 to_hash has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def to_hash(other = nil)
              payload = { parse: %w[everyone roles users] }
              replied_user = nil_merge(@replied_user, other&.replied_user)
              everyone = nil_merge(@everyone, other&.everyone)
              roles = nil_merge(@roles, other&.roles)
        Severity: Minor
        Found in lib/discorb/allowed_mentions.rb - About 55 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 wait has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def wait(path)
              # return if path.url.start_with?("https://")
              if @global && @global > Time.now.to_f
                time = @global - Time.now.to_f
                @client.logger.info(
        Severity: Minor
        Found in lib/discorb/rate_limit.rb - About 45 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 modify_option_map has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                def modify_option_map(option_map, options, guild, members, attachments)
        Severity: Minor
        Found in lib/discorb/interaction/command.rb - About 35 mins to fix

          Method _set_data has a Cognitive Complexity of 7 (exceeds 5 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 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(client, data, before, after)
                  @client = client
                  @data = data
                  @before = before
                  @after = after
          Severity: Minor
          Found in lib/discorb/gateway_events.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 edit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def edit(name: Discorb::Unset, avatar: Discorb::Unset)
                Async do
                  payload = {}
                  payload[:username] = name unless name == Discorb::Unset
                  if avatar == Discorb::Unset
          Severity: Minor
          Found in lib/discorb/user.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 _set_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def _set_data(data, gateway)
                @code = data[:code]
                if gateway
                  @channel_data = { id: data[:channel_id] }
                  @guild_data = { id: data[:guild_id] }
          Severity: Minor
          Found in lib/discorb/invite.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 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def initialize(data)
                  @name = data[:name]
                  @type = ACTIVITY_TYPES[data[:type]]
                  @url = data[:url]
                  @created_at = Time.at(data[:created_at])
          Severity: Minor
          Found in lib/discorb/presence.rb - About 25 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 _set_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def _set_data(data)
                @username = data[:username]
                @global_name = data[:global_name]
                @verified = data[:verified]
                @id = Snowflake.new(data[:id])
          Severity: Minor
          Found in lib/discorb/user.rb - About 25 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 modify_localization_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def modify_localization_hash(hash)
                hash.to_h do |rkey, value|
                  key = rkey.to_s.gsub("_", "-")
                  if VALID_LOCALES.none? { |valid| valid.downcase == key.downcase } &&
                       key != "default"
          Severity: Minor
          Found in lib/discorb/app_command/common.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def initialize(client, data)
                @client = client
                @id = Snowflake.new(data[:id])
                @application_id = Snowflake.new(data[:application_id])
                @type = self.class.interaction_name
          Severity: Minor
          Found in lib/discorb/interaction/root.rb - About 25 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