hunterlong/statup

View on GitHub

Showing 423 of 423 total issues

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

func resetCli() error {
    d := utils.Directory
    fmt.Println("Statping directory: ", d)
    assets := d + "/assets"
    if utils.FolderExists(assets) {
Severity: Major
Found in cmd/cli.go - About 35 mins to fix

    Method discord.OnTest has 5 return statements (exceeds 4 allowed).
    Open

    func (d *discord) OnTest() (string, error) {
        outError := errors.New("incorrect discord URL, please confirm URL is correct")
        message := `{"content": "Testing the discord notifier"}`
        contents, _, err := utils.HttpRequest(Discorder.Host.String, "POST", "application/json", nil, bytes.NewBuffer([]byte(message)), time.Duration(10*time.Second), true, nil)
        if string(contents) == "" {
    Severity: Major
    Found in notifiers/discord.go - About 35 mins to fix

      Function LoadConfigs has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
      Open

      func LoadConfigs(cfgFile string) (*DbConfig, error) {
          writeAble, err := utils.DirWritable(utils.Directory)
          if err != nil {
              return nil, err
          }
      Severity: Minor
      Found in types/configs/load.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

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

      func apiNotifierUpdateHandler(w http.ResponseWriter, r *http.Request) {
          vars := mux.Vars(r)
          notifer, err := notifications.Find(vars["notifier"])
          if err != nil {
              sendErrorJson(err, w, r)
      Severity: Major
      Found in handlers/notifications.go - About 35 mins to fix

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

        func ScopeName(r *http.Request) string {
            if ok := hasAPIQuery(r); ok {
                return "admin"
            }
            if ok := hasAuthorizationHeader(r); ok {
        Severity: Major
        Found in handlers/handlers.go - About 35 mins to fix

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

          func hasAPIQuery(r *http.Request) bool {
              query := r.URL.Query()
              key := query.Get("api")
              if key == "" {
                  return false
          Severity: Major
          Found in handlers/authentication.go - About 35 mins to fix

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

            func parseToken(token string) (JwtClaim, error) {
                var claims JwtClaim
                tkn, err := jwt.ParseWithClaims(token, &claims, func(token *jwt.Token) (interface{}, error) {
                    return jwtKey, nil
                })
            Severity: Major
            Found in handlers/jwt.go - About 35 mins to fix

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

              func CheckHttp(s *Service, record bool) (*Service, error) {
                  defer s.updateLastCheck()
                  timer := prometheus.NewTimer(metrics.ServiceTimer(s.Name))
                  defer timer.ObserveDuration()
              
              
              Severity: Major
              Found in types/services/routine.go - About 35 mins to fix

                Function SafeJson has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                Open

                func SafeJson(val reflect.Value, scope string) map[string]interface{} {
                    thisData := make(map[string]interface{})
                    if val.Kind() == reflect.Interface && !val.IsNil() {
                        elm := val.Elem()
                        if elm.Kind() == reflect.Ptr && !elm.IsNil() && elm.Elem().Kind() == reflect.Ptr {
                Severity: Minor
                Found in handlers/scope.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

                Method Service.UptimeData has 5 return statements (exceeds 4 allowed).
                Open

                func (s Service) UptimeData(hits []*hits.Hit, fails []*failures.Failure) (*UptimeSeries, error) {
                    if len(hits) == 0 {
                        return nil, errors.New("service does not have any successful hits")
                    }
                    // if theres no failures, then its been online 100%,
                Severity: Major
                Found in types/services/methods.go - About 35 mins to fix

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

                  func googleOAuth(r *http.Request) (*oAuth, error) {
                      auth := core.App.OAuth
                      code := r.URL.Query().Get("code")
                  
                      config := &oauth2.Config{
                  Severity: Major
                  Found in handlers/oauth_google.go - About 35 mins to fix

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

                    func LoadServicesYaml() (*yamlFile, error) {
                        if !utils.FileExists(utils.Directory + "/services.yml") {
                            return nil, nil
                        }
                    
                    
                    Severity: Major
                    Found in types/services/yaml.go - About 35 mins to fix

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

                      func findGroup(r *http.Request) (*groups.Group, error) {
                          vars := mux.Vars(r)
                          if utils.NotNumber(vars["id"]) {
                              return nil, errors.NotNumber
                          }
                      Severity: Major
                      Found in handlers/groups.go - About 35 mins to fix

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

                        func IsFullAuthenticated(r *http.Request) bool {
                            if ok := hasSetupEnv(); ok {
                                return true
                            }
                            if ok := hasAPIQuery(r); ok {
                        Severity: Major
                        Found in handlers/handlers.go - About 35 mins to fix

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

                          func runOnce() error {
                              config, err := configs.LoadConfigs(configFile)
                              if err != nil {
                                  return errors.Wrap(err, "config.yml file not found")
                              }
                          Severity: Major
                          Found in cmd/cli.go - About 35 mins to fix

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

                            func LoadConfigs(cfgFile string) (*DbConfig, error) {
                                writeAble, err := utils.DirWritable(utils.Directory)
                                if err != nil {
                                    return nil, err
                                }
                            Severity: Major
                            Found in types/configs/load.go - About 35 mins to fix

                              Function HttpRequest has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                              Open

                              func HttpRequest(endpoint, method string, contentType interface{}, headers []string, body io.Reader, timeout time.Duration, verifySSL bool, customTLS *tls.Config) ([]byte, *http.Response, error) {
                                  var err error
                                  var req *http.Request
                                  if method == "" {
                                      method = "GET"
                              Severity: Minor
                              Found in utils/utils.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

                              Method Service.Validate has 5 return statements (exceeds 4 allowed).
                              Open

                              func (s *Service) Validate() error {
                                  if s.Name == "" {
                                      return errors.New("missing service name")
                                  } else if s.Domain == "" && s.Type != "static" {
                                      return errors.New("missing domain name")
                              Severity: Major
                              Found in types/services/database.go - About 35 mins to fix

                                Method DbConfig.ConnectionString has 5 return statements (exceeds 4 allowed).
                                Open

                                func (d *DbConfig) ConnectionString() string {
                                    var conn string
                                    postgresSSL := utils.Params.GetString("POSTGRES_SSLMODE")
                                
                                    switch d.DbConn {
                                Severity: Major
                                Found in types/configs/methods.go - About 35 mins to fix

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

                                  func findSQLin(path string) (string, error) {
                                      filename := SqliteFilename
                                      var found []string
                                      err := filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
                                          if info.IsDir() {
                                  Severity: Major
                                  Found in types/configs/file.go - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language