tulir/gomuks

View on GitHub
matrix/matrix.go

Summary

Maintainability
F
3 days
Test Coverage

File matrix.go has 1107 lines of code (exceeds 500 allowed). Consider refactoring.
Open

// gomuks - A terminal Matrix client written in Go.
// Copyright (C) 2020 Tulir Asokan
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
Severity: Major
Found in matrix/matrix.go - About 2 days to fix

    Container has 54 methods (exceeds 50 allowed). Consider refactoring.
    Open

    type Container struct {
        client  *mautrix.Client
        crypto  ifc.Crypto
        syncer  *GomuksSyncer
        gmx     ifc.Gomuks
    Severity: Major
    Found in matrix/matrix.go - About 2 hrs to fix

      Method Container.OnLogin has 63 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (c *Container) OnLogin() {
          c.cryptoOnLogin()
          c.ui.OnLogin()
      
          c.client.Store = c.config
      Severity: Minor
      Found in matrix/matrix.go - About 1 hr to fix

        Method Container.HandleMessage has 54 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (c *Container) HandleMessage(source mautrix.EventSource, mxEvent *event.Event) {
            room := c.GetOrCreateRoom(mxEvent.RoomID)
            if source&mautrix.EventSourceLeave != 0 {
                room.HasLeft = true
                return
        Severity: Minor
        Found in matrix/matrix.go - About 1 hr to fix

          Method Container.GetHistory has 52 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (c *Container) GetHistory(room *rooms.Room, limit int, dbPointer uint64) ([]*muksevt.Event, uint64, error) {
              events, newDBPointer, err := c.history.Load(room, limit, dbPointer)
              if err != nil {
                  return nil, dbPointer, err
              }
          Severity: Minor
          Found in matrix/matrix.go - About 1 hr to fix

            Method Container.HandleMessage has 7 return statements (exceeds 4 allowed).
            Open

            func (c *Container) HandleMessage(source mautrix.EventSource, mxEvent *event.Event) {
                room := c.GetOrCreateRoom(mxEvent.RoomID)
                if source&mautrix.EventSourceLeave != 0 {
                    room.HasLeft = true
                    return
            Severity: Major
            Found in matrix/matrix.go - About 45 mins to fix

              Method Container.HandleEdit has 6 return statements (exceeds 4 allowed).
              Open

              func (c *Container) HandleEdit(room *rooms.Room, editsID id.EventID, editEvent *muksevt.Event) {
                  var origEvt *muksevt.Event
                  err := c.history.Update(room, editsID, func(evt *muksevt.Event) error {
                      if editEvent.Sender != evt.Sender {
                          return ErrCantEditOthersMessage
              Severity: Major
              Found in matrix/matrix.go - About 40 mins to fix

                Method Container.GetHistory has 6 return statements (exceeds 4 allowed).
                Open

                func (c *Container) GetHistory(room *rooms.Room, limit int, dbPointer uint64) ([]*muksevt.Event, uint64, error) {
                    events, newDBPointer, err := c.history.Load(room, limit, dbPointer)
                    if err != nil {
                        return nil, dbPointer, err
                    }
                Severity: Major
                Found in matrix/matrix.go - About 40 mins to fix

                  Method Container.DownloadToDisk has 6 return statements (exceeds 4 allowed).
                  Open

                  func (c *Container) DownloadToDisk(uri id.ContentURI, file *attachment.EncryptedFile, target string) (fullPath string, err error) {
                      cachePath := c.GetCachePath(uri)
                      if target == "" {
                          fullPath = cachePath
                      } else if !path.IsAbs(target) {
                  Severity: Major
                  Found in matrix/matrix.go - About 40 mins to fix

                    Method Container.UploadMedia has 6 return statements (exceeds 4 allowed).
                    Open

                    func (c *Container) UploadMedia(path string, encrypt bool) (*ifc.UploadedMediaInfo, error) {
                        var err error
                        path, err = filepath.Abs(path)
                        if err != nil {
                            return nil, fmt.Errorf("failed to get absolute path: %w", err)
                    Severity: Major
                    Found in matrix/matrix.go - About 40 mins to fix

                      Method Container.SendEvent has 5 return statements (exceeds 4 allowed).
                      Open

                      func (c *Container) SendEvent(evt *muksevt.Event) (id.EventID, error) {
                          defer debug.Recover()
                      
                          _, _ = c.client.UserTyping(evt.RoomID, false, 0)
                          c.typing = 0
                      Severity: Major
                      Found in matrix/matrix.go - About 35 mins to fix

                        Method Container.InitClient has 5 return statements (exceeds 4 allowed).
                        Open

                        func (c *Container) InitClient() error {
                            if len(c.config.HS) == 0 {
                                return fmt.Errorf("no homeserver entered")
                            }
                        
                        
                        Severity: Major
                        Found in matrix/matrix.go - About 35 mins to fix

                          Method Container.SingleSignOn has 5 return statements (exceeds 4 allowed).
                          Open

                          func (c *Container) SingleSignOn() error {
                              loginURL := c.client.BuildURLWithQuery(mautrix.ClientURLPath{"v3", "login", "sso", "redirect"}, map[string]string{
                                  "redirectUrl": "http://localhost:29325",
                              })
                              err := open.Open(loginURL)
                          Severity: Major
                          Found in matrix/matrix.go - About 35 mins to fix

                            There are no issues that match your filters.

                            Category
                            Status