wechaty/go-wechaty

View on GitHub

Showing 10 of 544 total issues

Method Wechaty.initPuppetEventBridge has a Cognitive Complexity of 85 (exceeds 14 allowed). Consider refactoring.
Open

func (w *Wechaty) initPuppetEventBridge() {
    // TODO temporary
    for _, name := range schemas.GetEventNames() {
        name := name
        switch name {
Severity: Minor
Found in wechaty/wechaty.go - About 1 day 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 Wechaty.initPuppetEventBridge has 180 lines of code (exceeds 45 allowed). Consider refactoring.
Open

func (w *Wechaty) initPuppetEventBridge() {
    // TODO temporary
    for _, name := range schemas.GetEventNames() {
        name := name
        switch name {
Severity: Major
Found in wechaty/wechaty.go - About 6 hrs to fix

    PuppetService has 66 methods (exceeds 60 allowed). Consider refactoring.
    Open

    type PuppetService struct {
        *wechatyPuppet.Puppet
        grpcConn    *grpc.ClientConn
        grpcClient  pbwechaty.PuppetClient
        eventStream pbwechaty.Puppet_EventClient
    Severity: Major
    Found in wechaty-puppet-service/puppet_service.go - About 3 hrs to fix

      File puppet_service.go has 1010 lines of code (exceeds 1000 allowed). Consider refactoring.
      Open

      package puppetservice
      
      import (
          "context"
          "crypto/x509"
      Severity: Major
      Found in wechaty-puppet-service/puppet_service.go - About 2 hrs to fix

        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
            }
        Severity: Minor
        Found in wechaty/user/message.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 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
            }
        Severity: Minor
        Found in wechaty/user/message.go - About 1 hr to fix

          Method Puppet.messageQueryFilterFactory has 50 lines of code (exceeds 45 allowed). Consider refactoring.
          Open

          func (p *Puppet) messageQueryFilterFactory(query *schemas.MessageQueryFilter) schemas.MessagePayloadFilterFunction {
              var filters []schemas.MessagePayloadFilterFunction
          
              // Deprecated FromId compatible
              //nolint:staticcheck
          Severity: Minor
          Found in wechaty-puppet/puppet.go - About 1 hr to fix

            Method emitter.Once has a Cognitive Complexity of 18 (exceeds 14 allowed). Consider refactoring.
            Open

            func (e *emitter) Once(evt EventName, listener ...Listener) {
                if len(listener) == 0 {
                    return
                }
            
            
            Severity: Minor
            Found in wechaty-puppet/events/events.go - About 55 mins 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 Wechaty.initPuppetEventBridge has 14 return statements (exceeds 12 allowed).
            Open

            func (w *Wechaty) initPuppetEventBridge() {
                // TODO temporary
                for _, name := range schemas.GetEventNames() {
                    name := name
                    switch name {
            Severity: Major
            Found in wechaty/wechaty.go - About 40 mins to fix

              Method Puppet.messageQueryFilterFactory has a Cognitive Complexity of 16 (exceeds 14 allowed). Consider refactoring.
              Open

              func (p *Puppet) messageQueryFilterFactory(query *schemas.MessageQueryFilter) schemas.MessagePayloadFilterFunction {
                  var filters []schemas.MessagePayloadFilterFunction
              
                  // Deprecated FromId compatible
                  //nolint:staticcheck
              Severity: Minor
              Found in wechaty-puppet/puppet.go - About 35 mins 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

              Severity
              Category
              Status
              Source
              Language