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
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)
- Read upRead up
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 =
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,
- Read upRead up
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]
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 =
- Read upRead up
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 = +""
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]
- Read upRead up
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])
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])
- Read upRead up
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,
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)
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])
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)
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|
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]
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 = +""
- Read upRead up
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,
- Read upRead up
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
- Read upRead up
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,
- Read upRead up
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"