Showing 285 of 1,104 total issues
Method Item.Revert
has a Cognitive Complexity of 196 (exceeds 20 allowed). Consider refactoring. Open
func (i *Item) Revert(event *events.Event) error {
if i.Reverted {
return events.NewUserError("item has already been reverted!")
}
- 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 Plugin.handleEdit
has a Cognitive Complexity of 125 (exceeds 20 allowed). Consider refactoring. Open
func (p *Plugin) handleEdit(event *events.Event) {
if len(event.Fields()) < 3 {
event.Respond("serverlist.edit.too-few-args-lt3")
return
}
- 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 Item.Revert
has 456 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (i *Item) Revert(event *events.Event) error {
if i.Reverted {
return events.NewUserError("item has already been reverted!")
}
Method Plugin.handleUserRoleRequest
has a Cognitive Complexity of 88 (exceeds 20 allowed). Consider refactoring. Open
func (p *Plugin) handleUserRoleRequest(event *events.Event) bool {
if event.MessageCreate == nil || event.MessageCreate.Author == nil || event.MessageCreate.Author.Bot || !p.isInRoleChannel(event) {
return false
}
- 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 Plugin.handleModEvent
has 234 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (p *Plugin) handleModEvent(event *events.Event) {
if !isEnabled(event) {
return
}
Method Plugin.handleEdit
has 217 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (p *Plugin) handleEdit(event *events.Event) {
if len(event.Fields()) < 3 {
event.Respond("serverlist.edit.too-few-args-lt3")
return
}
Method Plugin.cmdAdd
has 170 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (p *Plugin) cmdAdd(event *events.Event) {
if len(event.Fields()) < 3 {
event.Respond("automod.add.too-few")
return
}
Method Plugin.cmdAdd
has a Cognitive Complexity of 52 (exceeds 20 allowed). Consider refactoring. Open
func (p *Plugin) cmdAdd(event *events.Event) {
if len(event.Fields()) < 3 {
event.Respond("automod.add.too-few")
return
}
- 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 Plugin.handleAdd
has a Cognitive Complexity of 50 (exceeds 20 allowed). Consider refactoring. Open
func (p *Plugin) handleAdd(event *events.Event) {
if len(event.Fields()) < 5 {
event.Respond("serverlist.add.too-few")
return
}
- 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 Item.Revert
has 58 return statements (exceeds 4 allowed). Open
func (i *Item) Revert(event *events.Event) error {
if i.Reverted {
return events.NewUserError("item has already been reverted!")
}
Function optionsForChannel
has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring. Open
func optionsForChannel(old, new *discordgo.Channel) []ItemOption {
var options []ItemOption
option := ItemOption{
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 Plugin.Help
has 141 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (p *Plugin) Help() *common.PluginHelp {
return &common.PluginHelp{
Names: p.Names(),
Description: "stats.help.description",
Commands: []common.Command{
Method Plugin.handleUserRoleReactionRequest
has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring. Open
func (p *Plugin) handleUserRoleReactionRequest(event *events.Event) bool {
if event.BotUserID == event.MessageReactionAdd.UserID ||
event.MessageReactionAdd == nil ||
event.MessageReactionAdd.Emoji.Name == "" ||
!p.isInRoleChannel(event) {
- 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 Plugin.viewWeather
has 135 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (p *Plugin) viewWeather(event *events.Event) {
var weather *Weather
// check if they passed a location, otherwise check if they have one saved
if len(event.Fields()) > 1 {
Method Plugin.Help
has 134 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (p *Plugin) Help() *common.PluginHelp {
return &common.PluginHelp{
Names: p.Names(),
Description: "serverlist.help.description",
Commands: []common.Command{{
Method entityType.String
has 132 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (t entityType) String(state *state.State, guildID, value string) string {
switch t {
case EntityTypeUser:
return "<@" + value + "> #" + value
case EntityTypeRole:
Method Plugin.createRole
has 132 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (p *Plugin) createRole(event *events.Event) {
if len(event.Fields()) < 4 {
event.Respond("common.invalid-params")
return
}
Method Plugin.handleDownloadEmoji
has 132 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (p *Plugin) handleDownloadEmoji(event *events.Event) {
if !permissions.DiscordAttachFiles.Match(event.State(), event.DB(), event.BotUserID, event.ChannelID, false, false) {
event.Respond("tools.download-emoji.no-attach-files-permission")
return
}
Method Plugin.handleModEvent
has a Cognitive Complexity of 44 (exceeds 20 allowed). Consider refactoring. Open
func (p *Plugin) handleModEvent(event *events.Event) {
if !isEnabled(event) {
return
}
- 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 Plugin.createRole
has a Cognitive Complexity of 44 (exceeds 20 allowed). Consider refactoring. Open
func (p *Plugin) createRole(event *events.Event) {
if len(event.Fields()) < 4 {
event.Respond("common.invalid-params")
return
}
- 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"