tulir/gomuks

View on GitHub

Showing 89 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

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                    func cmdKick(cmd *Command) {
                        if len(cmd.Args) < 1 {
                            cmd.Reply("Usage: /kick <user> [reason]")
                            return
                        }
                    Severity: Major
                    Found in ui/commands.go and 1 other location - About 2 hrs to fix
                    ui/commands.go on lines 571..586

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 201.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                    func cmdBan(cmd *Command) {
                        if len(cmd.Args) < 1 {
                            cmd.Reply("Usage: /ban <user> [reason]")
                            return
                        }
                    Severity: Major
                    Found in ui/commands.go and 1 other location - About 2 hrs to fix
                    ui/commands.go on lines 600..614

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 201.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    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

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                            func cmdUnban(cmd *Command) {
                                if len(cmd.Args) != 1 {
                                    cmd.Reply("Usage: /unban <user>")
                                    return
                                }
                            Severity: Major
                            Found in ui/commands.go and 1 other location - About 1 hr to fix
                            ui/commands.go on lines 559..569

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 151.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                            func cmdInvite(cmd *Command) {
                                if len(cmd.Args) != 1 {
                                    cmd.Reply("Usage: /invite <user id>")
                                    return
                                }
                            Severity: Major
                            Found in ui/commands.go and 1 other location - About 1 hr to fix
                            ui/commands.go on lines 588..598

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 151.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            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
                              Severity
                              Category
                              Status
                              Source
                              Language