ProjectCacophony/Processor

View on GitHub

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!")
    }

Severity: Minor
Found in plugins/eventlog/revert.go - About 3 days 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 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
    }
Severity: Minor
Found in plugins/serverlist/edit.go - About 2 days 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 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!")
    }

Severity: Major
Found in plugins/eventlog/revert.go - About 2 days to fix

    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
        }
    
    
    Severity: Minor
    Found in plugins/roles/process.go - About 1 day 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 Plugin.handleModEvent has 234 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (p *Plugin) handleModEvent(event *events.Event) {
        if !isEnabled(event) {
            return
        }
    
    
    Severity: Major
    Found in plugins/eventlog/handleModEvents.go - About 1 day to fix

      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
          }
      Severity: Major
      Found in plugins/serverlist/edit.go - About 7 hrs to fix

        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
            }
        Severity: Major
        Found in plugins/automod/cmdAdd.go - About 5 hrs to fix

          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
              }
          Severity: Minor
          Found in plugins/automod/cmdAdd.go - About 5 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 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
              }
          Severity: Minor
          Found in plugins/serverlist/add.go - About 5 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 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!")
              }
          
          
          Severity: Major
          Found in plugins/eventlog/revert.go - About 5 hrs to fix

            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",
            Severity: Minor
            Found in plugins/eventlog/options.go - 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 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{
            Severity: Major
            Found in plugins/stats/handle.go - About 4 hrs to fix

              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) {
              Severity: Minor
              Found in plugins/roles/process.go - 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 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 {
              Severity: Major
              Found in plugins/weather/weather.go - About 4 hrs to fix

                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{{
                Severity: Major
                Found in plugins/serverlist/handle.go - About 4 hrs to fix

                  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:
                  Severity: Major
                  Found in plugins/eventlog/types.go - About 4 hrs to fix

                    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
                        }
                    Severity: Major
                    Found in plugins/roles/roles.go - About 4 hrs to fix

                      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
                          }
                      Severity: Major
                      Found in plugins/tools/downloadEmoji.go - About 4 hrs to fix

                        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
                            }
                        
                        
                        Severity: Minor
                        Found in plugins/eventlog/handleModEvents.go - 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 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
                            }
                        Severity: Minor
                        Found in plugins/roles/roles.go - 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

                        Severity
                        Category
                        Status
                        Source
                        Language