Showing 97 of 102 total issues
File matrix.go
has 1145 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
File room-view.go
has 806 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
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
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
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 {
- Read upRead up
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
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
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,
Container
has 54 methods (exceeds 50 allowed). Consider refactoring. Open
type Container struct {
client *mautrix.Client
crypto ifc.Crypto
syncer *GomuksSyncer
gmx ifc.Gomuks
RoomView
has 52 methods (exceeds 50 allowed). Consider refactoring. Open
type RoomView struct {
topic *mauview.TextView
content *MessageView
status *mauview.TextField
userList *MemberList
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
}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function main
has 74 lines of code (exceeds 50 allowed). Consider refactoring. Open
func main() {
flag.SetHelpTitles(
"gomuks - A terminal Matrix client written in Go.",
"gomuks [-vch] [--clear-all-data]",
)
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
}
- Read upRead up
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 Container.InitClient
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (c *Container) InitClient(isStartup bool) error {
if len(c.config.HS) == 0 {
if isStartup {
return nil
}
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)
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
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 {
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()
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
}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76