tulir/gomuks

View on GitHub

Showing 60 of 94 total issues

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

    File room-view.go has 807 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 ui/room-view.go - About 1 day to fix

      File commands.go has 786 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 ui/commands.go - About 1 day to fix

        File crypto-commands.go has 624 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: Minor
        Found in ui/crypto-commands.go - About 5 hrs to fix

          Method HistoryManager.store has a Cognitive Complexity of 43 (exceeds 20 allowed). Consider refactoring.
          Open

          func (hm *HistoryManager) store(room *rooms.Room, events []*event.Event, append bool) (newEvents []*muksevt.Event, newPtrStart uint64, err error) {
              hm.Lock()
              defer hm.Unlock()
              newEvents = make([]*muksevt.Event, len(events))
              err = hm.db.Update(func(tx *bolt.Tx) error {
          Severity: Minor
          Found in matrix/history.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

          File room.go has 571 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: Minor
          Found in matrix/rooms/room.go - About 3 hrs to fix

            File message-view.go has 566 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: Minor
            Found in ui/message-view.go - About 3 hrs to fix

              Function NewCommandProcessor has 110 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func NewCommandProcessor(parent *MainView) *CommandProcessor {
                  return &CommandProcessor{
                      gomuksPointerContainer: gomuksPointerContainer{
                          MainView: parent,
                          UI:       parent.parent,
              Severity: Major
              Found in ui/command-processor.go - About 3 hrs 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

                  RoomView has 52 methods (exceeds 50 allowed). Consider refactoring.
                  Open

                  type RoomView struct {
                      topic    *mauview.TextView
                      content  *MessageView
                      status   *mauview.TextField
                      userList *MemberList
                  Severity: Major
                  Found in ui/room-view.go - About 2 hrs to fix

                    Method RoomList.clickRoom has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (list *RoomList) clickRoom(line, column int, mod bool) bool {
                        line += list.scrollOffset
                        if line < 0 {
                            return false
                        }
                    Severity: Minor
                    Found in ui/room-list.go - About 1 hr 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 MessageView.AddMessage has 64 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (view *MessageView) AddMessage(ifcMessage ifc.Message, direction MessageDirection) {
                        if ifcMessage == nil {
                            return
                        }
                        message, ok := ifcMessage.(*messages.UIMessage)
                    Severity: Minor
                    Found in ui/message-view.go - About 1 hr 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 HistoryManager.store has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (hm *HistoryManager) store(room *rooms.Room, events []*event.Event, append bool) (newEvents []*muksevt.Event, newPtrStart uint64, err error) {
                            hm.Lock()
                            defer hm.Unlock()
                            newEvents = make([]*muksevt.Event, len(events))
                            err = hm.db.Update(func(tx *bolt.Tx) error {
                        Severity: Minor
                        Found in matrix/history.go - About 1 hr to fix

                          Method MessageView.Draw has 60 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (view *MessageView) Draw(screen mauview.Screen) {
                              view.setSize(screen.Size())
                              view.recalculateBuffers()
                          
                              height := view.Height()
                          Severity: Minor
                          Found in ui/message-view.go - About 1 hr to fix

                            Function cmdToggle has 58 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func cmdToggle(cmd *Command) {
                                if len(cmd.Args) == 0 {
                                    cmd.Reply(makeUsage())
                                    return
                                }
                            Severity: Minor
                            Found in ui/commands.go - About 1 hr to fix

                              Function cmdCrossSigningGenerate has 54 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func cmdCrossSigningGenerate(cmd *Command, container ifc.MatrixContainer, mach *crypto.OlmMachine, client *mautrix.Client, force bool) {
                                  if !force {
                                      existingKeys := mach.GetOwnCrossSigningPublicKeys()
                                      if existingKeys != nil {
                                          cmd.Reply("Found existing cross-signing keys. Use `--force` if you want to overwrite them.")
                              Severity: Minor
                              Found in ui/crypto-commands.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

                                    Function ParseStateEvent has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                                    Open

                                    func ParseStateEvent(evt *muksevt.Event, displayname string) *UIMessage {
                                        text := tstring.NewColorTString(displayname, widget.GetHashColor(evt.Sender)).Append(" ")
                                        switch content := evt.Content.Parsed.(type) {
                                        case *event.TopicEventContent:
                                            if len(content.Topic) == 0 {
                                    Severity: Minor
                                    Found in ui/messages/parser.go - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language