lunemec/nanny

View on GitHub

Showing 11 of 25 total issues

Function makeNotifiers has 69 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func makeNotifiers() (map[string]notifier.Notifier, error) {
    notifiers := make(map[string]notifier.Notifier)
    if config.Stderr.Enabled {
        notifiers["stderr"] = &notifier.StdErr{}
    }
Severity: Minor
Found in cmd/root.go - About 1 hr to fix

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

    func main() {
        http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
            webhookSecret := ""
    
            if r.Method != http.MethodPost {
    Severity: Minor
    Found in receiver_examples/webhook_receiver_example.go - About 1 hr to fix

      Function NewXmpp has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func NewXmpp(To []string,
          Server string,
          Port int,
          User string,
          Password string,
      Severity: Major
      Found in pkg/notifier/xmpp.go - About 50 mins to fix

        Function main has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
        Open

        func main() {
            http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
                webhookSecret := ""
        
                if r.Method != http.MethodPost {
        Severity: Minor
        Found in receiver_examples/webhook_receiver_example.go - About 45 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

        Function main has 7 return statements (exceeds 4 allowed).
        Open

        func main() {
            http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
                webhookSecret := ""
        
                if r.Method != http.MethodPost {
        Severity: Major
        Found in receiver_examples/webhook_receiver_example.go - About 45 mins to fix

          Function getSignalsHandler has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          func getSignalsHandler(n *nanny.Nanny, notifiers notifiers, store storage.Storage, w http.ResponseWriter, req *http.Request) error {
          Severity: Minor
          Found in api/api.go - About 35 mins to fix

            Function signalHandler has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            func signalHandler(n *nanny.Nanny, notifiers notifiers, store storage.Storage, w http.ResponseWriter, req *http.Request) error {
            Severity: Minor
            Found in api/api.go - About 35 mins to fix

              Function NewWebhook has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func NewWebhook(WebhookURL string,
                  WebhookURLAllClear string,
                  WebhookSecret string,
                  RequestTimeout time.Duration,
                  AllowInsecureTLS bool) (Notifier, error) {
              Severity: Minor
              Found in pkg/notifier/webhook.go - About 35 mins to fix

                Method twilio.NotifyAllClear has 5 return statements (exceeds 4 allowed).
                Open

                func (n *twilio) NotifyAllClear(msg Message) error {
                    resp, exc, err := n.t.SendSMS(n.from, n.to, msg.FormatAllClear(), "", n.appSid)
                    if err != nil {
                        return errors.Wrap(err, "unable to send SMS via twilio")
                    }
                Severity: Major
                Found in pkg/notifier/twilio.go - About 35 mins to fix

                  Method twilio.Notify has 5 return statements (exceeds 4 allowed).
                  Open

                  func (n *twilio) Notify(msg Message) error {
                      resp, exc, err := n.t.SendSMS(n.from, n.to, msg.Format(), "", n.appSid)
                      if err != nil {
                          return errors.Wrap(err, "unable to send SMS via twilio")
                      }
                  Severity: Major
                  Found in pkg/notifier/twilio.go - About 35 mins to fix

                    Function makeNotifiers has 5 return statements (exceeds 4 allowed).
                    Open

                    func makeNotifiers() (map[string]notifier.Notifier, error) {
                        notifiers := make(map[string]notifier.Notifier)
                        if config.Stderr.Enabled {
                            notifiers["stderr"] = &notifier.StdErr{}
                        }
                    Severity: Major
                    Found in cmd/root.go - About 35 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language