Showing 11 of 25 total issues
Function makeNotifiers
has 69 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func makeNotifiers() (map[string]notifier.Notifier, error) {
notifiers := make(map[string]notifier.Notifier)
if config.Stderr.Enabled {
notifiers["stderr"] = ¬ifier.StdErr{}
}
Function main
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
webhookSecret := ""
if r.Method != http.MethodPost {
Function NewXmpp
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func NewXmpp(To []string,
Server string,
Port int,
User string,
Password string,
Function main
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
webhookSecret := ""
if r.Method != http.MethodPost {
- 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
Function main
has 7 return statements (exceeds 4 allowed). Open
Open
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
webhookSecret := ""
if r.Method != http.MethodPost {
Function getSignalsHandler
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func getSignalsHandler(n *nanny.Nanny, notifiers notifiers, store storage.Storage, w http.ResponseWriter, req *http.Request) error {
Function signalHandler
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func signalHandler(n *nanny.Nanny, notifiers notifiers, store storage.Storage, w http.ResponseWriter, req *http.Request) error {
Function NewWebhook
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func NewWebhook(WebhookURL string,
WebhookURLAllClear string,
WebhookSecret string,
RequestTimeout time.Duration,
AllowInsecureTLS bool) (Notifier, error) {
Method twilio.NotifyAllClear
has 5 return statements (exceeds 4 allowed). Open
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")
}
Method twilio.Notify
has 5 return statements (exceeds 4 allowed). Open
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")
}
Function makeNotifiers
has 5 return statements (exceeds 4 allowed). Open
Open
func makeNotifiers() (map[string]notifier.Notifier, error) {
notifiers := make(map[string]notifier.Notifier)
if config.Stderr.Enabled {
notifiers["stderr"] = ¬ifier.StdErr{}
}