ProjectCacophony/Gateway

View on GitHub

Showing 4 of 23 total issues

Method EventHandler.OnDiscordEvent has 181 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (eh *EventHandler) OnDiscordEvent(session *discordgo.Session, eventItem interface{}) {
    var err error

    if session == nil || session.State == nil || session.State.User == nil {
        return
Severity: Major
Found in pkg/handler/handler.go - About 6 hrs to fix

    Method EventHandler.OnDiscordEvent has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
    Open

    func (eh *EventHandler) OnDiscordEvent(session *discordgo.Session, eventItem interface{}) {
        var err error
    
        if session == nil || session.State == nil || session.State.User == nil {
            return
    Severity: Minor
    Found in pkg/handler/handler.go - About 3 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 EventHandler.OnDiscordEvent has 9 return statements (exceeds 4 allowed).
    Open

    func (eh *EventHandler) OnDiscordEvent(session *discordgo.Session, eventItem interface{}) {
        var err error
    
        if session == nil || session.State == nil || session.State.User == nil {
            return
    Severity: Major
    Found in pkg/handler/handler.go - About 55 mins to fix

      Function NewEventHandler has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          logger *zap.Logger,
          redisClient *redis.Client,
          publisher *events.Publisher,
          checker *whitelist.Checker,
          state *state.State,
      Severity: Major
      Found in pkg/handler/handler.go - About 50 mins to fix
        Severity
        Category
        Status
        Source
        Language