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) {
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) == "" {
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
}
- 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 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)
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 {
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
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
})
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()
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 {
- 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 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%,
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{
Function LoadServicesYaml
has 5 return statements (exceeds 4 allowed). Open
func LoadServicesYaml() (*yamlFile, error) {
if !utils.FileExists(utils.Directory + "/services.yml") {
return nil, nil
}
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
}
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 {
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")
}
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
}
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"
- 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 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")
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 {
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() {