Method Message.MentionList
has a Cognitive Complexity of 23 (exceeds 14 allowed). Consider refactoring. Open
func (m *Message) MentionList() []_interface.IContact {
room := m.Room()
if m.Type() != schemas.MessageTypeText || room == nil {
return nil
}
- 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 Message.MentionList
has 52 lines of code (exceeds 45 allowed). Consider refactoring. Open
func (m *Message) MentionList() []_interface.IContact {
room := m.Room()
if m.Type() != schemas.MessageTypeText || room == nil {
return nil
}
Similar blocks of code found in 3 locations. Consider refactoring. Open
func (m *Message) ToUrlLink() (*UrlLink, error) {
if m.Type() != schemas.MessageTypeURL {
return nil, errors.New("message not a Url Link")
}
urlPayload, err := m.GetPuppet().MessageURL(m.id)
- 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 109.
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 3 locations. Consider refactoring. Open
func (m *Message) ToMiniProgram() (*MiniProgram, error) {
if m.Type() != schemas.MessageTypeMiniProgram {
return nil, errors.New("message not a MiniProgram")
}
miniProgramPayload, err := m.GetPuppet().MessageMiniProgram(m.id)
- 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 109.
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 3 locations. Consider refactoring. Open
func (m *Message) ToLocation() (*Location, error) {
if m.Type() != schemas.MessageTypeLocation {
return nil, errors.New("message not a Location")
}
- 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 109.
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 3 locations. Consider refactoring. Open
func (m *Message) Listener() _interface.IContact {
if m.payload.ListenerId == "" {
return nil
}
return m.GetWechaty().Contact().Load(m.payload.ListenerId)
- 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 86.
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 3 locations. Consider refactoring. Open
func (m *Message) Talker() _interface.IContact {
if m.payload.TalkerId == "" {
return nil
}
return m.GetWechaty().Contact().Load(m.payload.TalkerId)
- 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 86.
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
var listenerId should be listenerID Open
listenerId := m.payload.ListenerId
- Exclude checks
method sayId should be sayID Open
func (m *Message) sayId() (string, error) {
- Exclude checks
exported method Message.Ready should have comment or be unexported Open
func (m *Message) Ready() (err error) {
- Exclude checks
exported method Message.MentionSelf should have comment or be unexported Open
func (m *Message) MentionSelf() bool {
- Exclude checks
exported method Message.MentionText should have comment or be unexported Open
func (m *Message) MentionText() string {
- Exclude checks
exported type Message should have comment or be unexported Open
type Message struct {
- Exclude checks
exported method Message.Age should have comment or be unexported Open
func (m *Message) Age() time.Duration {
- Exclude checks
method ToUrlLink should be ToURLLink Open
func (m *Message) ToUrlLink() (*UrlLink, error) {
- Exclude checks
exported method Message.ToMiniProgram should have comment or be unexported Open
func (m *Message) ToMiniProgram() (*MiniProgram, error) {
- Exclude checks
var talkerId should be talkerID Open
talkerId := m.payload.TalkerId
- Exclude checks
var roomId should be roomID Open
roomId := m.payload.RoomId
- Exclude checks
exported method Message.ToLocation should have comment or be unexported Open
func (m *Message) ToLocation() (*Location, error) {
- Exclude checks
var roomId should be roomID Open
roomId := m.payload.RoomId
- Exclude checks
exported method Message.IsReady should have comment or be unexported Open
func (m *Message) IsReady() bool {
- Exclude checks
method parameter contactOrRoomId should be contactOrRoomID Open
func (m *Message) Forward(contactOrRoomId string) error {
- Exclude checks
var originalMessageId should be originalMessageID Open
originalMessageId := m.Text()
- Exclude checks
exported method Message.ToUrlLink should have comment or be unexported Open
func (m *Message) ToUrlLink() (*UrlLink, error) {
- Exclude checks
var conversationId should be conversationID Open
conversationId, err := m.sayId()
- Exclude checks